Skip to content

Commit 01752b3

Browse files
committed
Added inotify bindings.
1 parent 42cd3ba commit 01752b3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/unix/notbsd/linux/mod.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,13 @@ s! {
655655
pub updated: ::c_ulong,
656656
pub ha: [::c_uchar; ::MAX_ADDR_LEN],
657657
}
658+
659+
pub struct inotify_event {
660+
pub wd: ::c_int,
661+
pub mask: ::uint32_t,
662+
pub cookie: ::uint32_t,
663+
pub len: ::uint32_t
664+
}
658665
}
659666

660667
pub const ABDAY_1: ::nl_item = 0x20000;
@@ -1677,6 +1684,46 @@ pub const ARPD_LOOKUP: ::c_ushort = 0x02;
16771684
pub const ARPD_FLUSH: ::c_ushort = 0x03;
16781685
pub const ATF_MAGIC: ::c_int = 0x80;
16791686

1687+
// uapi/linux/inotify.h
1688+
pub const IN_ACCESS: ::uint32_t = 0x0000_0001;
1689+
pub const IN_MODIFY: ::uint32_t = 0x0000_0002;
1690+
pub const IN_ATTRIB: ::uint32_t = 0x0000_0004;
1691+
pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008;
1692+
pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010;
1693+
pub const IN_OPEN: ::uint32_t = 0x0000_0020;
1694+
pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040;
1695+
pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080;
1696+
pub const IN_CREATE: ::uint32_t = 0x0000_0100;
1697+
pub const IN_DELETE: ::uint32_t = 0x0000_0200;
1698+
pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400;
1699+
pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800;
1700+
1701+
pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000;
1702+
pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000;
1703+
pub const IN_IGNORED: ::uint32_t = 0x0000_8000;
1704+
1705+
pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
1706+
pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
1707+
1708+
pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000;
1709+
pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000;
1710+
pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000;
1711+
1712+
pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000;
1713+
pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000;
1714+
pub const IN_ISDIR: ::uint32_t = 0x4000_0000;
1715+
pub const IN_ONESHOT: ::uint32_t = 0x8000_0000;
1716+
1717+
pub const IN_ALL_EVENTS: ::uint32_t = (
1718+
IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
1719+
IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
1720+
IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
1721+
IN_MOVE_SELF
1722+
);
1723+
1724+
pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
1725+
pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
1726+
16801727
#[cfg(not(target_arch = "sparc64"))]
16811728
pub const SO_TIMESTAMPING: ::c_int = 37;
16821729
#[cfg(target_arch = "sparc64")]
@@ -2259,6 +2306,12 @@ extern {
22592306
nobj: ::size_t,
22602307
stream: *mut ::FILE
22612308
) -> ::size_t;
2309+
pub fn inotify_init() -> ::c_int;
2310+
pub fn inotify_init1(flags: ::c_int) -> ::c_int;
2311+
pub fn inotify_add_watch(fd: ::c_int,
2312+
path: *const ::c_char,
2313+
mask: ::uint32_t) -> ::c_int;
2314+
pub fn inotify_rm_watch(fd: ::c_int, wd: ::c_int) -> ::c_int;
22622315
}
22632316

22642317
cfg_if! {

0 commit comments

Comments
 (0)