diff --git a/src/call.rs b/src/call.rs index baa6737..6ea8b2f 100644 --- a/src/call.rs +++ b/src/call.rs @@ -37,6 +37,10 @@ pub fn chdir(path: &str) -> Result { unsafe { syscall2(SYS_CHDIR, path.as_ptr() as usize, path.len()) } } +pub fn chmod(path: &str, mode: usize) -> Result { + unsafe { syscall3(SYS_CHMOD, path.as_ptr() as usize, path.len(), mode) } +} + /// Produce a fork of the current process, or a new process thread pub unsafe fn clone(flags: usize) -> Result { syscall1_clobber(SYS_CLONE, flags) diff --git a/src/flag.rs b/src/flag.rs index 4f4f2a0..0d0f95a 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -21,12 +21,6 @@ pub const EVENT_WRITE: usize = 2; pub const F_GETFL: usize = 1; pub const F_SETFL: usize = 2; -pub const F_GETMODE: usize = 3; -pub const F_SETMODE: usize = 4; -pub const F_GETUID: usize = 5; -pub const F_SETUID: usize = 6; -pub const F_GETGID: usize = 7; -pub const F_SETGID: usize = 8; pub const FUTEX_WAIT: usize = 0; pub const FUTEX_WAKE: usize = 1; diff --git a/src/number.rs b/src/number.rs index 4768aa0..db90dcd 100644 --- a/src/number.rs +++ b/src/number.rs @@ -13,6 +13,7 @@ pub const SYS_RET_FILE: usize = 0x0010_0000; pub const SYS_LINK: usize = SYS_CLASS_PATH | SYS_ARG_PATH | 9; pub const SYS_OPEN: usize = SYS_CLASS_PATH | SYS_RET_FILE | 5; pub const SYS_MKDIR: usize = SYS_CLASS_PATH | 39; +pub const SYS_CHMOD: usize = SYS_CLASS_PATH | 15; pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84; pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10; diff --git a/src/scheme.rs b/src/scheme.rs index c3111fb..73f9065 100644 --- a/src/scheme.rs +++ b/src/scheme.rs @@ -7,6 +7,7 @@ pub trait Scheme { packet.a = Error::mux(match packet.a { SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), SYS_MKDIR => self.mkdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), + SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), @@ -39,6 +40,11 @@ pub trait Scheme { Err(Error::new(ENOENT)) } + #[allow(unused_variables)] + fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { + Err(Error::new(ENOENT)) + } + #[allow(unused_variables)] fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) @@ -116,6 +122,7 @@ pub trait SchemeMut { packet.a = Error::mux(match packet.a { SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), SYS_MKDIR => self.mkdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), + SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), @@ -147,6 +154,11 @@ pub trait SchemeMut { Err(Error::new(ENOENT)) } + #[allow(unused_variables)] + fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { + Err(Error::new(ENOENT)) + } + #[allow(unused_variables)] fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT))