alnyan/yggdrasil: get rid of some todos
This commit is contained in:
parent
56469a9118
commit
d6da94083e
@ -84,10 +84,3 @@ impl FromRawFd for crate::fs::File {
|
||||
crate::fs::File::from_inner(inner)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> AsRawFd for crate::io::StdinLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use yggdrasil_rt::io::{
|
||||
FileMode as OsFileMode, OpenOptions as OsOpenOptions, SeekFrom as OsSeekFrom,
|
||||
FileMetadataUpdate, FileMetadataUpdateMode, FileMode as OsFileMode,
|
||||
OpenOptions as OsOpenOptions, SeekFrom as OsSeekFrom,
|
||||
};
|
||||
|
||||
use super::{FileAttr, FilePermissions, FileTimes};
|
||||
@ -30,7 +31,7 @@ impl OpenOptions {
|
||||
if read {
|
||||
self.options |= OsOpenOptions::READ;
|
||||
} else {
|
||||
todo!()
|
||||
self.options &= !OsOpenOptions::READ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +39,7 @@ impl OpenOptions {
|
||||
if write {
|
||||
self.options |= OsOpenOptions::WRITE;
|
||||
} else {
|
||||
todo!()
|
||||
self.options &= !OsOpenOptions::WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ impl OpenOptions {
|
||||
if append {
|
||||
self.options |= OsOpenOptions::APPEND;
|
||||
} else {
|
||||
todo!()
|
||||
self.options &= !OsOpenOptions::APPEND;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +55,7 @@ impl OpenOptions {
|
||||
if truncate {
|
||||
self.options |= OsOpenOptions::TRUNCATE;
|
||||
} else {
|
||||
todo!()
|
||||
self.options &= !OsOpenOptions::TRUNCATE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +63,7 @@ impl OpenOptions {
|
||||
if create {
|
||||
self.options |= OsOpenOptions::CREATE;
|
||||
} else {
|
||||
todo!()
|
||||
self.options &= !OsOpenOptions::CREATE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +71,7 @@ impl OpenOptions {
|
||||
if create_new {
|
||||
self.options |= OsOpenOptions::CREATE_EXCL | OsOpenOptions::CREATE;
|
||||
} else {
|
||||
todo!()
|
||||
self.options &= !OsOpenOptions::CREATE_EXCL | OsOpenOptions::CREATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,11 +96,13 @@ impl File {
|
||||
}
|
||||
|
||||
pub fn fsync(&self) -> io::Result<()> {
|
||||
todo!()
|
||||
crate::debug_trace!("TODO: fsync()");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn datasync(&self) -> io::Result<()> {
|
||||
todo!()
|
||||
crate::debug_trace!("TODO: datasync()");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn truncate(&self, _size: u64) -> io::Result<()> {
|
||||
@ -111,7 +114,7 @@ impl File {
|
||||
}
|
||||
|
||||
pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -128,7 +131,7 @@ impl File {
|
||||
}
|
||||
|
||||
pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -137,7 +140,7 @@ impl File {
|
||||
}
|
||||
|
||||
pub fn flush(&self) -> io::Result<()> {
|
||||
todo!()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn seek(&self, pos: SeekFrom) -> io::Result<u64> {
|
||||
@ -147,15 +150,23 @@ impl File {
|
||||
}
|
||||
|
||||
pub fn duplicate(&self) -> io::Result<File> {
|
||||
todo!()
|
||||
let fd = cvt_io(unsafe { yggdrasil_rt::sys::clone_fd(self.as_raw_fd(), None) })?;
|
||||
Ok(unsafe { File::from_raw_fd(fd) })
|
||||
}
|
||||
|
||||
pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> {
|
||||
todo!()
|
||||
pub fn set_permissions(&self, perm: FilePermissions) -> io::Result<()> {
|
||||
cvt_io(unsafe {
|
||||
yggdrasil_rt::sys::update_metadata(
|
||||
Some(self.as_raw_fd()),
|
||||
"",
|
||||
&FileMetadataUpdate::Permissions(perm.0, FileMetadataUpdateMode::Set),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_times(&self, _times: FileTimes) -> io::Result<()> {
|
||||
todo!();
|
||||
crate::debug_trace!("TODO: File::set_times()");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
use yggdrasil_rt::io::{
|
||||
FileAttr as OsFileAttr, FileMode as OsFileMode, FileType as OsFileType, RawFd as OsRawFd,
|
||||
FileAttr as OsFileAttr, FileMetadataUpdate, FileMetadataUpdateMode, FileMode as OsFileMode,
|
||||
FileType as OsFileType, RawFd as OsRawFd,
|
||||
};
|
||||
|
||||
use crate::hash::Hash;
|
||||
@ -67,11 +68,17 @@ impl FileAttr {
|
||||
|
||||
impl FilePermissions {
|
||||
pub fn readonly(&self) -> bool {
|
||||
todo!()
|
||||
!self.0.contains_any(
|
||||
OsFileMode::USER_WRITE | OsFileMode::GROUP_WRITE | OsFileMode::OTHER_WRITE,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_readonly(&mut self, _readonly: bool) {
|
||||
todo!()
|
||||
pub fn set_readonly(&mut self, readonly: bool) {
|
||||
if readonly {
|
||||
self.0 &= !(OsFileMode::USER_WRITE | OsFileMode::GROUP_WRITE | OsFileMode::OTHER_WRITE);
|
||||
} else {
|
||||
self.0 |= OsFileMode::USER_WRITE | OsFileMode::GROUP_WRITE | OsFileMode::OTHER_WRITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,11 +110,11 @@ impl fmt::Debug for FileType {
|
||||
|
||||
impl FileTimes {
|
||||
pub fn set_accessed(&mut self, _t: SystemTime) {
|
||||
todo!()
|
||||
crate::debug_trace!("TODO: FileTimes::set_accessed()");
|
||||
}
|
||||
|
||||
pub fn set_modified(&mut self, _t: SystemTime) {
|
||||
todo!()
|
||||
crate::debug_trace!("TODO: FileTimes::set_modified()");
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,8 +136,16 @@ pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn set_perm(_p: &Path, _perm: FilePermissions) -> io::Result<()> {
|
||||
todo!()
|
||||
pub fn set_perm(path: &Path, perm: FilePermissions) -> io::Result<()> {
|
||||
run_with_path_str(path, |path_str| {
|
||||
cvt_io(unsafe {
|
||||
yggdrasil_rt::sys::update_metadata(
|
||||
None,
|
||||
path_str,
|
||||
&FileMetadataUpdate::Permissions(perm.0, FileMetadataUpdateMode::Set),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn readlink(path: &Path) -> io::Result<PathBuf> {
|
||||
|
@ -7,7 +7,8 @@ use yggdrasil_rt::process::ExitCode as OsExitCode;
|
||||
use yggdrasil_rt::{Error as OsError, sys as syscall};
|
||||
|
||||
pub fn errno() -> i32 {
|
||||
todo!()
|
||||
// Errors are communicated directly, no errno
|
||||
0
|
||||
}
|
||||
|
||||
pub fn error_string(errno: i32) -> String {
|
||||
|
@ -298,7 +298,7 @@ impl Command {
|
||||
}
|
||||
|
||||
pub fn get_envs(&self) -> CommandEnvs<'_> {
|
||||
todo!()
|
||||
self.env.iter()
|
||||
}
|
||||
|
||||
pub fn get_current_dir(&self) -> Option<&Path> {
|
||||
|
@ -1,7 +1,9 @@
|
||||
use yggdrasil_rt::Error as OsError;
|
||||
use yggdrasil_rt::io::RawFd;
|
||||
|
||||
use crate::io;
|
||||
use crate::io::{IoSlice, IoSliceMut};
|
||||
use crate::sys::cvt_io;
|
||||
use yggdrasil_rt::{io::RawFd, Error as OsError};
|
||||
|
||||
pub struct Stdin;
|
||||
pub struct Stdout;
|
||||
@ -31,7 +33,7 @@ impl io::Read for Stdin {
|
||||
}
|
||||
|
||||
fn read_vectored(&mut self, _data: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -46,7 +48,7 @@ impl io::Write for Stdout {
|
||||
}
|
||||
|
||||
fn write_vectored(&mut self, _data: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -65,7 +67,7 @@ impl io::Write for Stderr {
|
||||
}
|
||||
|
||||
fn write_vectored(&mut self, _data: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
Loading…
x
Reference in New Issue
Block a user