diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 1f0e0e00d225cfd0d9a1638ee574387cfe1bc1f2..ee8108de92bc0d84176374c39ef1ae36832b77d0 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 e192124b52ddccebdcbb2c3c1199e29d5c7dd14d..dd7cf1a3bd3c9608e28b02adb30663b503c42170 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 78154927a34357df3e10181bc9b1b9ef9ece542c..de73e19deed3cef95fbb9dcfbf480aa213bc258a 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 4f6747accd22e70c53003daa75a6d9fdc18fb4fb..d7b5c91b67b240d84dc73eae08c583f77e404890 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 684d1a93f7190facef0c05286d7e7c9b7e253a10..9c1ce770bde3d7eb2b8fa0b867c2fc769b6b5e7b 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 4ceb4ee9d55ba66a39b9659a96b61e8494b784b6..5fedee60b139c24b02cf986e5fd20edbed798833 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 ab8e0c3d30fddbfe201cd9f940edc53b5bbb6b78..8ffcc9994180c3ec0029e1e5aa6e80ad197e1482 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,