Skip to content

Commit a3abe12

Browse files
committed
Add more fcntl and seal constants for Android/Linux
A new binary is generated for testing this, but it's not yet been connected to CI. It can be run locally, however, via `cargo run --bin linux_fcntl` within the libc-test folder.
1 parent 916b82d commit a3abe12

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

libc-test/build.rs

+24
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ fn main() {
459459
// asm/termios.h and ioctl.h (+ some other headers) because of redeclared types.
460460
"CMSPAR" if mips && linux && !musl => true,
461461

462+
// These constants are tested in a separate test program generated below because there
463+
// are header conflicts if we try to include the headers that define them here.
464+
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true,
465+
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => true,
466+
462467
_ => false,
463468
}
464469
});
@@ -635,4 +640,23 @@ fn main() {
635640
} else {
636641
cfg.generate("../src/lib.rs", "all.rs");
637642
}
643+
644+
// On Linux or Android also generate another script for testing linux/fcntl declarations.
645+
// These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h`
646+
// fails on a lot of platforms.
647+
if android || linux {
648+
let mut cfg = ctest::TestGenerator::new();
649+
cfg.header("linux/fcntl.h");
650+
cfg.skip_type(|_| true)
651+
.skip_struct(|_| true)
652+
.skip_fn(|_| true);
653+
cfg.skip_const(move |name| {
654+
match name {
655+
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false,
656+
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false,
657+
_ => true,
658+
}
659+
});
660+
cfg.generate("../src/lib.rs", "linux_fcntl.rs");
661+
}
638662
}

src/unix/notbsd/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,17 @@ pub const F_SETFL: ::c_int = 4;
212212
pub const F_SETLEASE: ::c_int = 1024;
213213
pub const F_GETLEASE: ::c_int = 1025;
214214
pub const F_NOTIFY: ::c_int = 1026;
215+
pub const F_CANCELLK: ::c_int = 1029;
215216
pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
216217
pub const F_SETPIPE_SZ: ::c_int = 1031;
217218
pub const F_GETPIPE_SZ: ::c_int = 1032;
219+
pub const F_ADD_SEALS: ::c_int = 1033;
220+
pub const F_GET_SEALS: ::c_int = 1034;
221+
222+
pub const F_SEAL_SEAL: ::c_int = 0x0001;
223+
pub const F_SEAL_SHRINK: ::c_int = 0x0002;
224+
pub const F_SEAL_GROW: ::c_int = 0x0004;
225+
pub const F_SEAL_WRITE: ::c_int = 0x0008;
218226

219227
// TODO(#235): Include file sealing fcntls once we have a way to verify them.
220228

0 commit comments

Comments
 (0)