Remove redundant methods from KernelScheme.
This commit is contained in:
+16
-27
@@ -590,16 +590,16 @@ pub trait KernelScheme: Send + Sync + 'static {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
fn kfpath(&self, id: usize, buf: UserSliceWo, token: &mut CleanLockToken) -> Result<usize>;
|
||||
fn kfutimens(&self, id: usize, buf: UserSliceRo, token: &mut CleanLockToken) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
fn kfstat(&self, id: usize, buf: UserSliceWo, token: &mut CleanLockToken) -> Result<()> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
// SYS_FSTATVFS is removed, this still exists as the memory scheme implements it to allow df to show memory usage.
|
||||
fn kfstatvfs(&self, id: usize, buf: UserSliceWo, token: &mut CleanLockToken) -> Result<()> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
// SYS_GETDENTS is removed, but this is still used by the irq, acpi and sys schemes. TODO:
|
||||
// outsource sys scheme to userspace and switch to a non-filesystem API for acpi and irq?
|
||||
fn getdents(
|
||||
&self,
|
||||
id: usize,
|
||||
@@ -611,18 +611,15 @@ pub trait KernelScheme: Send + Sync + 'static {
|
||||
Err(Error::new(EOPNOTSUPP))
|
||||
}
|
||||
|
||||
// SYS_FSYNC is deprecated, but many schemes still implement the corresponding std_fs_call, so
|
||||
// this should be kept for now.
|
||||
fn fsync(&self, id: usize, token: &mut CleanLockToken) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
fn ftruncate(&self, id: usize, len: usize, token: &mut CleanLockToken) -> Result<()> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
fn fsize(&self, id: usize, token: &mut CleanLockToken) -> Result<u64> {
|
||||
Err(Error::new(ESPIPE))
|
||||
}
|
||||
fn fchmod(&self, id: usize, new_mode: u16, token: &mut CleanLockToken) -> Result<()> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
fn fchown(
|
||||
&self,
|
||||
id: usize,
|
||||
@@ -677,15 +674,6 @@ pub trait KernelScheme: Send + Sync + 'static {
|
||||
) -> Result<()> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
fn relpathat(
|
||||
&self,
|
||||
dirfd: usize,
|
||||
fd: usize,
|
||||
payload: UserSliceRo,
|
||||
token: &mut CleanLockToken,
|
||||
) -> Result<usize> {
|
||||
Err(Error::new(EOPNOTSUPP))
|
||||
}
|
||||
fn close(&self, id: usize, token: &mut CleanLockToken) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
@@ -753,19 +741,16 @@ pub trait KernelScheme: Send + Sync + 'static {
|
||||
let metadata = StdFsCallMeta::new(kind, arg1, arg2);
|
||||
use StdFsCallKind::*;
|
||||
match kind {
|
||||
Relpathat => {
|
||||
if fds.len() != 2 {
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
self.relpathat(fds[0], fds[1], payload.into_ro()?, token)
|
||||
}
|
||||
// Seems unlikely any kernel scheme will implement this. If so, it can be added back to
|
||||
// this trait.
|
||||
Relpathat => Err(Error::new(EOPNOTSUPP)),
|
||||
|
||||
_ => {
|
||||
if fds.len() != 1 {
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
let id = fds[0];
|
||||
match kind {
|
||||
Fchmod => self.fchmod(id, metadata.arg1 as u16, token).map(|_| 0),
|
||||
Getdents => self.getdents(
|
||||
id,
|
||||
payload.into_wo()?,
|
||||
@@ -776,8 +761,12 @@ pub trait KernelScheme: Send + Sync + 'static {
|
||||
Fstat => self.kfstat(id, payload.into_wo()?, token).map(|_| 0),
|
||||
Fstatvfs => self.kfstatvfs(id, payload.into_wo()?, token).map(|_| 0),
|
||||
Fsync => self.fsync(id, token).map(|_| 0),
|
||||
Ftruncate => self.ftruncate(id, metadata.arg1 as usize, token).map(|_| 0),
|
||||
Futimens => self.kfutimens(id, payload.into_ro()?, token),
|
||||
|
||||
// The syscalls for these have been replaced by std_fs_call, and the only
|
||||
// scheme that used to provide a non-default impl was UserScheme. Preserve the
|
||||
// old default behavior for all other schemes.
|
||||
Ftruncate | Futimens | Fchmod => Err(Error::new(EBADF)),
|
||||
|
||||
/* TODO: Support Fchown and Unlinkat using std_fs_call
|
||||
Fchown => self.kstdfscall(fds, kind, desc, payload, flags, metadata, token),
|
||||
Unlinkat => self.kstdfscall(fds, kind, payload, metadata, &caller).map(|_| 0)
|
||||
|
||||
+19
-98
@@ -1468,21 +1468,6 @@ impl KernelScheme for UserScheme {
|
||||
.map(|o| o as u64)
|
||||
}
|
||||
|
||||
fn fchmod(&self, file: usize, mode: u16, token: &mut CleanLockToken) -> Result<()> {
|
||||
let ctx = { context::current().read(token.token()).caller_ctx() };
|
||||
self.inner
|
||||
.call(
|
||||
ctx,
|
||||
Vec::new(),
|
||||
Opcode::Fchmod,
|
||||
[file, mode as usize],
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fchown(&self, file: usize, uid: u32, gid: u32, token: &mut CleanLockToken) -> Result<()> {
|
||||
{
|
||||
let ctx = context::current();
|
||||
@@ -1617,21 +1602,6 @@ impl KernelScheme for UserScheme {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ftruncate(&self, file: usize, len: usize, token: &mut CleanLockToken) -> Result<()> {
|
||||
let ctx = { context::current().read(token.token()).caller_ctx() };
|
||||
self.inner
|
||||
.call(
|
||||
ctx,
|
||||
Vec::new(),
|
||||
Opcode::Ftruncate,
|
||||
[file, len],
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn close(&self, id: usize, token: &mut CleanLockToken) -> Result<()> {
|
||||
self.inner.todo.send(
|
||||
Sqe {
|
||||
@@ -1794,61 +1764,18 @@ impl KernelScheme for UserScheme {
|
||||
|
||||
result
|
||||
}
|
||||
fn kfutimens(
|
||||
&self,
|
||||
file: usize,
|
||||
buf: UserSliceRo,
|
||||
token: &mut CleanLockToken,
|
||||
) -> Result<usize> {
|
||||
let ctx = { context::current().read(token.token()).caller_ctx() };
|
||||
let mut address = self.inner.capture_user(buf, token)?;
|
||||
let result = self
|
||||
.inner
|
||||
.call(
|
||||
ctx,
|
||||
Vec::new(),
|
||||
Opcode::Futimens,
|
||||
[file, address.base(), address.len()],
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result
|
||||
}
|
||||
fn getdents(
|
||||
&self,
|
||||
file: usize,
|
||||
buf: UserSliceWo,
|
||||
header_size: u16,
|
||||
opaque_id_start: u64,
|
||||
token: &mut CleanLockToken,
|
||||
_file: usize,
|
||||
_buf: UserSliceWo,
|
||||
_header_size: u16,
|
||||
_opaque_id_start: u64,
|
||||
_token: &mut CleanLockToken,
|
||||
) -> Result<usize> {
|
||||
let ctx = { context::current().read(token.token()).caller_ctx() };
|
||||
let mut address = self.inner.capture_user(buf, token)?;
|
||||
// TODO: Support passing the 16-byte record_len of the last dent, to make it possible to
|
||||
// iterate backwards without first interating forward? The last entry will contain the
|
||||
// opaque id to pass to the next getdents. Since this field is small, this would fit in the
|
||||
// extra_raw field of `Cqe`s.
|
||||
let result = self
|
||||
.inner
|
||||
.call(
|
||||
ctx,
|
||||
Vec::new(),
|
||||
Opcode::Getdents,
|
||||
[
|
||||
file,
|
||||
address.base(),
|
||||
address.len(),
|
||||
header_size.into(),
|
||||
opaque_id_start as usize,
|
||||
],
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result
|
||||
// SYS_FSTATVFS has been removed, so this should be unreachable for UserScheme which
|
||||
// overrides translate_stdfscall
|
||||
error!("getdents should be unreachable for UserScheme");
|
||||
Err(Error::new(EBADFD))
|
||||
}
|
||||
fn kfstat(&self, file: usize, stat: UserSliceWo, token: &mut CleanLockToken) -> Result<()> {
|
||||
let ctx = { context::current().read(token.token()).caller_ctx() };
|
||||
@@ -1867,22 +1794,16 @@ impl KernelScheme for UserScheme {
|
||||
address.release(token)?;
|
||||
result.map(|_| ())
|
||||
}
|
||||
fn kfstatvfs(&self, file: usize, stat: UserSliceWo, token: &mut CleanLockToken) -> Result<()> {
|
||||
let ctx = { context::current().read(token.token()).caller_ctx() };
|
||||
let mut address = self.inner.capture_user(stat, token)?;
|
||||
let result = self
|
||||
.inner
|
||||
.call(
|
||||
ctx,
|
||||
Vec::new(),
|
||||
Opcode::Fstatvfs,
|
||||
[file, address.base(), address.len()],
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result.map(|_| ())
|
||||
fn kfstatvfs(
|
||||
&self,
|
||||
_file: usize,
|
||||
_stat: UserSliceWo,
|
||||
_token: &mut CleanLockToken,
|
||||
) -> Result<()> {
|
||||
// SYS_FSTATVFS has been removed, so this should be unreachable for UserScheme which
|
||||
// overrides translate_stdfscall
|
||||
error!("kfstatvfs should be unreachable for UserScheme");
|
||||
Err(Error::new(EBADFD))
|
||||
}
|
||||
fn kfmap(
|
||||
&self,
|
||||
|
||||
+2
-4
@@ -4,8 +4,6 @@
|
||||
|
||||
extern crate syscall;
|
||||
|
||||
use syscall::{dirent::DirentHeader, CallFlags, RwFlags, EINVAL};
|
||||
|
||||
pub use self::syscall::{
|
||||
data, error, flag, io, number, ptrace_event, EnvRegisters, FloatRegisters, IntRegisters,
|
||||
};
|
||||
@@ -15,8 +13,8 @@ pub use self::{fs::*, futex::futex, process::*, time::*, usercopy::validate_regi
|
||||
use self::{
|
||||
data::{Map, TimeSpec},
|
||||
debug::{debug_end, debug_start},
|
||||
error::{Error, Result, ENOSYS},
|
||||
flag::{EventFlags, MapFlags},
|
||||
error::{Error, Result, EINVAL, ENOSYS},
|
||||
flag::{CallFlags, EventFlags, MapFlags, RwFlags},
|
||||
number::*,
|
||||
usercopy::UserSlice,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user