1
1
//! inotify support for working with inotifies
2
2
3
+ #![ allow( unused_qualifications) ]
4
+
5
+ use super :: inotify;
3
6
pub use crate :: backend:: fs:: inotify:: { CreateFlags , ReadFlags , WatchFlags } ;
4
7
use crate :: backend:: fs:: syscalls;
5
8
use crate :: fd:: { AsFd , OwnedFd } ;
@@ -9,13 +12,23 @@ use crate::io::{read_uninit, Errno};
9
12
use core:: mem:: { align_of, size_of, MaybeUninit } ;
10
13
use linux_raw_sys:: general:: inotify_event;
11
14
15
+ #[ deprecated( note = "Use add_watch." ) ]
16
+ #[ doc( hidden) ]
17
+ pub use add_watch as inotify_add_watch;
18
+ #[ deprecated( note = "Use init." ) ]
19
+ #[ doc( hidden) ]
20
+ pub use init as inotify_init;
21
+ #[ deprecated( note = "Use remove_watch." ) ]
22
+ #[ doc( hidden) ]
23
+ pub use remove_watch as inotify_remove_watch;
24
+
12
25
/// `inotify_init1(flags)`—Creates a new inotify object.
13
26
///
14
27
/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
15
28
/// descriptor from being implicitly passed across `exec` boundaries.
16
29
#[ doc( alias = "inotify_init1" ) ]
17
30
#[ inline]
18
- pub fn inotify_init ( flags : CreateFlags ) -> io:: Result < OwnedFd > {
31
+ pub fn init ( flags : inotify :: CreateFlags ) -> io:: Result < OwnedFd > {
19
32
syscalls:: inotify_init1 ( flags)
20
33
}
21
34
@@ -27,22 +40,23 @@ pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
27
40
/// Note: Due to the existence of hardlinks, providing two different paths to
28
41
/// this method may result in it returning the same watch descriptor. An
29
42
/// application should keep track of this externally to avoid logic errors.
43
+ #[ doc( alias = "inotify_add_watch" ) ]
30
44
#[ inline]
31
- pub fn inotify_add_watch < P : crate :: path:: Arg > (
45
+ pub fn add_watch < P : crate :: path:: Arg > (
32
46
inot : impl AsFd ,
33
47
path : P ,
34
- flags : WatchFlags ,
48
+ flags : inotify :: WatchFlags ,
35
49
) -> io:: Result < i32 > {
36
50
path. into_with_c_str ( |path| syscalls:: inotify_add_watch ( inot. as_fd ( ) , path, flags) )
37
51
}
38
52
39
53
/// `inotify_rm_watch(self, wd)`—Removes a watch from this inotify.
40
54
///
41
55
/// The watch descriptor provided should have previously been returned by
42
- /// [`inotify_add_watch `] and not previously have been removed.
56
+ /// [`inotify::add_watch `] and not previously have been removed.
43
57
#[ doc( alias = "inotify_rm_watch" ) ]
44
58
#[ inline]
45
- pub fn inotify_remove_watch ( inot : impl AsFd , wd : i32 ) -> io:: Result < ( ) > {
59
+ pub fn remove_watch ( inot : impl AsFd , wd : i32 ) -> io:: Result < ( ) > {
46
60
syscalls:: inotify_rm_watch ( inot. as_fd ( ) , wd)
47
61
}
48
62
@@ -52,14 +66,14 @@ pub fn inotify_remove_watch(inot: impl AsFd, wd: i32) -> io::Result<()> {
52
66
/// based on it.
53
67
///
54
68
/// [`RawDir`]: crate::fs::raw_dir::RawDir
55
- pub struct InotifyReader < ' buf , Fd : AsFd > {
69
+ pub struct Reader < ' buf , Fd : AsFd > {
56
70
fd : Fd ,
57
71
buf : & ' buf mut [ MaybeUninit < u8 > ] ,
58
72
initialized : usize ,
59
73
offset : usize ,
60
74
}
61
75
62
- impl < ' buf , Fd : AsFd > InotifyReader < ' buf , Fd > {
76
+ impl < ' buf , Fd : AsFd > Reader < ' buf , Fd > {
63
77
/// Create a new iterator from the given file descriptor and buffer.
64
78
pub fn new ( fd : Fd , buf : & ' buf mut [ MaybeUninit < u8 > ] ) -> Self {
65
79
Self {
@@ -114,7 +128,7 @@ impl<'a> InotifyEvent<'a> {
114
128
}
115
129
}
116
130
117
- impl < ' buf , Fd : AsFd > InotifyReader < ' buf , Fd > {
131
+ impl < ' buf , Fd : AsFd > Reader < ' buf , Fd > {
118
132
/// Read the next inotify event.
119
133
#[ allow( unsafe_code) ]
120
134
pub fn next ( & mut self ) -> io:: Result < InotifyEvent > {
0 commit comments