summaryrefslogtreecommitdiff
path: root/src/fcntl.rs
diff options
context:
space:
mode:
authorDavid Henningsson <diwic@ubuntu.com>2015-08-23 07:41:33 +0200
committerCarl Lerche <me@carllerche.com>2015-08-25 15:56:04 -0700
commit4f69bc358d7ab644ae766fde8bb5bdfd631f789b (patch)
treebad01ac6570ac623577f6a940dfe298e7c27fb27 /src/fcntl.rs
parent1020c6417a47e5abcc2ddce8f0c0c014f52ad60d (diff)
downloadnix-4f69bc358d7ab644ae766fde8bb5bdfd631f789b.zip
Add memfd functionality
Diffstat (limited to 'src/fcntl.rs')
-rw-r--r--src/fcntl.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/fcntl.rs b/src/fcntl.rs
index 1bc11c74..6a0fdf96 100644
--- a/src/fcntl.rs
+++ b/src/fcntl.rs
@@ -40,6 +40,14 @@ mod ffi {
pub const F_SETLK: c_int = 6;
pub const F_SETLKW: c_int = 7;
pub const F_GETLK: c_int = 5;
+
+ pub const F_ADD_SEALS: c_int = 1033;
+ pub const F_GET_SEALS: c_int = 1034;
+
+ pub const F_SEAL_SEAL: c_int = 1;
+ pub const F_SEAL_SHRINK: c_int = 2;
+ pub const F_SEAL_GROW: c_int = 4;
+ pub const F_SEAL_WRITE: c_int = 8;
}
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
@@ -98,7 +106,11 @@ pub enum FcntlArg<'a> {
#[cfg(any(target_os = "linux", target_os = "android"))]
F_OFD_SETLKW(&'a flock),
#[cfg(any(target_os = "linux", target_os = "android"))]
- F_OFD_GETLK(&'a mut flock)
+ F_OFD_GETLK(&'a mut flock),
+ #[cfg(target_os = "linux")]
+ F_ADD_SEALS(SealFlag),
+ #[cfg(target_os = "linux")]
+ F_GET_SEALS,
// TODO: Rest of flags
}
@@ -118,6 +130,10 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
F_SETLK(flock) => ffi::fcntl(fd, ffi::F_SETLK, flock),
F_SETLKW(flock) => ffi::fcntl(fd, ffi::F_SETLKW, flock),
F_GETLK(flock) => ffi::fcntl(fd, ffi::F_GETLK, flock),
+ #[cfg(target_os = "linux")]
+ F_ADD_SEALS(flag) => ffi::fcntl(fd, ffi::F_ADD_SEALS, flag.bits()),
+ #[cfg(target_os = "linux")]
+ F_GET_SEALS => ffi::fcntl(fd, ffi::F_GET_SEALS),
#[cfg(any(target_os = "linux", target_os = "android"))]
_ => unimplemented!()
}
@@ -195,6 +211,16 @@ mod consts {
const FD_CLOEXEC = 1
}
);
+
+ bitflags!(
+ flags SealFlag: c_int {
+ const F_SEAL_SEAL = 1,
+ const F_SEAL_SHRINK = 2,
+ const F_SEAL_GROW = 4,
+ const F_SEAL_WRITE = 8,
+ }
+ );
+
}
#[cfg(any(target_os = "macos", target_os = "ios"))]