diff --git a/src/call.rs b/src/call.rs index 1e8eac6..bc1af0d 100644 --- a/src/call.rs +++ b/src/call.rs @@ -12,32 +12,6 @@ extern "C" fn restorer() -> ! { unreachable!(); } -/// Change the process's working directory -/// -/// This function will attempt to set the process's working directory to `path`, which can be -/// either a relative, scheme relative, or absolute path. -/// -/// On success, `Ok(0)` will be returned. On error, one of the following errors will be returned. -/// -/// # Errors -/// -/// * `EACCES` - permission is denied for one of the components of `path`, or `path` -/// * `EFAULT` - `path` does not point to the process's addressible memory -/// * `EIO` - an I/O error occurred -/// * `ENOENT` - `path` does not exit -/// * `ENOTDIR` - `path` is not a directory -pub fn chdir>(path: T) -> Result { - unsafe { syscall2(SYS_CHDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) } -} - -#[deprecated( - since = "0.1.55", - note = "use fchmod instead" -)] -pub fn chmod>(path: T, mode: usize) -> Result { - unsafe { syscall3(SYS_CHMOD, path.as_ref().as_ptr() as usize, path.as_ref().len(), mode) } -} - /// Close a file pub fn close(fd: usize) -> Result { unsafe { syscall1(SYS_CLOSE, fd) } @@ -140,11 +114,6 @@ pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mu syscall5(SYS_FUTEX, addr as usize, op, (val as isize) as usize, val2, addr2 as usize) } -/// Get the current working directory -pub fn getcwd(buf: &mut [u8]) -> Result { - unsafe { syscall2(SYS_GETCWD, buf.as_mut_ptr() as usize, buf.len()) } -} - /// Get the effective group ID pub fn getegid() -> Result { unsafe { syscall0(SYS_GETEGID) } diff --git a/src/number.rs b/src/number.rs index a35f469..2b9205a 100644 --- a/src/number.rs +++ b/src/number.rs @@ -12,7 +12,6 @@ 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_CHMOD: usize = SYS_CLASS_PATH | 15; pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84; pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10; @@ -38,11 +37,9 @@ pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118; pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93; pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320; -pub const SYS_CHDIR: usize = 12; pub const SYS_CLOCK_GETTIME: usize = 265; pub const SYS_EXIT: usize = 1; pub const SYS_FUTEX: usize = 240; -pub const SYS_GETCWD: usize = 183; pub const SYS_GETEGID: usize = 202; pub const SYS_GETENS: usize = 951; pub const SYS_GETEUID: usize = 201; diff --git a/src/scheme/scheme.rs b/src/scheme/scheme.rs index 249d28c..6bf3617 100644 --- a/src/scheme/scheme.rs +++ b/src/scheme/scheme.rs @@ -14,11 +14,6 @@ pub trait Scheme { } else { Err(Error::new(EINVAL)) }, - SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { - self.chmod(path, packet.d as u16, packet.uid, packet.gid) - } else { - Err(Error::new(EINVAL)) - }, SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { self.rmdir(path, packet.uid, packet.gid) } else { diff --git a/src/scheme/scheme_block.rs b/src/scheme/scheme_block.rs index e22535e..3b3de4b 100644 --- a/src/scheme/scheme_block.rs +++ b/src/scheme/scheme_block.rs @@ -14,11 +14,6 @@ pub trait SchemeBlock { } else { Err(Error::new(EINVAL)) }, - SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { - self.chmod(path, packet.d as u16, packet.uid, packet.gid) - } else { - Err(Error::new(EINVAL)) - }, SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { self.rmdir(path, packet.uid, packet.gid) } else { diff --git a/src/scheme/scheme_block_mut.rs b/src/scheme/scheme_block_mut.rs index c1e5435..1fae3a0 100644 --- a/src/scheme/scheme_block_mut.rs +++ b/src/scheme/scheme_block_mut.rs @@ -14,11 +14,6 @@ pub trait SchemeBlockMut { } else { Err(Error::new(EINVAL)) }, - SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { - self.chmod(path, packet.d as u16, packet.uid, packet.gid) - } else { - Err(Error::new(EINVAL)) - }, SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { self.rmdir(path, packet.uid, packet.gid) } else { diff --git a/src/scheme/scheme_mut.rs b/src/scheme/scheme_mut.rs index deb1483..b364b62 100644 --- a/src/scheme/scheme_mut.rs +++ b/src/scheme/scheme_mut.rs @@ -14,11 +14,6 @@ pub trait SchemeMut { } else { Err(Error::new(EINVAL)) }, - SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { - self.chmod(path, packet.d as u16, packet.uid, packet.gid) - } else { - Err(Error::new(EINVAL)) - }, SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { self.rmdir(path, packet.uid, packet.gid) } else { diff --git a/src/tests.rs b/src/tests.rs index c5e1f8d..fdff89b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,29 +1,3 @@ -#[test] -fn chdir() { - use std::str; - - let mut current_buf = [0; 4096]; - let current_count = dbg!(crate::getcwd(&mut current_buf)).unwrap(); - let current = dbg!(str::from_utf8(¤t_buf[..current_count])).unwrap(); - - let new = "file:"; - assert_eq!(dbg!(crate::chdir(dbg!(new))), Ok(0)); - { - let mut buf = [0; 4096]; - let count = dbg!(crate::getcwd(&mut buf)).unwrap(); - assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(new)); - } - - assert_eq!(dbg!(crate::chdir(current)), Ok(0)); - { - let mut buf = [0; 4096]; - let count = dbg!(crate::getcwd(&mut buf)).unwrap(); - assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(current)); - } -} - -//TODO: chmod - #[test] fn clone() { let expected_status = 42; @@ -207,8 +181,6 @@ fn fstatvfs() { //TODO: futex -// getcwd tested by chdir - #[test] fn getegid() { assert_eq!(crate::getegid(), Ok(0));