Skip to content

Commit 4ca8a59

Browse files
committed
Add chflags(2) and friends
1 parent 4e5ef22 commit 4ca8a59

File tree

7 files changed

+53
-0
lines changed

7 files changed

+53
-0
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,11 @@ pub const SHMLBA: ::c_int = 4096;
23022302
pub const SHM_R: ::c_int = IPC_R;
23032303
pub const SHM_W: ::c_int = IPC_W;
23042304

2305+
// Flags for chflags(2)
2306+
pub const UF_COMPRESSED: ::c_ulong = 0x00000020;
2307+
pub const UF_TRACKED: ::c_ulong = 0x00000040;
2308+
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
2309+
23052310
f! {
23062311
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
23072312
status >> 8

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,14 @@ pub const RTP_PRIO_NORMAL: ::c_ushort = 1;
767767
pub const RTP_PRIO_IDLE: ::c_ushort = 2;
768768
pub const RTP_PRIO_THREAD: ::c_ushort = 3;
769769

770+
// Flags for chflags(2)
771+
pub const UF_NOHISTORY ::c_ulong = 0x00000040;
772+
pub const UF_CACHE: ::c_ulong = 0x00000080;
773+
pub const UF_XLINK: ::c_ulong = 0x00000100;
774+
pub const SF_NOHISTORY ::c_ulong = 0x00400000;
775+
pub const SF_CACHE: ::c_ulong = 0x00800000;
776+
pub const SF_XLINK: ::c_ulong = 0x01000000;
777+
770778
extern {
771779
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
772780
-> ::c_int;

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,16 @@ pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08;
928928
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10;
929929
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20;
930930

931+
// Flags for chflags(2)
932+
pub const UF_SYSTEM: ::c_ulong = 0x00000080;
933+
pub const UF_SPARSE: ::c_ulong = 0x00000100;
934+
pub const UF_OFFLINE: ::c_ulong = 0x00000200;
935+
pub const UF_REPARSE: ::c_ulong = 0x00000400;
936+
pub const UF_ARCHIVE: ::c_ulong = 0x00000800;
937+
pub const UF_READONLY: ::c_ulong = 0x00001000;
938+
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
939+
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
940+
931941
extern {
932942
pub fn __error() -> *mut ::c_int;
933943

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,10 @@ pub const RTP_PRIO_MAX: ::c_ushort = 31;
10031003
pub const RTP_LOOKUP: ::c_int = 0;
10041004
pub const RTP_SET: ::c_int = 1;
10051005

1006+
// Flags for chflags(2)
1007+
pub const UF_NOUNLINK: ::c_ulong = 0x00000010;
1008+
pub const SF_NOUNLINK: ::c_ulong = 0x00100000;
1009+
10061010
f! {
10071011
pub fn WIFCONTINUED(status: ::c_int) -> bool {
10081012
status == 0x13
@@ -1032,6 +1036,8 @@ extern {
10321036
pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
10331037
timeout: *const ::timespec) -> ::c_int;
10341038
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
1039+
pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_ulong,
1040+
atflag: ::c_int) -> ::c_int;
10351041
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
10361042
pub fn duplocale(base: ::locale_t) -> ::locale_t;
10371043
pub fn endutxent();
@@ -1069,6 +1075,7 @@ extern {
10691075
eventlist: *mut ::kevent,
10701076
nevents: ::c_int,
10711077
timeout: *const ::timespec) -> ::c_int;
1078+
pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
10721079
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
10731080
nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
10741081
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;

src/unix/bsd/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ pub const POLLWRNORM: ::c_short = 0x004;
331331
pub const POLLRDBAND: ::c_short = 0x080;
332332
pub const POLLWRBAND: ::c_short = 0x100;
333333

334+
// Flags for chflags(2)
335+
pub const UF_SETTABLE: ::c_ulong = 0x0000ffff;
336+
pub const UF_NODUMP: ::c_ulong = 0x00000001;
337+
pub const UF_IMMUTABLE: ::c_ulong = 0x00000002;
338+
pub const UF_APPEND: ::c_ulong = 0x00000004;
339+
pub const UF_OPAQUE: ::c_ulong = 0x00000008;
340+
pub const SF_SETTABLE: ::c_ulong = 0xffff0000;
341+
pub const SF_ARCHIVED: ::c_ulong = 0x00010000;
342+
pub const SF_IMMUTABLE: ::c_ulong = 0x00020000;
343+
pub const SF_APPEND: ::c_ulong = 0x00040000;
344+
334345
f! {
335346
pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
336347
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
@@ -417,6 +428,8 @@ f! {
417428
}
418429

419430
extern {
431+
pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
432+
pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
420433
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
421434
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
422435
pub fn setgroups(ngroups: ::c_int,

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,11 @@ pub const PT_GET_EVENT_MASK: ::c_int = 17;
992992
pub const PT_GET_PROCESS_STATE: ::c_int = 18;
993993
pub const PT_FIRSTMACH: ::c_int = 32;
994994

995+
// Flags for chflags(2)
996+
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
997+
pub const SF_LOG: ::c_ulong = 0x00400000;
998+
pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;
999+
9951000
// dirfd() is a macro on netbsd to access
9961001
// the first field of the struct where dirp points to:
9971002
// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
@@ -1027,6 +1032,9 @@ extern {
10271032
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
10281033
nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
10291034

1035+
1036+
pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
1037+
10301038
pub fn extattr_delete_fd(fd: ::c_int,
10311039
attrnamespace: ::c_int,
10321040
attrname: *const ::c_char) -> ::c_int;

src/unix/bsd/netbsdlike/openbsdlike/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,8 @@ f! {
707707
}
708708

709709
extern {
710+
pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_ulong,
711+
atflag: ::c_int) -> ::c_int;
710712
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
711713
pub fn getnameinfo(sa: *const ::sockaddr,
712714
salen: ::socklen_t,

0 commit comments

Comments
 (0)