Skip to content

Commit

Permalink
Add more fcntl and seal constants for Android/Linux
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Susurrus committed Aug 10, 2017
1 parent 916b82d commit a3abe12
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ fn main() {
// asm/termios.h and ioctl.h (+ some other headers) because of redeclared types.
"CMSPAR" if mips && linux && !musl => true,

// These constants are tested in a separate test program generated below because there
// are header conflicts if we try to include the headers that define them here.
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true,
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => true,

_ => false,
}
});
Expand Down Expand Up @@ -635,4 +640,23 @@ fn main() {
} else {
cfg.generate("../src/lib.rs", "all.rs");
}

// On Linux or Android also generate another script for testing linux/fcntl declarations.
// These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h`
// fails on a lot of platforms.
if android || linux {
let mut cfg = ctest::TestGenerator::new();
cfg.header("linux/fcntl.h");
cfg.skip_type(|_| true)
.skip_struct(|_| true)
.skip_fn(|_| true);
cfg.skip_const(move |name| {
match name {
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false,
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false,
_ => true,
}
});
cfg.generate("../src/lib.rs", "linux_fcntl.rs");
}
}
8 changes: 8 additions & 0 deletions src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,17 @@ pub const F_SETFL: ::c_int = 4;
pub const F_SETLEASE: ::c_int = 1024;
pub const F_GETLEASE: ::c_int = 1025;
pub const F_NOTIFY: ::c_int = 1026;
pub const F_CANCELLK: ::c_int = 1029;
pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
pub const F_SETPIPE_SZ: ::c_int = 1031;
pub const F_GETPIPE_SZ: ::c_int = 1032;
pub const F_ADD_SEALS: ::c_int = 1033;
pub const F_GET_SEALS: ::c_int = 1034;

pub const F_SEAL_SEAL: ::c_int = 0x0001;
pub const F_SEAL_SHRINK: ::c_int = 0x0002;
pub const F_SEAL_GROW: ::c_int = 0x0004;
pub const F_SEAL_WRITE: ::c_int = 0x0008;

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

Expand Down

0 comments on commit a3abe12

Please sign in to comment.