Skip to content

Commit

Permalink
Added basic support to inode in filestat_get (for #3583 and #3239)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Apr 13, 2023
1 parent f0478b9 commit 7a6b5e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/wasi/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub const MAX_SYMLINKS: u32 = 128;
pub struct Inode(u64);

impl Inode {
fn as_u64(&self) -> u64 {
pub fn as_u64(&self) -> u64 {
self.0
}
}
Expand Down
11 changes: 7 additions & 4 deletions lib/wasi/src/syscalls/wasi/path_filestat_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ pub(crate) fn path_filestat_get_internal(
path_string,
flags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0,
)?;
if file_inode.is_preopened {
Ok(*file_inode.stat.read().unwrap().deref())
let st_ino = file_inode.ino().as_u64();
let mut stat = if file_inode.is_preopened {
*file_inode.stat.read().unwrap().deref()
} else {
let guard = file_inode.read();
state.fs.get_stat_for_kind(guard.deref())
}
state.fs.get_stat_for_kind(guard.deref())?
};
stat.st_ino = st_ino;
Ok(stat)
}

0 comments on commit 7a6b5e1

Please sign in to comment.