Skip to content

Commit 5c55ce0

Browse files
committed
linux: Add missing Linux-specific fcntls
Also move F_DUPFD_CLOEXEC up a level as it is available on Android. This commit leaves file sealing related fcntls and bitflag constants out of "plain" Linux, as they are defined in `linux/fcntl.h` rather than `fcntl.h`. They can be included once an approach for verification has been figured out. Android and musl both include them in `fcntl.h` however. See #235 for more detail.
1 parent fa161ae commit 5c55ce0

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/unix/notbsd/android/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,15 @@ pub const RTLD_GLOBAL: ::c_int = 0x2;
544544
pub const RTLD_NOLOAD: ::c_int = 0x4;
545545
pub const RTLD_NOW: ::c_int = 0;
546546

547+
// TODO(#235): Move these to unix::notbsd once verification is figured out.
548+
pub const F_ADD_SEALS: ::c_int = 1033;
549+
pub const F_GET_SEALS: ::c_int = 1034;
550+
551+
pub const F_SEAL_SEAL: ::c_int = 0x0001;
552+
pub const F_SEAL_SHRINK: ::c_int = 0x0002;
553+
pub const F_SEAL_GROW: ::c_int = 0x0004;
554+
pub const F_SEAL_WRITE: ::c_int = 0x0008;
555+
547556
f! {
548557
pub fn sigemptyset(set: *mut sigset_t) -> ::c_int {
549558
*set = 0;

src/unix/notbsd/linux/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ pub const RTLD_NOW: ::c_int = 0x2;
315315

316316
pub const TCP_MD5SIG: ::c_int = 14;
317317

318-
pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
319-
320318
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
321319
__align: [],
322320
size: [0; __SIZEOF_PTHREAD_MUTEX_T],

src/unix/notbsd/linux/musl/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ pub const TIOCINQ: ::c_ulong = ::FIONREAD;
148148
pub const RTLD_GLOBAL: ::c_int = 0x100;
149149
pub const RTLD_NOLOAD: ::c_int = 0x4;
150150

151+
// TODO(#235): Move these to unix::notbsd once verification is figured out.
152+
pub const F_ADD_SEALS: ::c_int = 1033;
153+
pub const F_GET_SEALS: ::c_int = 1034;
154+
155+
pub const F_SEAL_SEAL: ::c_int = 0x0001;
156+
pub const F_SEAL_SHRINK: ::c_int = 0x0002;
157+
pub const F_SEAL_GROW: ::c_int = 0x0004;
158+
pub const F_SEAL_WRITE: ::c_int = 0x0008;
159+
151160
extern {
152161
pub fn getnameinfo(sa: *const ::sockaddr,
153162
salen: ::socklen_t,

src/unix/notbsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ pub const F_SETFD: ::c_int = 2;
161161
pub const F_GETFL: ::c_int = 3;
162162
pub const F_SETFL: ::c_int = 4;
163163

164+
// Linux-specific fcntls
165+
pub const F_SETLEASE: ::c_int = 1024;
166+
pub const F_GETLEASE: ::c_int = 1025;
167+
pub const F_NOTIFY: ::c_int = 1026;
168+
pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
169+
pub const F_SETPIPE_SZ: ::c_int = 1031;
170+
pub const F_GETPIPE_SZ: ::c_int = 1032;
171+
172+
// TODO(#235): Include file sealing fcntls once we have a way to verify them.
173+
164174
pub const SIGTRAP: ::c_int = 5;
165175

166176
pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;

0 commit comments

Comments
 (0)