1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use super::consts::*;
bitflags! {
pub struct CtlFlags : libc::c_uint {
const RD = CTLFLAG_RD;
const WR = CTLFLAG_WR;
const RW = Self::RD.bits | Self::WR.bits;
const DORMANT = CTLFLAG_DORMANT;
const ANYBODY = CTLFLAG_ANYBODY;
const SECURE = CTLFLAG_SECURE;
const PRISON = CTLFLAG_PRISON;
const DYN = CTLFLAG_DYN;
const SKIP = CTLFLAG_DORMANT;
const SECURE_MASK = 0x00F00000;
const TUN = CTLFLAG_TUN;
const RDTUN = Self::RD.bits | Self::TUN.bits;
const RWTUN = Self::RW.bits | Self::TUN.bits;
const MPSAFE = CTLFLAG_MPSAFE;
const VNET = CTLFLAG_VNET;
const DYING = CTLFLAG_DYING;
const CAPRD = CTLFLAG_CAPRD;
const CAPWR = CTLFLAG_CAPWR;
const STATS = CTLFLAG_STATS;
const NOFETCH = CTLFLAG_NOFETCH;
const CAPRW = Self::CAPRD.bits | Self::CAPWR.bits;
}
}
#[cfg(test)]
mod tests {
use crate::Sysctl;
#[test]
fn ctl_flags() {
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
let ctl: crate::Ctl = crate::Ctl::new("kern.ostype").unwrap();
#[cfg(any(target_os = "android", target_os = "linux"))]
let ctl: crate::Ctl = crate::Ctl::new("kernel.ostype").unwrap();
let flags: crate::CtlFlags = ctl.flags().unwrap();
assert_eq!(flags.bits() & crate::CTLFLAG_RD, crate::CTLFLAG_RD);
assert_eq!(flags.bits() & crate::CTLFLAG_WR, 0);
}
}