rustix/backend/libc/fs/
inotify.rs

1//! inotify support for working with inotify objects.
2
3use crate::backend::c;
4use bitflags::bitflags;
5
6bitflags! {
7    /// `IN_*` for use with [`inotify::init`].
8    ///
9    /// [`inotify::init`]: crate::fs::inotify::init
10    #[repr(transparent)]
11    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
12    pub struct CreateFlags: u32 {
13        /// `IN_CLOEXEC`
14        const CLOEXEC = bitcast!(c::IN_CLOEXEC);
15        /// `IN_NONBLOCK`
16        const NONBLOCK = bitcast!(c::IN_NONBLOCK);
17
18        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
19        const _ = !0;
20    }
21}
22
23bitflags! {
24    /// `IN*` for use with [`inotify::add_watch`].
25    ///
26    /// [`inotify::add_watch`]: crate::fs::inotify::add_watch
27    #[repr(transparent)]
28    #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)]
29    pub struct WatchFlags: u32 {
30        /// `IN_ACCESS`
31        const ACCESS = c::IN_ACCESS;
32        /// `IN_ATTRIB`
33        const ATTRIB = c::IN_ATTRIB;
34        /// `IN_CLOSE_NOWRITE`
35        const CLOSE_NOWRITE = c::IN_CLOSE_NOWRITE;
36        /// `IN_CLOSE_WRITE`
37        const CLOSE_WRITE = c::IN_CLOSE_WRITE;
38        /// `IN_CREATE`
39        const CREATE = c::IN_CREATE;
40        /// `IN_DELETE`
41        const DELETE = c::IN_DELETE;
42        /// `IN_DELETE_SELF`
43        const DELETE_SELF = c::IN_DELETE_SELF;
44        /// `IN_MODIFY`
45        const MODIFY = c::IN_MODIFY;
46        /// `IN_MOVE_SELF`
47        const MOVE_SELF = c::IN_MOVE_SELF;
48        /// `IN_MOVED_FROM`
49        const MOVED_FROM = c::IN_MOVED_FROM;
50        /// `IN_MOVED_TO`
51        const MOVED_TO = c::IN_MOVED_TO;
52        /// `IN_OPEN`
53        const OPEN = c::IN_OPEN;
54
55        /// `IN_CLOSE`
56        const CLOSE = c::IN_CLOSE;
57        /// `IN_MOVE`
58        const MOVE = c::IN_MOVE;
59        /// `IN_ALL_EVENTS`
60        const ALL_EVENTS = c::IN_ALL_EVENTS;
61
62        /// `IN_DONT_FOLLOW`
63        const DONT_FOLLOW = c::IN_DONT_FOLLOW;
64        /// `IN_EXCL_UNLINK`
65        const EXCL_UNLINK = 1;
66        /// `IN_MASK_ADD`
67        const MASK_ADD = 1;
68        /// `IN_MASK_CREATE`
69        const MASK_CREATE = 1;
70        /// `IN_ONESHOT`
71        const ONESHOT = c::IN_ONESHOT;
72        /// `IN_ONLYDIR`
73        const ONLYDIR = c::IN_ONLYDIR;
74
75        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
76        const _ = !0;
77    }
78}
79
80bitflags! {
81    /// `IN*` for use with [`inotify::Reader`].
82    ///
83    /// [`inotify::Reader`]: crate::fs::inotify::Reader
84    #[repr(transparent)]
85    #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)]
86    pub struct ReadFlags: u32 {
87        /// `IN_ACCESS`
88        const ACCESS = c::IN_ACCESS;
89        /// `IN_ATTRIB`
90        const ATTRIB = c::IN_ATTRIB;
91        /// `IN_CLOSE_NOWRITE`
92        const CLOSE_NOWRITE = c::IN_CLOSE_NOWRITE;
93        /// `IN_CLOSE_WRITE`
94        const CLOSE_WRITE = c::IN_CLOSE_WRITE;
95        /// `IN_CREATE`
96        const CREATE = c::IN_CREATE;
97        /// `IN_DELETE`
98        const DELETE = c::IN_DELETE;
99        /// `IN_DELETE_SELF`
100        const DELETE_SELF = c::IN_DELETE_SELF;
101        /// `IN_MODIFY`
102        const MODIFY = c::IN_MODIFY;
103        /// `IN_MOVE_SELF`
104        const MOVE_SELF = c::IN_MOVE_SELF;
105        /// `IN_MOVED_FROM`
106        const MOVED_FROM = c::IN_MOVED_FROM;
107        /// `IN_MOVED_TO`
108        const MOVED_TO = c::IN_MOVED_TO;
109        /// `IN_OPEN`
110        const OPEN = c::IN_OPEN;
111
112        /// `IN_IGNORED`
113        const IGNORED = c::IN_IGNORED;
114        /// `IN_ISDIR`
115        const ISDIR = c::IN_ISDIR;
116        /// `IN_Q_OVERFLOW`
117        const QUEUE_OVERFLOW = c::IN_Q_OVERFLOW;
118        /// `IN_UNMOUNT`
119        const UNMOUNT = c::IN_UNMOUNT;
120
121        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
122        const _ = !0;
123    }
124}