Skip to content

Add chflags(2) and friends #1128

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 1 commit into from
Nov 20, 2018
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
16 changes: 16 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,20 @@ pub const SHMLBA: ::c_int = 4096;
pub const SHM_R: ::c_int = IPC_R;
pub const SHM_W: ::c_int = IPC_W;

// Flags for chflags(2)
pub const UF_SETTABLE: ::c_uint = 0x0000ffff;
pub const UF_NODUMP: ::c_uint = 0x00000001;
pub const UF_IMMUTABLE: ::c_uint = 0x00000002;
pub const UF_APPEND: ::c_uint = 0x00000004;
pub const UF_OPAQUE: ::c_uint = 0x00000008;
pub const UF_COMPRESSED: ::c_uint = 0x00000020;
pub const UF_TRACKED: ::c_uint = 0x00000040;
pub const SF_SETTABLE: ::c_uint = 0xffff0000;
pub const SF_ARCHIVED: ::c_uint = 0x00010000;
pub const SF_IMMUTABLE: ::c_uint = 0x00020000;
pub const SF_APPEND: ::c_uint = 0x00040000;
pub const UF_HIDDEN: ::c_uint = 0x00008000;

f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
Expand Down Expand Up @@ -2335,6 +2349,8 @@ extern {
pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
timeout: *const ::timespec) -> ::c_int;
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int;
pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int;
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,14 @@ pub const RTP_PRIO_NORMAL: ::c_ushort = 1;
pub const RTP_PRIO_IDLE: ::c_ushort = 2;
pub const RTP_PRIO_THREAD: ::c_ushort = 3;

// Flags for chflags(2)
pub const UF_NOHISTORY: ::c_ulong = 0x00000040;
pub const UF_CACHE: ::c_ulong = 0x00000080;
pub const UF_XLINK: ::c_ulong = 0x00000100;
pub const SF_NOHISTORY: ::c_ulong = 0x00400000;
pub const SF_CACHE: ::c_ulong = 0x00800000;
pub const SF_XLINK: ::c_ulong = 0x01000000;

extern {
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
Expand Down
10 changes: 10 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,16 @@ pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20;

// Flags for chflags(2)
pub const UF_SYSTEM: ::c_ulong = 0x00000080;
pub const UF_SPARSE: ::c_ulong = 0x00000100;
pub const UF_OFFLINE: ::c_ulong = 0x00000200;
pub const UF_REPARSE: ::c_ulong = 0x00000400;
pub const UF_ARCHIVE: ::c_ulong = 0x00000800;
pub const UF_READONLY: ::c_ulong = 0x00001000;
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;

extern {
pub fn __error() -> *mut ::c_int;

Expand Down
18 changes: 18 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,19 @@ pub const RTP_PRIO_MAX: ::c_ushort = 31;
pub const RTP_LOOKUP: ::c_int = 0;
pub const RTP_SET: ::c_int = 1;

// Flags for chflags(2)
pub const UF_SETTABLE: ::c_ulong = 0x0000ffff;
pub const UF_NODUMP: ::c_ulong = 0x00000001;
pub const UF_IMMUTABLE: ::c_ulong = 0x00000002;
pub const UF_APPEND: ::c_ulong = 0x00000004;
pub const UF_OPAQUE: ::c_ulong = 0x00000008;
pub const UF_NOUNLINK: ::c_ulong = 0x00000010;
pub const SF_SETTABLE: ::c_ulong = 0xffff0000;
pub const SF_ARCHIVED: ::c_ulong = 0x00010000;
pub const SF_IMMUTABLE: ::c_ulong = 0x00020000;
pub const SF_APPEND: ::c_ulong = 0x00040000;
pub const SF_NOUNLINK: ::c_ulong = 0x00100000;

f! {
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13
Expand Down Expand Up @@ -1032,9 +1045,13 @@ extern {
pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
timeout: *const ::timespec) -> ::c_int;
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_ulong,
atflag: ::c_int) -> ::c_int;
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
pub fn duplocale(base: ::locale_t) -> ::locale_t;
pub fn endutxent();
pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int;
pub fn getgrent_r(grp: *mut ::group,
Expand Down Expand Up @@ -1069,6 +1086,7 @@ extern {
eventlist: *mut ::kevent,
nevents: ::c_int,
timeout: *const ::timespec) -> ::c_int;
pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
Expand Down
16 changes: 16 additions & 0 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,17 @@ pub const TIOCM_DSR: ::c_int = 0o0400;
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
pub const TIOCM_RI: ::c_int = TIOCM_RNG;

// Flags for chflags(2)
pub const UF_SETTABLE: ::c_ulong = 0x0000ffff;
pub const UF_NODUMP: ::c_ulong = 0x00000001;
pub const UF_IMMUTABLE: ::c_ulong = 0x00000002;
pub const UF_APPEND: ::c_ulong = 0x00000004;
pub const UF_OPAQUE: ::c_ulong = 0x00000008;
pub const SF_SETTABLE: ::c_ulong = 0xffff0000;
pub const SF_ARCHIVED: ::c_ulong = 0x00010000;
pub const SF_IMMUTABLE: ::c_ulong = 0x00020000;
pub const SF_APPEND: ::c_ulong = 0x00040000;

f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
Expand All @@ -594,6 +605,11 @@ f! {
}
}

extern {
pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
}

#[link(name = "util")]
extern {
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
Expand Down
7 changes: 7 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,11 @@ pub const PT_GET_EVENT_MASK: ::c_int = 17;
pub const PT_GET_PROCESS_STATE: ::c_int = 18;
pub const PT_FIRSTMACH: ::c_int = 32;

// Flags for chflags(2)
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
pub const SF_LOG: ::c_ulong = 0x00400000;
pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;

// dirfd() is a macro on netbsd to access
// the first field of the struct where dirp points to:
// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
Expand Down Expand Up @@ -1027,6 +1032,8 @@ extern {
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;

pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;

pub fn extattr_delete_fd(fd: ::c_int,
attrnamespace: ::c_int,
attrname: *const ::c_char) -> ::c_int;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/netbsdlike/openbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ f! {
}

extern {
pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_ulong,
atflag: ::c_int) -> ::c_int;
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
pub fn getnameinfo(sa: *const ::sockaddr,
salen: ::socklen_t,
Expand Down