Skip to content

Commit 501ca54

Browse files
committed
Auto merge of #1256 - vdagonneau:master, r=gnzlbg
Moved inotify declarations up so that it works on android too. Following my previous pull request to include inotify bindings, I would like to move the code so that it benefits android too.
2 parents 315e600 + d25a054 commit 501ca54

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

src/unix/notbsd/android/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,7 @@ extern {
19521952
f: extern fn(*mut ::c_void) -> *mut ::c_void,
19531953
value: *mut ::c_void) -> ::c_int;
19541954
pub fn __errno() -> *mut ::c_int;
1955+
pub fn inotify_rm_watch(fd: ::c_int, wd: ::uint32_t) -> ::c_int;
19551956
pub fn sendmmsg(sockfd: ::c_int, msgvec: *const ::mmsghdr, vlen: ::c_uint,
19561957
flags: ::c_int) -> ::c_int;
19571958
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,

src/unix/notbsd/linux/mod.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,6 @@ s! {
493493
pub updated: ::c_ulong,
494494
pub ha: [::c_uchar; ::MAX_ADDR_LEN],
495495
}
496-
497-
pub struct inotify_event {
498-
pub wd: ::c_int,
499-
pub mask: ::uint32_t,
500-
pub cookie: ::uint32_t,
501-
pub len: ::uint32_t
502-
}
503496
}
504497

505498
s_no_extra_traits!{
@@ -1690,45 +1683,6 @@ pub const ARPD_LOOKUP: ::c_ushort = 0x02;
16901683
pub const ARPD_FLUSH: ::c_ushort = 0x03;
16911684
pub const ATF_MAGIC: ::c_int = 0x80;
16921685

1693-
// uapi/linux/inotify.h
1694-
pub const IN_ACCESS: ::uint32_t = 0x0000_0001;
1695-
pub const IN_MODIFY: ::uint32_t = 0x0000_0002;
1696-
pub const IN_ATTRIB: ::uint32_t = 0x0000_0004;
1697-
pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008;
1698-
pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010;
1699-
pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
1700-
pub const IN_OPEN: ::uint32_t = 0x0000_0020;
1701-
pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040;
1702-
pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080;
1703-
pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
1704-
pub const IN_CREATE: ::uint32_t = 0x0000_0100;
1705-
pub const IN_DELETE: ::uint32_t = 0x0000_0200;
1706-
pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400;
1707-
pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800;
1708-
1709-
pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000;
1710-
pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000;
1711-
pub const IN_IGNORED: ::uint32_t = 0x0000_8000;
1712-
1713-
pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000;
1714-
pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000;
1715-
// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000;
1716-
1717-
// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000;
1718-
// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000;
1719-
pub const IN_ISDIR: ::uint32_t = 0x4000_0000;
1720-
pub const IN_ONESHOT: ::uint32_t = 0x8000_0000;
1721-
1722-
pub const IN_ALL_EVENTS: ::uint32_t = (
1723-
IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
1724-
IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
1725-
IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
1726-
IN_MOVE_SELF
1727-
);
1728-
1729-
pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
1730-
pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
1731-
17321686
#[cfg(not(target_arch = "sparc64"))]
17331687
pub const SO_TIMESTAMPING: ::c_int = 37;
17341688
#[cfg(target_arch = "sparc64")]
@@ -2332,11 +2286,6 @@ extern {
23322286
nobj: ::size_t,
23332287
stream: *mut ::FILE
23342288
) -> ::size_t;
2335-
pub fn inotify_init() -> ::c_int;
2336-
pub fn inotify_init1(flags: ::c_int) -> ::c_int;
2337-
pub fn inotify_add_watch(fd: ::c_int,
2338-
path: *const ::c_char,
2339-
mask: ::uint32_t) -> ::c_int;
23402289
pub fn inotify_rm_watch(fd: ::c_int, wd: ::c_int) -> ::c_int;
23412290
}
23422291

src/unix/notbsd/mod.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ s! {
208208
pub ar_op: u16,
209209
}
210210

211+
pub struct inotify_event {
212+
pub wd: ::c_int,
213+
pub mask: ::uint32_t,
214+
pub cookie: ::uint32_t,
215+
pub len: ::uint32_t
216+
}
217+
211218
pub struct mmsghdr {
212219
pub msg_hdr: ::msghdr,
213220
pub msg_len: ::c_uint,
@@ -1131,6 +1138,45 @@ pub const ARPHRD_IEEE802154: u16 = 804;
11311138
pub const ARPHRD_VOID: u16 = 0xFFFF;
11321139
pub const ARPHRD_NONE: u16 = 0xFFFE;
11331140

1141+
// uapi/linux/inotify.h
1142+
pub const IN_ACCESS: ::uint32_t = 0x0000_0001;
1143+
pub const IN_MODIFY: ::uint32_t = 0x0000_0002;
1144+
pub const IN_ATTRIB: ::uint32_t = 0x0000_0004;
1145+
pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008;
1146+
pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010;
1147+
pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
1148+
pub const IN_OPEN: ::uint32_t = 0x0000_0020;
1149+
pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040;
1150+
pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080;
1151+
pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
1152+
pub const IN_CREATE: ::uint32_t = 0x0000_0100;
1153+
pub const IN_DELETE: ::uint32_t = 0x0000_0200;
1154+
pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400;
1155+
pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800;
1156+
1157+
pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000;
1158+
pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000;
1159+
pub const IN_IGNORED: ::uint32_t = 0x0000_8000;
1160+
1161+
pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000;
1162+
pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000;
1163+
// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000;
1164+
1165+
// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000;
1166+
// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000;
1167+
pub const IN_ISDIR: ::uint32_t = 0x4000_0000;
1168+
pub const IN_ONESHOT: ::uint32_t = 0x8000_0000;
1169+
1170+
pub const IN_ALL_EVENTS: ::uint32_t = (
1171+
IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
1172+
IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
1173+
IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
1174+
IN_MOVE_SELF
1175+
);
1176+
1177+
pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
1178+
pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
1179+
11341180
fn CMSG_ALIGN(len: usize) -> usize {
11351181
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
11361182
}
@@ -1377,6 +1423,11 @@ extern {
13771423
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
13781424
-> ::ssize_t;
13791425
pub fn uname(buf: *mut ::utsname) -> ::c_int;
1426+
pub fn inotify_init() -> ::c_int;
1427+
pub fn inotify_init1(flags: ::c_int) -> ::c_int;
1428+
pub fn inotify_add_watch(fd: ::c_int,
1429+
path: *const ::c_char,
1430+
mask: ::uint32_t) -> ::c_int;
13801431
}
13811432

13821433
cfg_if! {

0 commit comments

Comments
 (0)