Skip to content

Commit 686349a

Browse files
bors[bot]rtzoeller
andauthored
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 <[email protected]>
2 parents f1a1e2d + e543733 commit 686349a

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ semver = "1.0.0"
8888
caps = "0.5.1"
8989

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

9393
[[test]]
9494
name = "test"

src/mount/bsd.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ pub type NmountResult = std::result::Result<(), NmountError>;
168168
/// To mount `target` onto `mountpoint` with `nullfs`:
169169
/// ```
170170
/// # use nix::unistd::Uid;
171-
/// # use ::sysctl::CtlValue;
172-
/// # if !Uid::current().is_root() && CtlValue::Int(0) == ::sysctl::value("vfs.usermount").unwrap() {
171+
/// # use ::sysctl::{CtlValue, Sysctl};
172+
/// # let ctl = ::sysctl::Ctl::new("vfs.usermount").unwrap();
173+
/// # if !Uid::current().is_root() && CtlValue::Int(0) == ctl.value().unwrap() {
173174
/// # return;
174175
/// # };
175176
/// use nix::mount::{MntFlags, Nmount, unmount};

test/common/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ cfg_if! {
3535
#[cfg(target_os = "freebsd")]
3636
#[macro_export] macro_rules! require_mount {
3737
($name:expr) => {
38-
use ::sysctl::CtlValue;
38+
use ::sysctl::{CtlValue, Sysctl};
3939
use nix::unistd::Uid;
4040

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

62-
if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed")
63-
.unwrap()
63+
let ctl = ::sysctl::Ctl::new("security.jail.jailed").unwrap();
64+
if let CtlValue::Int(1) = ctl.value().unwrap()
6465
{
6566
skip!("{} cannot run in a jail. Skipping test.", $name);
6667
}

test/sys/test_lio_listio_resubmit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use nix::sys::signal::SigevNotify;
1111
use nix::unistd::{SysconfVar, sysconf};
1212
use std::os::unix::io::AsRawFd;
1313
use std::{thread, time};
14-
use sysctl::CtlValue;
14+
use sysctl::{CtlValue, Sysctl};
1515
use tempfile::tempfile;
1616

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

0 commit comments

Comments
 (0)