Add chmod, update cargo version

This commit is contained in:
Jeremy Soller
2016-11-15 16:43:49 -07:00
parent cd6f7c219c
commit 3ee7a7ff0f
4 changed files with 17 additions and 6 deletions

View File

@@ -37,6 +37,10 @@ pub fn chdir(path: &str) -> Result<usize> {
unsafe { syscall2(SYS_CHDIR, path.as_ptr() as usize, path.len()) }
}
pub fn chmod(path: &str, mode: usize) -> Result<usize> {
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<usize> {
syscall1_clobber(SYS_CLONE, flags)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<usize> {
Err(Error::new(ENOENT))
}
#[allow(unused_variables)]
fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
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<usize> {
Err(Error::new(ENOENT))
}
#[allow(unused_variables)]
fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))