Skip to content

Define XATTR flags, and add XATTR functions for OSX #592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ fn main() {
cfg.header("mach/mach_time.h");
cfg.header("malloc/malloc.h");
cfg.header("util.h");
cfg.header("sys/xattr.h");
if target.starts_with("x86") {
cfg.header("crt_externs.h");
}
Expand Down
28 changes: 28 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,13 @@ pub const P_ALL: idtype_t = 0;
pub const P_PID: idtype_t = 1;
pub const P_PGID: idtype_t = 2;

pub const XATTR_NOFOLLOW: ::c_int = 0x0001;
pub const XATTR_CREATE: ::c_int = 0x0002;
pub const XATTR_REPLACE: ::c_int = 0x0004;
pub const XATTR_NOSECURITY: ::c_int = 0x0008;
pub const XATTR_NODEFAULT: ::c_int = 0x0010;
pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;

f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
Expand Down Expand Up @@ -1665,6 +1672,27 @@ extern {
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;

pub fn getxattr(path: *const ::c_char, name: *const ::c_char,
value: *mut ::c_void, size: ::size_t, position: u32,
flags: ::c_int) -> ::ssize_t;
pub fn fgetxattr(filedes: ::c_int, name: *const ::c_char,
value: *mut ::c_void, size: ::size_t, position: u32,
flags: ::c_int) -> ::ssize_t;
pub fn setxattr(path: *const ::c_char, name: *const ::c_char,
value: *const ::c_void, size: ::size_t, position: u32,
flags: ::c_int) -> ::c_int;
pub fn fsetxattr(filedes: ::c_int, name: *const ::c_char,
value: *const ::c_void, size: ::size_t, position: u32,
flags: ::c_int) -> ::c_int;
pub fn listxattr(path: *const ::c_char, list: *mut ::c_char,
size: ::size_t, flags: ::c_int) -> ::ssize_t;
pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char,
size: ::size_t, flags: ::c_int) -> ::ssize_t;
pub fn removexattr(path: *const ::c_char, name: *const ::c_char,
flags: ::c_int) -> ::c_int;
pub fn fremovexattr(filedes: ::c_int, name: *const ::c_char,
flags: ::c_int) -> ::c_int;

pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int;

#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Expand Down
3 changes: 3 additions & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;

pub const XATTR_CREATE: ::c_int = 0x1;
pub const XATTR_REPLACE: ::c_int = 0x2;

f! {
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.bits.iter_mut() {
Expand Down