Skip to content

Commit 2038ce6

Browse files
bors[bot]rtzoeller
andauthored
Merge #1653
1653: Document inotify, mman, personality, reboot, timerfd r=asomers a=rtzoeller Document the `inotify`, `mman`, `personality`, `reboot`, and `timerfd` modules. Co-authored-by: Ryan Zoeller <[email protected]>
2 parents 0bd56d9 + 7baf6d1 commit 2038ce6

File tree

6 files changed

+75
-6
lines changed

6 files changed

+75
-6
lines changed

src/sys/inotify.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,63 @@ use cfg_if::cfg_if;
4141
libc_bitflags! {
4242
/// Configuration options for [`inotify_add_watch`](fn.inotify_add_watch.html).
4343
pub struct AddWatchFlags: u32 {
44+
/// File was accessed.
4445
IN_ACCESS;
46+
/// File was modified.
4547
IN_MODIFY;
48+
/// Metadata changed.
4649
IN_ATTRIB;
50+
/// Writable file was closed.
4751
IN_CLOSE_WRITE;
52+
/// Nonwritable file was closed.
4853
IN_CLOSE_NOWRITE;
54+
/// File was opened.
4955
IN_OPEN;
56+
/// File was moved from X.
5057
IN_MOVED_FROM;
58+
/// File was moved to Y.
5159
IN_MOVED_TO;
60+
/// Subfile was created.
5261
IN_CREATE;
62+
/// Subfile was deleted.
5363
IN_DELETE;
64+
/// Self was deleted.
5465
IN_DELETE_SELF;
66+
/// Self was moved.
5567
IN_MOVE_SELF;
5668

69+
/// Backing filesystem was unmounted.
5770
IN_UNMOUNT;
71+
/// Event queue overflowed.
5872
IN_Q_OVERFLOW;
73+
/// File was ignored.
5974
IN_IGNORED;
6075

76+
/// Combination of `IN_CLOSE_WRITE` and `IN_CLOSE_NOWRITE`.
6177
IN_CLOSE;
78+
/// Combination of `IN_MOVED_FROM` and `IN_MOVED_TO`.
6279
IN_MOVE;
6380

81+
/// Only watch the path if it is a directory.
6482
IN_ONLYDIR;
83+
/// Don't follow symlinks.
6584
IN_DONT_FOLLOW;
6685

86+
/// Event occurred against directory.
6787
IN_ISDIR;
88+
/// Only send event once.
6889
IN_ONESHOT;
90+
/// All of the events.
6991
IN_ALL_EVENTS;
7092
}
7193
}
7294

7395
libc_bitflags! {
7496
/// Configuration options for [`inotify_init1`](fn.inotify_init1.html).
7597
pub struct InitFlags: c_int {
98+
/// Set the `FD_CLOEXEC` flag on the file descriptor.
7699
IN_CLOEXEC;
100+
/// Set the `O_NONBLOCK` flag on the open file description referred to by the new file descriptor.
77101
IN_NONBLOCK;
78102
}
79103
}

src/sys/mman.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ libc_enum!{
299299
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
300300
#[cfg_attr(docsrs, doc(cfg(all())))]
301301
MADV_CORE,
302+
/// This process should not be killed when swap space is exhausted.
302303
#[cfg(any(target_os = "freebsd"))]
303304
#[cfg_attr(docsrs, doc(cfg(all())))]
304305
MADV_PROTECT,
@@ -314,14 +315,18 @@ libc_enum!{
314315
#[cfg(any(target_os = "ios", target_os = "macos"))]
315316
#[cfg_attr(docsrs, doc(cfg(all())))]
316317
MADV_ZERO_WIRED_PAGES,
318+
/// Pages can be reused (by anyone).
317319
#[cfg(any(target_os = "ios", target_os = "macos"))]
318320
#[cfg_attr(docsrs, doc(cfg(all())))]
319321
MADV_FREE_REUSABLE,
322+
/// Caller wants to reuse those pages.
320323
#[cfg(any(target_os = "ios", target_os = "macos"))]
321324
#[cfg_attr(docsrs, doc(cfg(all())))]
322325
MADV_FREE_REUSE,
326+
// Darwin doesn't document this flag's behavior.
323327
#[cfg(any(target_os = "ios", target_os = "macos"))]
324328
#[cfg_attr(docsrs, doc(cfg(all())))]
329+
#[allow(missing_docs)]
325330
MADV_CAN_REUSE,
326331
}
327332
}

