diff --git a/Cargo.toml b/Cargo.toml index f0981fb304..a761213f2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redox_syscall" -version = "0.6.0" +version = "0.7.0" description = "A Rust library to access raw Redox system calls" license = "MIT" authors = ["Jeremy Soller "] diff --git a/src/call.rs b/src/call.rs index 27b0bd87b4..3fbc98673c 100644 --- a/src/call.rs +++ b/src/call.rs @@ -174,12 +174,6 @@ pub fn nanosleep(req: &TimeSpec, rem: &mut TimeSpec) -> Result { } } -/// Open a file -pub fn open>(path: T, flags: usize) -> Result { - let path = path.as_ref(); - unsafe { syscall3(SYS_OPEN, path.as_ptr() as usize, path.len(), flags) } -} - /// Open a file at a specific path pub fn openat>( fd: usize, diff --git a/src/data.rs b/src/data.rs index c7d8568c55..fc21f358a6 100644 --- a/src/data.rs +++ b/src/data.rs @@ -408,6 +408,15 @@ impl DerefMut for CtxtStsBuf { } } +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct NewFdParams { + pub offset: u64, + pub number: usize, + pub flags: usize, + pub internal_flags: u8, +} + #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum GlobalSchemes { diff --git a/src/flag.rs b/src/flag.rs index 404e0bef78..954344b20f 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -102,6 +102,9 @@ bitflags::bitflags! { /// If set, the file descriptors received will be placed into the *upper* file table. const UPPER_TBL = 4; + /// If set, the received file descriptors are marked as close-on-exec. + const CLOEXEC = 8; + // No, cloexec won't be stored in the kernel in the future, when the stable ABI is moved to // relibc, so no flag for that! } @@ -116,6 +119,9 @@ bitflags::bitflags! { /// If set, the file descriptors received will be placed into the *upper* file table. const UPPER_TBL = 2; + + /// If set, the received file descriptors are marked as close-on-exec. + const CLOEXEC = 4; } } bitflags::bitflags! { @@ -404,6 +410,7 @@ bitflags! { const FD_EXCLUSIVE = 1 << 12; const FD_CLONE = 1 << 13; const FD_UPPER = 1 << 14; + const FD_CLOEXEC = 1 << 15; } } diff --git a/src/number.rs b/src/number.rs index e7400cb3a5..f954bb7f81 100644 --- a/src/number.rs +++ b/src/number.rs @@ -10,7 +10,6 @@ pub const SYS_ARG_PATH: usize = 0x0300_0000; pub const SYS_RET: usize = 0x00F0_0000; pub const SYS_RET_FILE: usize = 0x0010_0000; -pub const SYS_OPEN: usize = SYS_CLASS_PATH | SYS_RET_FILE | 5; pub const SYS_OPENAT: usize = SYS_CLASS_PATH | SYS_RET_FILE | 7; pub const SYS_OPENAT_WITH_FILTER: usize = SYS_CLASS_PATH | SYS_RET_FILE | 985; pub const SYS_UNLINKAT: usize = SYS_CLASS_PATH | 263; diff --git a/src/schemev2.rs b/src/schemev2.rs index ce86653b4a..bb017bca2b 100644 --- a/src/schemev2.rs +++ b/src/schemev2.rs @@ -99,9 +99,6 @@ impl CqeOpcode { #[non_exhaustive] #[derive(Clone, Copy, Debug)] pub enum Opcode { - Open = 0, // path_ptr, path_len (utf8), flags - Rmdir = 1, // path_ptr, path_len (utf8) - Unlink = 2, // path_ptr, path_len (utf8) Close = 3, // fd Dup = 4, // old fd, buf_ptr, buf_len Read = 5, // fd, buf_ptr, buf_len, TODO offset, TODO flags, _ @@ -145,9 +142,6 @@ impl Opcode { // TODO: Use a library where this match can be automated. Some(match raw { - 0 => Open, - 1 => Rmdir, - 2 => Unlink, 3 => Close, 4 => Dup, 5 => Read,