Use open for mkdir

This commit is contained in:
Jeremy Soller
2016-11-25 16:57:21 -07:00
parent 2835586ee6
commit 7497b715cd
5 changed files with 2 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "redox_syscall"
version = "0.1.10"
version = "0.1.11"
description = "A Rust library to access raw Redox system calls"
license = "MIT"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]

View File

@@ -181,11 +181,6 @@ pub fn lseek(fd: usize, offset: isize, whence: usize) -> Result<usize> {
unsafe { syscall3(SYS_LSEEK, fd, offset as usize, whence) }
}
/// Make a directory, with permissions `mode`
pub fn mkdir(path: &str, mode: u16) -> Result<usize> {
unsafe { syscall3(SYS_MKDIR, path.as_ptr() as usize, path.len(), mode as usize) }
}
/// Make a new scheme namespace
pub fn mkns(schemes: &[[usize; 2]]) -> Result<usize> {
unsafe { syscall2(SYS_MKNS, schemes.as_ptr() as usize, schemes.len()) }

View File

@@ -41,6 +41,7 @@ pub const O_CLOEXEC: usize = 0x0100_0000;
pub const O_CREAT: usize = 0x0200_0000;
pub const O_TRUNC: usize = 0x0400_0000;
pub const O_EXCL: usize = 0x0800_0000;
pub const O_DIRECTORY: usize = 0x1000_0000;
pub const O_ACCMODE: usize = O_RDONLY | O_WRONLY | O_RDWR;
pub const SEEK_SET: usize = 0;

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_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

@@ -6,7 +6,6 @@ pub trait Scheme {
fn handle(&self, packet: &mut Packet) {
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),
@@ -36,11 +35,6 @@ pub trait Scheme {
Err(Error::new(ENOENT))
}
#[allow(unused_variables)]
fn mkdir(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))
}
#[allow(unused_variables)]
fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))
@@ -127,7 +121,6 @@ pub trait SchemeMut {
fn handle(&mut self, packet: &mut Packet) {
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),
@@ -156,11 +149,6 @@ pub trait SchemeMut {
Err(Error::new(ENOENT))
}
#[allow(unused_variables)]
fn mkdir(&mut self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))
}
#[allow(unused_variables)]
fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))