src/sys/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ feature! {
5555
#[cfg(not(target_os = "redox"))]
5656
feature! {
5757
#![feature = "mman"]
58-
#[allow(missing_docs)]
5958
pub mod mman;
6059
}
6160

6261
#[cfg(target_os = "linux")]
6362
feature! {
6463
#![feature = "personality"]
65-
#[allow(missing_docs)]
6664
pub mod personality;
6765
}
6866

@@ -93,7 +91,6 @@ feature! {
9391
#[cfg(target_os = "linux")]
9492
feature! {
9593
#![feature = "reboot"]
96-
#[allow(missing_docs)]
9794
pub mod reboot;
9895
}
9996

@@ -192,14 +189,12 @@ feature! {
192189
#[cfg(any(target_os = "android", target_os = "linux"))]
193190
feature! {
194191
#![feature = "inotify"]
195-
#[allow(missing_docs)]
196192
pub mod inotify;
197193
}
198194

199195
#[cfg(any(target_os = "android", target_os = "linux"))]
200196
feature! {
201197
#![feature = "time"]
202-
#[allow(missing_docs)]
203198
pub mod timerfd;
204199
}
205200

src/sys/personality.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Process execution domains
12
use crate::Result;
23
use crate::errno::Errno;
34

@@ -7,18 +8,44 @@ libc_bitflags! {
78
/// Flags used and returned by [`get()`](fn.get.html) and
89
/// [`set()`](fn.set.html).
910
pub struct Persona: c_int {
11+
/// Provide the legacy virtual address space layout.
1012
ADDR_COMPAT_LAYOUT;
13+
/// Disable address-space-layout randomization.
1114
ADDR_NO_RANDOMIZE;
15+
/// Limit the address space to 32 bits.
1216
ADDR_LIMIT_32BIT;
17+
/// Use `0xc0000000` as the offset at which to search a virtual memory
18+
/// chunk on [`mmap(2)`], otherwise use `0xffffe000`.
19+
///
20+
/// [`mmap(2)`]: https://man7.org/linux/man-pages/man2/mmap.2.html
1321
ADDR_LIMIT_3GB;
22+
/// User-space function pointers to signal handlers point to descriptors.
1423
#[cfg(not(any(target_env = "musl", target_env = "uclibc")))]
24+
#[cfg_attr(docsrs, doc(cfg(all())))]
1525
FDPIC_FUNCPTRS;
26+
/// Map page 0 as read-only.
1627
MMAP_PAGE_ZERO;
28+
/// `PROT_READ` implies `PROT_EXEC` for [`mmap(2)`].
29+
///
30+
/// [`mmap(2)`]: https://man7.org/linux/man-pages/man2/mmap.2.html
1731
READ_IMPLIES_EXEC;
32+
/// No effects.
1833
SHORT_INODE;
34+
/// [`select(2)`], [`pselect(2)`], and [`ppoll(2)`] do not modify the
35+
/// returned timeout argument when interrupted by a signal handler.
36+
///
37+
/// [`select(2)`]: https://man7.org/linux/man-pages/man2/select.2.html
38+
/// [`pselect(2)`]: https://man7.org/linux/man-pages/man2/pselect.2.html
39+
/// [`ppoll(2)`]: https://man7.org/linux/man-pages/man2/ppoll.2.html
1940
STICKY_TIMEOUTS;
41+
/// Have [`uname(2)`] report a 2.6.40+ version number rather than a 3.x
42+
/// version number.
43+
///
44+
/// [`uname(2)`]: https://man7.org/linux/man-pages/man2/uname.2.html
2045
#[cfg(not(any(target_env = "musl", target_env = "uclibc")))]
46+
#[cfg_attr(docsrs, doc(cfg(all())))]
2147
UNAME26;
48+
/// No effects.
2249
WHOLE_SECONDS;
2350
}
2451
}

src/sys/reboot.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,22 @@ libc_enum! {
1313
#[repr(i32)]
1414
#[non_exhaustive]
1515
pub enum RebootMode {
16+
/// Halt the system.
1617
RB_HALT_SYSTEM,
18+
/// Execute a kernel that has been loaded earlier with
19+
/// [`kexec_load(2)`](https://man7.org/linux/man-pages/man2/kexec_load.2.html).
1720
RB_KEXEC,
21+
/// Stop the system and switch off power, if possible.
1822
RB_POWER_OFF,
23+
/// Restart the system.
1924
RB_AUTOBOOT,
20-
// we do not support Restart2,
25+
// we do not support Restart2.
26+
/// Suspend the system using software suspend.
2127
RB_SW_SUSPEND,
2228
}
2329
}
2430

31+
/// Reboots or shuts down the system.
2532
pub fn reboot(how: RebootMode) -> Result<Infallible> {
2633
unsafe {
2734
libc::reboot(how as libc::c_int)

src/sys/timerfd.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,19 @@ libc_enum! {
6060
#[repr(i32)]
6161
#[non_exhaustive]
6262
pub enum ClockId {
63+
/// A settable system-wide real-time clock.
6364
CLOCK_REALTIME,
65+
/// A non-settable monotonically increasing clock.
66+
///
67+
/// Does not change after system startup.
68+
/// Does not measure time while the system is suspended.
6469
CLOCK_MONOTONIC,
70+
/// Like `CLOCK_MONOTONIC`, except that `CLOCK_BOOTTIME` includes the time
71+
/// that the system was suspended.
6572
CLOCK_BOOTTIME,
73+
/// Like `CLOCK_REALTIME`, but will wake the system if it is suspended.
6674
CLOCK_REALTIME_ALARM,
75+
/// Like `CLOCK_BOOTTIME`, but will wake the system if it is suspended.
6776
CLOCK_BOOTTIME_ALARM,
6877
}
6978
}
@@ -72,7 +81,9 @@ libc_bitflags! {
7281
/// Additional flags to change the behaviour of the file descriptor at the
7382
/// time of creation.
7483
pub struct TimerFlags: c_int {
84+
/// Set the `O_NONBLOCK` flag on the open file description referred to by the new file descriptor.
7585
TFD_NONBLOCK;
86+
/// Set the `FD_CLOEXEC` flag on the file descriptor.
7687
TFD_CLOEXEC;
7788
}
7889
}

0 commit comments

Comments
 (0)