mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-28 08:01:33 +00:00
add comment and reduce code in pre-open loading section
This commit is contained in:
@ -36,6 +36,7 @@ impl<T: Copy + ValueType> WasmPtr<T, Item> {
|
|||||||
return Err(__WASI_EFAULT);
|
return Err(__WASI_EFAULT);
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
|
// clears bits below aligment amount (assumes power of 2) to align pointer
|
||||||
let aligner = |ptr: usize, align: usize| ptr & !(align - 1);
|
let aligner = |ptr: usize, align: usize| ptr & !(align - 1);
|
||||||
let cell_ptr = aligner(
|
let cell_ptr = aligner(
|
||||||
memory.view::<u8>().as_ptr().add(self.offset as usize) as usize,
|
memory.view::<u8>().as_ptr().add(self.offset as usize) as usize,
|
||||||
|
@ -218,35 +218,10 @@ impl WasiFs {
|
|||||||
file
|
file
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
let inode_val = InodeVal {
|
// TODO: handle nested pats in `file`
|
||||||
stat: __wasi_filestat_t {
|
let inode_val =
|
||||||
st_filetype: __WASI_FILETYPE_DIRECTORY,
|
InodeVal::from_file_metadata(cur_file_metadata, file.clone(), true, kind);
|
||||||
st_size: cur_file_metadata.len(),
|
|
||||||
st_atim: cur_file_metadata
|
|
||||||
.accessed()
|
|
||||||
.ok()
|
|
||||||
.and_then(|sys_time| sys_time.duration_since(SystemTime::UNIX_EPOCH).ok())
|
|
||||||
.map(|duration| duration.as_nanos() as u64)
|
|
||||||
.unwrap_or(0),
|
|
||||||
st_ctim: cur_file_metadata
|
|
||||||
.created()
|
|
||||||
.ok()
|
|
||||||
.and_then(|sys_time| sys_time.duration_since(SystemTime::UNIX_EPOCH).ok())
|
|
||||||
.map(|duration| duration.as_nanos() as u64)
|
|
||||||
.unwrap_or(0),
|
|
||||||
st_mtim: cur_file_metadata
|
|
||||||
.modified()
|
|
||||||
.ok()
|
|
||||||
.and_then(|sys_time| sys_time.duration_since(SystemTime::UNIX_EPOCH).ok())
|
|
||||||
.map(|duration| duration.as_nanos() as u64)
|
|
||||||
.unwrap_or(0),
|
|
||||||
..__wasi_filestat_t::default()
|
|
||||||
},
|
|
||||||
is_preopened: true,
|
|
||||||
// TODO: handle nested paths
|
|
||||||
name: file.clone(),
|
|
||||||
kind,
|
|
||||||
};
|
|
||||||
let inode = wasi_fs.inodes.insert(inode_val);
|
let inode = wasi_fs.inodes.insert(inode_val);
|
||||||
wasi_fs.inodes[inode].stat.st_ino = wasi_fs.inode_counter.get();
|
wasi_fs.inodes[inode].stat.st_ino = wasi_fs.inode_counter.get();
|
||||||
wasi_fs
|
wasi_fs
|
||||||
|
Reference in New Issue
Block a user