From 3bc400d7c7ec49afbbf0b51a882af044b4109dfc Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 19 Nov 2018 17:58:54 -0700 Subject: Add chflags(2) and friends --- src/unix/bsd/apple/mod.rs | 16 ++++++++++++++++ src/unix/bsd/freebsdlike/dragonfly/mod.rs | 8 ++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 10 ++++++++++ src/unix/bsd/freebsdlike/mod.rs | 18 ++++++++++++++++++ src/unix/bsd/netbsdlike/mod.rs | 16 ++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 7 +++++++ src/unix/bsd/netbsdlike/openbsdlike/mod.rs | 2 ++ 7 files changed, 77 insertions(+) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 1f0e0e00d2..ee8108de92 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -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 @@ -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, diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index e192124b52..dd7cf1a3bd 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -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; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 78154927a3..de73e19dee 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -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; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4f6747accd..d7b5c91b67 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -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 @@ -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, @@ -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; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 684d1a93f7..9c1ce770bd 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -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 @@ -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, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 4ceb4ee9d5..5fedee60b1 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -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 @@ -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; diff --git a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index ab8e0c3d30..8ffcc99941 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@ -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, -- cgit v1.2.1