[wasi-common] Clean up the use of mutable Entry (#1395)
* Clean up the use of mutable Entry Until now, several syscalls including `fd_pwrite` etc. were relying on mutating `&mut Entry` by mutating its inner file handle. This is unnecessary in almost all cases since all methods mutating `std::fs::File` in Rust's libstd are also implemented for `&std::fs::File`. While here, I've also modified `OsHandle` in BSD to include `RefCell<Option<Dir>>` rather than `Option<Mutex<Dir>>` as was until now. While `RefCell` could easily be replaced with `RefCell`, since going multithreading will require a lot of (probably even) conceptual changes to `wasi-common`, I thought it'd be best not to mix single- with multithreading contexts and swap all places at once when it comes to it. I've also had to make some modifications to virtual FS which mainly swapped mutability for interior mutability in places. * Use one-liners wherever convenient
This commit is contained in:
@@ -44,7 +44,7 @@ pub(crate) fn filestat_get(file: &std::fs::File) -> Result<types::Filestat> {
|
||||
}
|
||||
|
||||
pub(crate) fn readdir<'a>(
|
||||
os_handle: &'a mut OsHandle,
|
||||
os_handle: &'a OsHandle,
|
||||
cookie: types::Dircookie,
|
||||
) -> Result<impl Iterator<Item = Result<(types::Dirent, String)>> + 'a> {
|
||||
use yanix::dir::{DirIter, Entry, EntryExt, SeekLoc};
|
||||
|
||||
Reference in New Issue
Block a user