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.
This commit is contained in:
bors 2018-10-30 21:40:23 +00:00
commit 8dde98ed58
4 changed files with 113 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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,