diff options
author | bors <bors@rust-lang.org> | 2018-10-30 21:40:23 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2018-10-30 21:40:23 +0000 |
commit | 8dde98ed58437de6df430f75f33822ba82cbd0ec (patch) | |
tree | 0d9a488c4b0174fd84ae884e6c90d05d7197f847 | |
parent | 04a13d1b979e12a999fcef99437eabc0e6c806c6 (diff) | |
parent | 74d5a9833fcf21d8b356ea1de64f62708e7111d6 (diff) | |
download | rust-libc-8dde98ed58437de6df430f75f33822ba82cbd0ec.tar.gz |
Auto merge of #1114 - asomers:extattr, r=alexcrichton
Add extattr(2) and extattr(3) definitions for FreeBSD and NetBSD
DragonflyBSD does define 3 of these 14 functions. But I elected not to
add it to the PR because I can't find any evidence that these syscalls
are used on Dragonfly, even in the base system. And by themselves,
those three are insufficient for the xattr crate.
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | libc-test/build.rs | 2 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd/mod.rs | 64 | ||||
-rw-r--r-- | src/unix/bsd/netbsdlike/netbsd/mod.rs | 47 |
4 files changed, 113 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index 197d8c663b..d5982e6e4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,8 +53,6 @@ matrix: - env: TARGET=arm-unknown-linux-musleabihf - env: TARGET=aarch64-unknown-linux-gnu - env: TARGET=aarch64-unknown-linux-musl - # FIXME(#856) - rust: 1.22.1 - env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu - env: TARGET=powerpc64le-unknown-linux-gnu diff --git a/libc-test/build.rs b/libc-test/build.rs index db6588b802..be148b83fb 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -304,6 +304,7 @@ fn main() { cfg.header("pthread_np.h"); cfg.header("sched.h"); cfg.header("ufs/ufs/quota.h"); + cfg.header("sys/extattr.h"); cfg.header("sys/jail.h"); cfg.header("sys/ipc.h"); cfg.header("sys/msg.h"); @@ -317,6 +318,7 @@ fn main() { cfg.header("mqueue.h"); cfg.header("ufs/ufs/quota.h"); cfg.header("ufs/ufs/quota1.h"); + cfg.header("sys/extattr.h"); cfg.header("sys/ioctl_compat.h"); // DCCP support diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 653cfa5c66..78154927a3 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -186,6 +186,10 @@ s! { pub const SIGEV_THREAD_ID: ::c_int = 4; +pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; + pub const RAND_MAX: ::c_int = 0x7fff_fffd; pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; @@ -934,6 +938,58 @@ extern { pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; + pub fn extattr_delete_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_get_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_list_fd(fd: ::c_int, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_list_file(path: *const ::c_char, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_list_link(path: *const ::c_char, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn jail(jail: *mut ::jail) -> ::c_int; pub fn jail_attach(jid: ::c_int) -> ::c_int; pub fn jail_remove(jid: ::c_int) -> ::c_int; @@ -1060,6 +1116,14 @@ extern { pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; } +#[link(name = "util")] +extern { + pub fn extattr_namespace_to_string(attrnamespace: ::c_int, + string: *mut *mut ::c_char) -> ::c_int; + pub fn extattr_string_to_namespace(string: *const ::c_char, + attrnamespace: *mut ::c_int) -> ::c_int; +} + cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 3f735278c0..915505d14b 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -334,6 +334,9 @@ pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200; pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; pub const AT_REMOVEDIR: ::c_int = 0x800; +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; + pub const LC_COLLATE_MASK: ::c_int = (1 << ::LC_COLLATE); pub const LC_CTYPE_MASK: ::c_int = (1 << ::LC_CTYPE); pub const LC_MONETARY_MASK: ::c_int = (1 << ::LC_MONETARY); @@ -1013,6 +1016,46 @@ extern { pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; + pub fn extattr_delete_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_get_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + #[link_name = "__lutimes50"] pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn getnameinfo(sa: *const ::sockaddr, @@ -1112,6 +1155,10 @@ extern { #[link(name = "util")] extern { + pub fn extattr_namespace_to_string(attrnamespace: ::c_int, + string: *mut *mut ::c_char) -> ::c_int; + pub fn extattr_string_to_namespace(string: *const ::c_char, + attrnamespace: *mut ::c_int) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] pub fn getpwent_r(pwd: *mut ::passwd, buf: *mut ::c_char, |