From 0a9511eb21b6fa081174911cdcb4f271c37ca809 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 25 Mar 2019 19:15:53 +0100 Subject: [PATCH 1/4] Move inotify_event to the linux and android sub-modules --- libc-test/build.rs | 26 +++++++++++--------------- src/unix/notbsd/android/mod.rs | 7 +++++++ src/unix/notbsd/linux/mod.rs | 7 +++++++ src/unix/notbsd/mod.rs | 7 ------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d3d35614e7071..9ecfdc0d59516 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1065,22 +1065,18 @@ fn test_openbsd(target: &str) { } }); - cfg.field_name(move |struct_, field| { - match field { - "st_birthtime" if struct_.starts_with("stat") => { - "__st_birthtime".to_string() - } - "st_birthtime_nsec" if struct_.starts_with("stat") => { - "__st_birthtimensec".to_string() - } - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") - } - "sa_sigaction" if struct_ == "sigaction" => { - "sa_handler".to_string() - } - s => s.to_string(), + cfg.field_name(move |struct_, field| match field { + "st_birthtime" if struct_.starts_with("stat") => { + "__st_birthtime".to_string() + } + "st_birthtime_nsec" if struct_.starts_with("stat") => { + "__st_birthtimensec".to_string() + } + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.replace("e_nsec", ".tv_nsec") } + "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), + s => s.to_string(), }); cfg.skip_field_type(move |struct_, field| { diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 2f62a0930da2d..15d450d272222 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -249,6 +249,13 @@ s_no_extra_traits!{ pub ivlen: u32, pub iv: [::c_uchar; 0], } + + pub struct inotify_event { + pub wd: ::c_int, + pub mask: ::uint32_t, + pub cookie: ::uint32_t, + pub len: ::uint32_t + } } cfg_if! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index b9ecc9de9f439..cb9dc6ac7903a 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -524,6 +524,13 @@ s_no_extra_traits!{ pub ivlen: u32, pub iv: [::c_uchar; 0], } + + pub struct inotify_event { + pub wd: ::c_int, + pub mask: ::uint32_t, + pub cookie: ::uint32_t, + pub len: ::uint32_t + } } cfg_if! { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 13ddb292d3fb3..bc5c48fc0e4c9 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -208,13 +208,6 @@ s! { pub ar_op: u16, } - pub struct inotify_event { - pub wd: ::c_int, - pub mask: ::uint32_t, - pub cookie: ::uint32_t, - pub len: ::uint32_t - } - pub struct mmsghdr { pub msg_hdr: ::msghdr, pub msg_len: ::c_uint, From 917a20c4e39f5a2d97dbf9144da4e14dd0d50af4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 25 Mar 2019 19:20:48 +0100 Subject: [PATCH 2/4] Move IPV6_FLOW... constants to the linux and android sub-modules --- src/unix/notbsd/android/mod.rs | 5 +++++ src/unix/notbsd/linux/mod.rs | 5 +++++ src/unix/notbsd/mod.rs | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 15d450d272222..20e3fcd77136b 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -1363,6 +1363,11 @@ pub const IP_ORIGDSTADDR : ::c_int = 20; pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR; pub const IPV6_ORIGDSTADDR : ::c_int = 74; pub const IPV6_RECVORIGDSTADDR : ::c_int = IPV6_ORIGDSTADDR; +pub const IPV6_FLOWINFO: ::c_int = 11; +pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; +pub const IPV6_FLOWINFO_SEND: ::c_int = 33; +pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; +pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; pub const IUTF8: ::tcflag_t = 0x00004000; pub const CMSPAR: ::tcflag_t = 0o10000000000; pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index cb9dc6ac7903a..1f736d4a69d92 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -1416,6 +1416,11 @@ pub const IP_ORIGDSTADDR : ::c_int = 20; pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR; pub const IPV6_ORIGDSTADDR : ::c_int = 74; pub const IPV6_RECVORIGDSTADDR : ::c_int = IPV6_ORIGDSTADDR; +pub const IPV6_FLOWINFO: ::c_int = 11; +pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; +pub const IPV6_FLOWINFO_SEND: ::c_int = 33; +pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; +pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; pub const IUTF8: ::tcflag_t = 0x00004000; pub const CMSPAR: ::tcflag_t = 0o10000000000; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index bc5c48fc0e4c9..df1dc87ec09f0 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -800,7 +800,6 @@ pub const IP_RECVTOS: ::c_int = 13; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; pub const IP_TRANSPARENT: ::c_int = 19; -pub const IPV6_FLOWINFO: ::c_int = 11; pub const IPV6_UNICAST_HOPS: ::c_int = 16; pub const IPV6_MULTICAST_IF: ::c_int = 17; pub const IPV6_MULTICAST_HOPS: ::c_int = 18; @@ -808,16 +807,11 @@ pub const IPV6_MULTICAST_LOOP: ::c_int = 19; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; pub const IPV6_V6ONLY: ::c_int = 26; -pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; -pub const IPV6_FLOWINFO_SEND: ::c_int = 33; pub const IPV6_RECVPKTINFO: ::c_int = 49; pub const IPV6_PKTINFO: ::c_int = 50; pub const IPV6_RECVTCLASS: ::c_int = 66; pub const IPV6_TCLASS: ::c_int = 67; -pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; -pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; - pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; pub const TCP_CORK: ::c_int = 3; From c217e2f9be78e028a8bf1ec8a63131e7379594a2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 25 Mar 2019 20:15:13 +0100 Subject: [PATCH 3/4] Move inotify to the linux and android sub-modules --- src/unix/notbsd/android/mod.rs | 42 ++++++++++++++++++++++++++++++++ src/unix/notbsd/linux/mod.rs | 42 ++++++++++++++++++++++++++++++++ src/unix/notbsd/mod.rs | 44 ---------------------------------- 3 files changed, 84 insertions(+), 44 deletions(-) diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 20e3fcd77136b..05230166228e7 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -1802,6 +1802,43 @@ pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5; pub const ALG_OP_DECRYPT: ::c_int = 0; pub const ALG_OP_ENCRYPT: ::c_int = 1; +// uapi/linux/inotify.h +pub const IN_ACCESS: ::uint32_t = 0x0000_0001; +pub const IN_MODIFY: ::uint32_t = 0x0000_0002; +pub const IN_ATTRIB: ::uint32_t = 0x0000_0004; +pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010; +pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); +pub const IN_OPEN: ::uint32_t = 0x0000_0020; +pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040; +pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080; +pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO); +pub const IN_CREATE: ::uint32_t = 0x0000_0100; +pub const IN_DELETE: ::uint32_t = 0x0000_0200; +pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400; +pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800; +pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000; +pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000; +pub const IN_IGNORED: ::uint32_t = 0x0000_8000; +pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000; +pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000; +// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000; + +// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000; +// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000; +pub const IN_ISDIR: ::uint32_t = 0x4000_0000; +pub const IN_ONESHOT: ::uint32_t = 0x8000_0000; + +pub const IN_ALL_EVENTS: ::uint32_t = ( + IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | + IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | + IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | + IN_MOVE_SELF +); + +pub const IN_CLOEXEC: ::c_int = O_CLOEXEC; +pub const IN_NONBLOCK: ::c_int = O_NONBLOCK; + f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { @@ -2067,6 +2104,11 @@ extern { flags: ::c_int) -> ::c_int; pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, timeout: *const ::timespec) -> ::c_int; + pub fn inotify_init() -> ::c_int; + pub fn inotify_init1(flags: ::c_int) -> ::c_int; + pub fn inotify_add_watch(fd: ::c_int, + path: *const ::c_char, + mask: ::uint32_t) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 1f736d4a69d92..f9b5a6130d01b 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -1812,6 +1812,43 @@ pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5; pub const ALG_OP_DECRYPT: ::c_int = 0; pub const ALG_OP_ENCRYPT: ::c_int = 1; +// uapi/linux/inotify.h +pub const IN_ACCESS: ::uint32_t = 0x0000_0001; +pub const IN_MODIFY: ::uint32_t = 0x0000_0002; +pub const IN_ATTRIB: ::uint32_t = 0x0000_0004; +pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010; +pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); +pub const IN_OPEN: ::uint32_t = 0x0000_0020; +pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040; +pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080; +pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO); +pub const IN_CREATE: ::uint32_t = 0x0000_0100; +pub const IN_DELETE: ::uint32_t = 0x0000_0200; +pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400; +pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800; +pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000; +pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000; +pub const IN_IGNORED: ::uint32_t = 0x0000_8000; +pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000; +pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000; +// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000; + +// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000; +// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000; +pub const IN_ISDIR: ::uint32_t = 0x4000_0000; +pub const IN_ONESHOT: ::uint32_t = 0x8000_0000; + +pub const IN_ALL_EVENTS: ::uint32_t = ( + IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | + IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | + IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | + IN_MOVE_SELF +); + +pub const IN_CLOEXEC: ::c_int = O_CLOEXEC; +pub const IN_NONBLOCK: ::c_int = O_NONBLOCK; + f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { @@ -2397,6 +2434,11 @@ extern { stream: *mut ::FILE ) -> ::size_t; pub fn inotify_rm_watch(fd: ::c_int, wd: ::c_int) -> ::c_int; + pub fn inotify_init() -> ::c_int; + pub fn inotify_init1(flags: ::c_int) -> ::c_int; + pub fn inotify_add_watch(fd: ::c_int, + path: *const ::c_char, + mask: ::uint32_t) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index df1dc87ec09f0..2af3913097669 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1154,45 +1154,6 @@ pub const ARPHRD_IEEE802154: u16 = 804; pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; -// uapi/linux/inotify.h -pub const IN_ACCESS: ::uint32_t = 0x0000_0001; -pub const IN_MODIFY: ::uint32_t = 0x0000_0002; -pub const IN_ATTRIB: ::uint32_t = 0x0000_0004; -pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008; -pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010; -pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); -pub const IN_OPEN: ::uint32_t = 0x0000_0020; -pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040; -pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080; -pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO); -pub const IN_CREATE: ::uint32_t = 0x0000_0100; -pub const IN_DELETE: ::uint32_t = 0x0000_0200; -pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400; -pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800; - -pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000; -pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000; -pub const IN_IGNORED: ::uint32_t = 0x0000_8000; - -pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000; -pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000; -// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000; - -// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000; -// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000; -pub const IN_ISDIR: ::uint32_t = 0x4000_0000; -pub const IN_ONESHOT: ::uint32_t = 0x8000_0000; - -pub const IN_ALL_EVENTS: ::uint32_t = ( - IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | - IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | - IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | - IN_MOVE_SELF -); - -pub const IN_CLOEXEC: ::c_int = O_CLOEXEC; -pub const IN_NONBLOCK: ::c_int = O_NONBLOCK; - fn CMSG_ALIGN(len: usize) -> usize { len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) } @@ -1445,11 +1406,6 @@ extern { pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; pub fn uname(buf: *mut ::utsname) -> ::c_int; - pub fn inotify_init() -> ::c_int; - pub fn inotify_init1(flags: ::c_int) -> ::c_int; - pub fn inotify_add_watch(fd: ::c_int, - path: *const ::c_char, - mask: ::uint32_t) -> ::c_int; } cfg_if! { From 8abce839fc270e4bd25ba8879c76b766b93fd490 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 25 Mar 2019 21:34:54 +0100 Subject: [PATCH 4/4] Fix build --- src/unix/notbsd/android/mod.rs | 14 +++++++------- src/unix/notbsd/linux/mod.rs | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 05230166228e7..f7fe61a21d647 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -190,6 +190,13 @@ s! { pub ipi6_addr: ::in6_addr, pub ipi6_ifindex: ::c_int, } + + pub struct inotify_event { + pub wd: ::c_int, + pub mask: ::uint32_t, + pub cookie: ::uint32_t, + pub len: ::uint32_t + } } s_no_extra_traits!{ @@ -249,13 +256,6 @@ s_no_extra_traits!{ pub ivlen: u32, pub iv: [::c_uchar; 0], } - - pub struct inotify_event { - pub wd: ::c_int, - pub mask: ::uint32_t, - pub cookie: ::uint32_t, - pub len: ::uint32_t - } } cfg_if! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index f9b5a6130d01b..14c2463fa98d0 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -493,6 +493,13 @@ s! { pub updated: ::c_ulong, pub ha: [::c_uchar; ::MAX_ADDR_LEN], } + + pub struct inotify_event { + pub wd: ::c_int, + pub mask: ::uint32_t, + pub cookie: ::uint32_t, + pub len: ::uint32_t + } } s_no_extra_traits!{ @@ -524,13 +531,6 @@ s_no_extra_traits!{ pub ivlen: u32, pub iv: [::c_uchar; 0], } - - pub struct inotify_event { - pub wd: ::c_int, - pub mask: ::uint32_t, - pub cookie: ::uint32_t, - pub len: ::uint32_t - } } cfg_if! {