shims::fs adding more fields to FileMetadata
addressing, partially at least, FIXME comment and targetting unixes, adding device, user and group ids.
This commit is contained in:
parent
23b3be5ada
commit
d87984e129
1 changed files with 27 additions and 4 deletions
|
|
@ -128,16 +128,19 @@ trait EvalContextExtPrivate<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
let (created_sec, created_nsec) = metadata.created.unwrap_or((0, 0));
|
||||
let (modified_sec, modified_nsec) = metadata.modified.unwrap_or((0, 0));
|
||||
let mode = metadata.mode.to_uint(this.libc_ty_layout("mode_t").size)?;
|
||||
let dev = metadata.dev;
|
||||
let uid = metadata.uid;
|
||||
let gid = metadata.gid;
|
||||
|
||||
let buf = this.deref_pointer_as(buf_op, this.libc_ty_layout("stat"))?;
|
||||
this.write_int_fields_named(
|
||||
&[
|
||||
("st_dev", 0),
|
||||
("st_dev", dev.into()),
|
||||
("st_mode", mode.try_into().unwrap()),
|
||||
("st_nlink", 0),
|
||||
("st_ino", 0),
|
||||
("st_uid", 0),
|
||||
("st_gid", 0),
|
||||
("st_uid", uid.into()),
|
||||
("st_gid", gid.into()),
|
||||
("st_rdev", 0),
|
||||
("st_atime", access_sec.into()),
|
||||
("st_mtime", modified_sec.into()),
|
||||
|
|
@ -1544,6 +1547,9 @@ struct FileMetadata {
|
|||
created: Option<(u64, u32)>,
|
||||
accessed: Option<(u64, u32)>,
|
||||
modified: Option<(u64, u32)>,
|
||||
dev: u64,
|
||||
uid: u32,
|
||||
gid: u32,
|
||||
}
|
||||
|
||||
impl FileMetadata {
|
||||
|
|
@ -1575,6 +1581,9 @@ impl FileMetadata {
|
|||
ecx: &mut MiriInterpCx<'tcx>,
|
||||
metadata: Result<std::fs::Metadata, std::io::Error>,
|
||||
) -> InterpResult<'tcx, Result<FileMetadata, IoError>> {
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
||||
let metadata = match metadata {
|
||||
Ok(metadata) => metadata,
|
||||
Err(e) => {
|
||||
|
|
@ -1601,6 +1610,20 @@ impl FileMetadata {
|
|||
let modified = extract_sec_and_nsec(metadata.modified())?;
|
||||
|
||||
// FIXME: Provide more fields using platform specific methods.
|
||||
interp_ok(Ok(FileMetadata { mode, size, created, accessed, modified }))
|
||||
|
||||
cfg_select! {
|
||||
unix => {
|
||||
let dev = metadata.dev();
|
||||
let uid = metadata.uid();
|
||||
let gid = metadata.gid();
|
||||
}
|
||||
_ => {
|
||||
let dev = 0;
|
||||
let uid = 0;
|
||||
let gid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
interp_ok(Ok(FileMetadata { mode, size, created, accessed, modified, dev, uid, gid }))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue