Merge branch 'userspace_cwd' into 'master'

Remove cwd related syscalls and SYS_CHMOD.

See merge request redox-os/syscall!71
This commit is contained in:
Jeremy Soller
2022-08-15 21:02:25 +00:00
7 changed files with 0 additions and 82 deletions

View File

@@ -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<T: AsRef<str>>(path: T) -> Result<usize> {
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<T: AsRef<str>>(path: T, mode: usize) -> Result<usize> {
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<usize> {
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<usize> {
unsafe { syscall2(SYS_GETCWD, buf.as_mut_ptr() as usize, buf.len()) }
}
/// Get the effective group ID
pub fn getegid() -> Result<usize> {
unsafe { syscall0(SYS_GETEGID) }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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(&current_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));