stub out set_oflags for unix i guess?

what do we do about unsupported stuff like that? silently return OK?
This commit is contained in:
Pat Hickey
2020-12-10 15:37:02 -08:00
parent cdb642b3d6
commit 03c92de5aa
3 changed files with 19 additions and 4 deletions

View File

@@ -34,6 +34,9 @@ pub enum Error {
#[error("Unexpected IoError: {0}")]
UnexpectedIo(#[source] std::io::Error),
#[error("Unsupported operation: {0}")]
Unsupported(String),
// Below this, all variants are from the `$errno` type:
/// Errno::TooBig: Argument list too long
#[error("TooBig: Argument list too long")]

View File

@@ -24,6 +24,7 @@ pub enum Filetype {
SocketStream,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct FdFlags {
flags: u32,
}
@@ -42,6 +43,7 @@ impl FdFlags {
// etc
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct OFlags {
flags: u32,
}
@@ -187,10 +189,19 @@ impl WasiFile for cap_std::fs::File {
Ok(OFlags::RDWR)
}
}
fn set_oflags(&self, _flags: OFlags) -> Result<(), Error> {
// XXX cap-std::fs::Permissions does not export a constructor to build this out of
#[allow(unreachable_code)]
self.set_permissions(todo!())?;
fn set_oflags(&self, flags: OFlags) -> Result<(), Error> {
#![allow(unreachable_code, unused_variables)]
cfg_if! {
if #[cfg(unix)] {
use std::os::unix::fs::PermissionsExt;
use cap_std::fs::Permissions;
use std::fs::Permissions as StdPermissions;
let flags = todo!("normalize to unix flags {:?}", flags);
self.set_permissions(Permissions::from_std(StdPermissions::from_mode(flags)))?;
} else {
Err(Error::Unsupported("set oflags on non-unix host system".to_owned()))
}
}
Ok(())
}
fn get_filestat(&self) -> Result<Filestat, Error> {

View File

@@ -75,6 +75,7 @@ impl From<Error> for types::Errno {
Error::DirNotCapable { .. } => Errno::Notcapable,
Error::NotCapable => Errno::Notcapable,
Error::TableOverflow => Errno::Overflow,
Error::Unsupported { .. } => Errno::Notcapable, // XXX is this reasonable?
}
}
}