@@ -265,47 +265,59 @@ impl FileDescription for FileHandle {
265
265
266
266
impl < ' tcx > EvalContextExtPrivate < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
267
267
trait EvalContextExtPrivate < ' tcx > : crate :: MiriInterpCxExt < ' tcx > {
268
- fn macos_stat_write_buf (
268
+ fn macos_fbsd_solaris_write_buf (
269
269
& mut self ,
270
270
metadata : FileMetadata ,
271
271
buf_op : & OpTy < ' tcx > ,
272
272
) -> InterpResult < ' tcx , i32 > {
273
273
let this = self . eval_context_mut ( ) ;
274
274
275
- let mode: u16 = metadata. mode . to_u16 ( ) ?;
276
-
277
275
let ( access_sec, access_nsec) = metadata. accessed . unwrap_or ( ( 0 , 0 ) ) ;
278
276
let ( created_sec, created_nsec) = metadata. created . unwrap_or ( ( 0 , 0 ) ) ;
279
277
let ( modified_sec, modified_nsec) = metadata. modified . unwrap_or ( ( 0 , 0 ) ) ;
278
+ let mode = metadata. mode . to_uint ( this. libc_ty_layout ( "mode_t" ) . size ) ?;
280
279
281
280
let buf = this. deref_pointer_as ( buf_op, this. libc_ty_layout ( "stat" ) ) ?;
282
-
283
281
this. write_int_fields_named (
284
282
& [
285
283
( "st_dev" , 0 ) ,
286
- ( "st_mode" , mode. into ( ) ) ,
284
+ ( "st_mode" , mode. try_into ( ) . unwrap ( ) ) ,
287
285
( "st_nlink" , 0 ) ,
288
286
( "st_ino" , 0 ) ,
289
287
( "st_uid" , 0 ) ,
290
288
( "st_gid" , 0 ) ,
291
289
( "st_rdev" , 0 ) ,
292
290
( "st_atime" , access_sec. into ( ) ) ,
293
- ( "st_atime_nsec" , access_nsec. into ( ) ) ,
294
291
( "st_mtime" , modified_sec. into ( ) ) ,
295
- ( "st_mtime_nsec" , modified_nsec. into ( ) ) ,
296
292
( "st_ctime" , 0 ) ,
297
- ( "st_ctime_nsec" , 0 ) ,
298
- ( "st_birthtime" , created_sec. into ( ) ) ,
299
- ( "st_birthtime_nsec" , created_nsec. into ( ) ) ,
300
293
( "st_size" , metadata. size . into ( ) ) ,
301
294
( "st_blocks" , 0 ) ,
302
295
( "st_blksize" , 0 ) ,
303
- ( "st_flags" , 0 ) ,
304
- ( "st_gen" , 0 ) ,
305
296
] ,
306
297
& buf,
307
298
) ?;
308
299
300
+ if matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" ) {
301
+ this. write_int_fields_named (
302
+ & [
303
+ ( "st_atime_nsec" , access_nsec. into ( ) ) ,
304
+ ( "st_mtime_nsec" , modified_nsec. into ( ) ) ,
305
+ ( "st_ctime_nsec" , 0 ) ,
306
+ ( "st_birthtime" , created_sec. into ( ) ) ,
307
+ ( "st_birthtime_nsec" , created_nsec. into ( ) ) ,
308
+ ( "st_flags" , 0 ) ,
309
+ ( "st_gen" , 0 ) ,
310
+ ] ,
311
+ & buf,
312
+ ) ?;
313
+ }
314
+
315
+ if matches ! ( & * this. tcx. sess. target. os, "solaris" | "illumos" ) {
316
+ // FIXME: write st_fstype field once libc is updated.
317
+ // https://github.com/rust-lang/libc/pull/4145
318
+ //this.write_int_fields_named(&[("st_fstype", 0)], &buf)?;
319
+ }
320
+
309
321
interp_ok ( 0 )
310
322
}
311
323
@@ -648,15 +660,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
648
660
interp_ok ( Scalar :: from_i32 ( this. try_unwrap_io_result ( result) ?) )
649
661
}
650
662
651
- fn macos_fbsd_stat (
663
+ fn macos_fbsd_solaris_stat (
652
664
& mut self ,
653
665
path_op : & OpTy < ' tcx > ,
654
666
buf_op : & OpTy < ' tcx > ,
655
667
) -> InterpResult < ' tcx , Scalar > {
656
668
let this = self . eval_context_mut ( ) ;
657
669
658
- if !matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" ) {
659
- panic ! ( "`macos_fbsd_stat ` should not be called on {}" , this. tcx. sess. target. os) ;
670
+ if !matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" | "solaris" | "illumos" ) {
671
+ panic ! ( "`macos_fbsd_solaris_stat ` should not be called on {}" , this. tcx. sess. target. os) ;
660
672
}
661
673
662
674
let path_scalar = this. read_pointer ( path_op) ?;
@@ -674,19 +686,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
674
686
Err ( err) => return this. set_last_error_and_return_i32 ( err) ,
675
687
} ;
676
688
677
- interp_ok ( Scalar :: from_i32 ( this. macos_stat_write_buf ( metadata, buf_op) ?) )
689
+ interp_ok ( Scalar :: from_i32 ( this. macos_fbsd_solaris_write_buf ( metadata, buf_op) ?) )
678
690
}
679
691
680
692
// `lstat` is used to get symlink metadata.
681
- fn macos_fbsd_lstat (
693
+ fn macos_fbsd_solaris_lstat (
682
694
& mut self ,
683
695
path_op : & OpTy < ' tcx > ,
684
696
buf_op : & OpTy < ' tcx > ,
685
697
) -> InterpResult < ' tcx , Scalar > {
686
698
let this = self . eval_context_mut ( ) ;
687
699
688
- if !matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" ) {
689
- panic ! ( "`macos_fbsd_lstat` should not be called on {}" , this. tcx. sess. target. os) ;
700
+ if !matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" | "solaris" | "illumos" ) {
701
+ panic ! (
702
+ "`macos_fbsd_solaris_lstat` should not be called on {}" ,
703
+ this. tcx. sess. target. os
704
+ ) ;
690
705
}
691
706
692
707
let path_scalar = this. read_pointer ( path_op) ?;
@@ -703,18 +718,21 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
703
718
Err ( err) => return this. set_last_error_and_return_i32 ( err) ,
704
719
} ;
705
720
706
- interp_ok ( Scalar :: from_i32 ( this. macos_stat_write_buf ( metadata, buf_op) ?) )
721
+ interp_ok ( Scalar :: from_i32 ( this. macos_fbsd_solaris_write_buf ( metadata, buf_op) ?) )
707
722
}
708
723
709
- fn macos_fbsd_fstat (
724
+ fn macos_fbsd_solaris_fstat (
710
725
& mut self ,
711
726
fd_op : & OpTy < ' tcx > ,
712
727
buf_op : & OpTy < ' tcx > ,
713
728
) -> InterpResult < ' tcx , Scalar > {
714
729
let this = self . eval_context_mut ( ) ;
715
730
716
- if !matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" ) {
717
- panic ! ( "`macos_fbsd_fstat` should not be called on {}" , this. tcx. sess. target. os) ;
731
+ if !matches ! ( & * this. tcx. sess. target. os, "macos" | "freebsd" | "solaris" | "illumos" ) {
732
+ panic ! (
733
+ "`macos_fbsd_solaris_fstat` should not be called on {}" ,
734
+ this. tcx. sess. target. os
735
+ ) ;
718
736
}
719
737
720
738
let fd = this. read_scalar ( fd_op) ?. to_i32 ( ) ?;
@@ -730,7 +748,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
730
748
Ok ( metadata) => metadata,
731
749
Err ( err) => return this. set_last_error_and_return_i32 ( err) ,
732
750
} ;
733
- interp_ok ( Scalar :: from_i32 ( this. macos_stat_write_buf ( metadata, buf_op) ?) )
751
+ interp_ok ( Scalar :: from_i32 ( this. macos_fbsd_solaris_write_buf ( metadata, buf_op) ?) )
734
752
}
735
753
736
754
fn linux_statx (
0 commit comments