Commit 0e73ef14 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Add fchown, fchmod

parent 71c51bdb
......@@ -83,7 +83,19 @@ pub fn exit(status: usize) -> Result<usize> {
unsafe { syscall1(SYS_EXIT, status) }
}
/// Register a file for event-based I/O
/// Change file permissions
pub fn fchmod(fd: usize, mode: u16) -> Result<usize> {
unsafe { syscall2(SYS_FCHMOD, fd, mode as usize) }
}
/// Change file ownership
pub fn fchown(fd: usize, uid: u32, gid: u32) -> Result<usize> {
unsafe { syscall3(SYS_FCHOWN, fd, uid as usize, gid as usize) }
}
/// Change file descriptor flags
pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> {
unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) }
}
......
......@@ -22,6 +22,8 @@ pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63;
pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3;
pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4;
pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19;
pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94;
pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207;
pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55;
pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927;
pub const SYS_FMAP: usize = SYS_CLASS_FILE | 90;
......
......@@ -14,6 +14,8 @@ pub trait Scheme {
SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
SYS_LSEEK => self.seek(packet.b, packet.c, packet.d),
SYS_FCHMOD => self.fchmod(packet.b, packet.c as u16),
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32),
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
SYS_FEVENT => self.fevent(packet.b, packet.c),
SYS_FMAP => self.fmap(packet.b, packet.c, packet.d),
......@@ -83,6 +85,16 @@ pub trait Scheme {
Err(Error::new(EBADF))
}
#[allow(unused_variables)]
fn fchmod(&self, id: usize, mode: u16) -> Result<usize> {
Err(Error::new(EBADF))
}
#[allow(unused_variables)]
fn fchown(&self, id: usize, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(EBADF))
}
#[allow(unused_variables)]
fn fcntl(&self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
Err(Error::new(EBADF))
......@@ -146,6 +158,8 @@ pub trait SchemeMut {
SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
SYS_LSEEK => self.seek(packet.b, packet.c, packet.d),
SYS_FCHMOD => self.fchmod(packet.b, packet.c as u16),
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32),
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
SYS_FEVENT => self.fevent(packet.b, packet.c),
SYS_FMAP => self.fmap(packet.b, packet.c, packet.d),
......@@ -214,6 +228,16 @@ pub trait SchemeMut {
Err(Error::new(EBADF))
}
#[allow(unused_variables)]
fn fchmod(&mut self, id: usize, mode: u16) -> Result<usize> {
Err(Error::new(EBADF))
}
#[allow(unused_variables)]
fn fchown(&mut self, id: usize, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(EBADF))
}
#[allow(unused_variables)]
fn fcntl(&mut self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
Err(Error::new(EBADF))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment