Skip to content

Upgrade sysctl to 0.4 #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ semver = "1.0.0"
caps = "0.5.1"

[target.'cfg(target_os = "freebsd")'.dev-dependencies]
sysctl = "0.1"
sysctl = "0.4"

[[test]]
name = "test"
Expand Down
5 changes: 3 additions & 2 deletions src/mount/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ pub type NmountResult = std::result::Result<(), NmountError>;
/// To mount `target` onto `mountpoint` with `nullfs`:
/// ```
/// # use nix::unistd::Uid;
/// # use ::sysctl::CtlValue;
/// # if !Uid::current().is_root() && CtlValue::Int(0) == ::sysctl::value("vfs.usermount").unwrap() {
/// # use ::sysctl::{CtlValue, Sysctl};
/// # let ctl = ::sysctl::Ctl::new("vfs.usermount").unwrap();
/// # if !Uid::current().is_root() && CtlValue::Int(0) == ctl.value().unwrap() {
/// # return;
/// # };
/// use nix::mount::{MntFlags, Nmount, unmount};
Expand Down
11 changes: 6 additions & 5 deletions test/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ cfg_if! {
#[cfg(target_os = "freebsd")]
#[macro_export] macro_rules! require_mount {
($name:expr) => {
use ::sysctl::CtlValue;
use ::sysctl::{CtlValue, Sysctl};
use nix::unistd::Uid;

if !Uid::current().is_root() && CtlValue::Int(0) == ::sysctl::value("vfs.usermount").unwrap()
let ctl = ::sysctl::Ctl::new("vfs.usermount").unwrap();
if !Uid::current().is_root() && CtlValue::Int(0) == ctl.value().unwrap()
{
skip!("{} requires the ability to mount file systems. Skipping test.", $name);
}
Expand All @@ -57,10 +58,10 @@ cfg_if! {
#[cfg(target_os = "freebsd")]
#[macro_export] macro_rules! skip_if_jailed {
($name:expr) => {
use ::sysctl::CtlValue;
use ::sysctl::{CtlValue, Sysctl};

if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed")
.unwrap()
let ctl = ::sysctl::Ctl::new("security.jail.jailed").unwrap();
if let CtlValue::Int(1) = ctl.value().unwrap()
{
skip!("{} cannot run in a jail. Skipping test.", $name);
}
Expand Down
6 changes: 3 additions & 3 deletions test/sys/test_lio_listio_resubmit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use nix::sys::signal::SigevNotify;
use nix::unistd::{SysconfVar, sysconf};
use std::os::unix::io::AsRawFd;
use std::{thread, time};
use sysctl::CtlValue;
use sysctl::{CtlValue, Sysctl};
use tempfile::tempfile;

const BYTES_PER_OP: usize = 512;
Expand Down Expand Up @@ -44,8 +44,8 @@ fn test_lio_listio_resubmit() {
// Lookup system resource limits
let alm = sysconf(SysconfVar::AIO_LISTIO_MAX)
.expect("sysconf").unwrap() as usize;
let maqpp = if let CtlValue::Int(x) = sysctl::value(
"vfs.aio.max_aio_queue_per_proc").unwrap(){
let ctl = sysctl::Ctl::new("vfs.aio.max_aio_queue_per_proc").unwrap();
let maqpp = if let CtlValue::Int(x) = ctl.value().unwrap() {
x as usize
} else {
panic!("unknown sysctl");
Expand Down