Skip to content

Commit c8c5d64

Browse files
committed
Auto merge of #592 - PlasmaPower:xattr-flags, r=alexcrichton
Define XATTR flags, and add XATTR functions for OSX As found in: http://elixir.free-electrons.com/linux/latest/source/include/uapi/linux/xattr.h https://opensource.apple.com/source/xnu/xnu-2050.7.9/bsd/sys/xattr.h
2 parents c1187f3 + 1a06678 commit c8c5d64

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ fn main() {
145145
cfg.header("mach/mach_time.h");
146146
cfg.header("malloc/malloc.h");
147147
cfg.header("util.h");
148+
cfg.header("sys/xattr.h");
148149
if target.starts_with("x86") {
149150
cfg.header("crt_externs.h");
150151
}

src/unix/bsd/apple/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,13 @@ pub const P_ALL: idtype_t = 0;
15161516
pub const P_PID: idtype_t = 1;
15171517
pub const P_PGID: idtype_t = 2;
15181518

1519+
pub const XATTR_NOFOLLOW: ::c_int = 0x0001;
1520+
pub const XATTR_CREATE: ::c_int = 0x0002;
1521+
pub const XATTR_REPLACE: ::c_int = 0x0004;
1522+
pub const XATTR_NOSECURITY: ::c_int = 0x0008;
1523+
pub const XATTR_NODEFAULT: ::c_int = 0x0010;
1524+
pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;
1525+
15191526
f! {
15201527
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
15211528
status >> 8
@@ -1665,6 +1672,27 @@ extern {
16651672
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
16661673
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
16671674

1675+
pub fn getxattr(path: *const ::c_char, name: *const ::c_char,
1676+
value: *mut ::c_void, size: ::size_t, position: u32,
1677+
flags: ::c_int) -> ::ssize_t;
1678+
pub fn fgetxattr(filedes: ::c_int, name: *const ::c_char,
1679+
value: *mut ::c_void, size: ::size_t, position: u32,
1680+
flags: ::c_int) -> ::ssize_t;
1681+
pub fn setxattr(path: *const ::c_char, name: *const ::c_char,
1682+
value: *const ::c_void, size: ::size_t, position: u32,
1683+
flags: ::c_int) -> ::c_int;
1684+
pub fn fsetxattr(filedes: ::c_int, name: *const ::c_char,
1685+
value: *const ::c_void, size: ::size_t, position: u32,
1686+
flags: ::c_int) -> ::c_int;
1687+
pub fn listxattr(path: *const ::c_char, list: *mut ::c_char,
1688+
size: ::size_t, flags: ::c_int) -> ::ssize_t;
1689+
pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char,
1690+
size: ::size_t, flags: ::c_int) -> ::ssize_t;
1691+
pub fn removexattr(path: *const ::c_char, name: *const ::c_char,
1692+
flags: ::c_int) -> ::c_int;
1693+
pub fn fremovexattr(filedes: ::c_int, name: *const ::c_char,
1694+
flags: ::c_int) -> ::c_int;
1695+
16681696
pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int;
16691697

16701698
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),

src/unix/notbsd/linux/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
697697
pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
698698
pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
699699

700+
pub const XATTR_CREATE: ::c_int = 0x1;
701+
pub const XATTR_REPLACE: ::c_int = 0x2;
702+
700703
f! {
701704
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
702705
for slot in cpuset.bits.iter_mut() {

0 commit comments

Comments
 (0)