diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-25 01:02:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 01:02:18 +0000 |
commit | 686349a75fc1d2cd778aa0025f858886a7d764cd (patch) | |
tree | 4a83fa74b1e4c5df875c8e319196f61857e7205b | |
parent | f1a1e2d7c5be99bb11b4d390cd0b6802a839f419 (diff) | |
parent | e543733a4cce1dab91155e7bea9510ca9895ecfd (diff) | |
download | nix-686349a75fc1d2cd778aa0025f858886a7d764cd.zip |
Merge #1707
1707: Upgrade sysctl to 0.4 r=asomers a=rtzoeller
Upgrade sysctl dev-dependency to 0.4 and handle its breaking API changes.
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/mount/bsd.rs | 5 | ||||
-rw-r--r-- | test/common/mod.rs | 11 | ||||
-rw-r--r-- | test/sys/test_lio_listio_resubmit.rs | 6 |
4 files changed, 13 insertions, 11 deletions
@@ -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" diff --git a/src/mount/bsd.rs b/src/mount/bsd.rs index b4d611ee..109522f9 100644 --- a/src/mount/bsd.rs +++ b/src/mount/bsd.rs @@ -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}; diff --git a/test/common/mod.rs b/test/common/mod.rs index 544a1ae3..caa39ab4 100644 --- a/test/common/mod.rs +++ b/test/common/mod.rs @@ -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); } @@ -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); } diff --git a/test/sys/test_lio_listio_resubmit.rs b/test/sys/test_lio_listio_resubmit.rs index c9077891..2ed058c2 100644 --- a/test/sys/test_lio_listio_resubmit.rs +++ b/test/sys/test_lio_listio_resubmit.rs @@ -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; @@ -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"); |