@@ -411,9 +411,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
411
411
412
412
// If the `AT_SYMLINK_NOFOLLOW` flag is set, we query the file's metadata without following
413
413
// symbolic links.
414
- let is_symlink = flags & this. eval_libc ( "AT_SYMLINK_NOFOLLOW" ) ?. to_i32 ( ) ? ! = 0 ;
414
+ let follow_symlink = flags & this. eval_libc ( "AT_SYMLINK_NOFOLLOW" ) ?. to_i32 ( ) ? = = 0 ;
415
415
416
- let status = match FileStatus :: new ( this, path, is_symlink ) ? {
416
+ let status = match FileStatus :: new ( this, path, follow_symlink ) ? {
417
417
Some ( status) => status,
418
418
None => return Ok ( -1 ) ,
419
419
} ;
@@ -428,6 +428,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
428
428
. try_into ( )
429
429
. unwrap_or_else ( |_| bug ! ( "libc contains bad value for constant" ) ) ;
430
430
431
+ // We need to set the corresponding bits of `mask` if the access, creation and modification
432
+ // times were available. Otherwise we let them be zero.
431
433
let ( access_sec, access_nsec) = status. accessed . map ( |tup| {
432
434
mask |= this. eval_libc ( "STATX_ATIME" ) ?. to_u32 ( ) ?;
433
435
InterpResult :: Ok ( tup)
@@ -497,9 +499,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
497
499
}
498
500
}
499
501
500
- // Extracts the number of seconds and nanoseconds elapsed between `time` and the unix epoch when
501
- // `time` is Ok. If `time` is an error, it returns `None`.
502
- fn extract_sec_and_nsec < ' tcx > ( time : std:: io:: Result < SystemTime > ) -> InterpResult < ' tcx , Option < ( u64 , u32 ) > > {
502
+ /// Extracts the number of seconds and nanoseconds elapsed between `time` and the unix epoch when
503
+ /// `time` is Ok. Returns `None` if `time` is an error. Fails if `time` happens before the unix
504
+ /// epoch.
505
+ fn extract_sec_and_nsec < ' tcx > (
506
+ time : std:: io:: Result < SystemTime >
507
+ ) -> InterpResult < ' tcx , Option < ( u64 , u32 ) > > {
503
508
time. ok ( ) . map ( |time| {
504
509
let duration = system_time_to_duration ( & time) ?;
505
510
Ok ( ( duration. as_secs ( ) , duration. subsec_nanos ( ) ) )
@@ -518,9 +523,9 @@ impl FileStatus {
518
523
fn new < ' tcx , ' mir > (
519
524
ecx : & mut MiriEvalContext < ' mir , ' tcx > ,
520
525
path : PathBuf ,
521
- is_symlink : bool
526
+ follow_symlink : bool
522
527
) -> InterpResult < ' tcx , Option < FileStatus > > {
523
- let metadata = if is_symlink {
528
+ let metadata = if follow_symlink {
524
529
// FIXME: metadata for symlinks need testing.
525
530
std:: fs:: symlink_metadata ( path)
526
531
} else {
0 commit comments