Skip to content

Commit 9894a06

Browse files
authored
Merge pull request rust-lang#4159 from YohDeadfall/write-st-fstype-on-solaris
Set st_fstype of stat on Solaris and Illumos OSes
2 parents 4f8492c + 4a329e9 commit 9894a06

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/tools/miri/src/shims/unix/freebsd/foreign_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
6060
// since freebsd 12 the former form can be expected.
6161
"stat" | "stat@FBSD_1.0" => {
6262
let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
63-
let result = this.macos_fbsd_solaris_stat(path, buf)?;
63+
let result = this.macos_fbsd_solarish_stat(path, buf)?;
6464
this.write_scalar(result, dest)?;
6565
}
6666
"lstat" | "lstat@FBSD_1.0" => {
6767
let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
68-
let result = this.macos_fbsd_solaris_lstat(path, buf)?;
68+
let result = this.macos_fbsd_solarish_lstat(path, buf)?;
6969
this.write_scalar(result, dest)?;
7070
}
7171
"fstat" | "fstat@FBSD_1.0" => {
7272
let [fd, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
73-
let result = this.macos_fbsd_solaris_fstat(fd, buf)?;
73+
let result = this.macos_fbsd_solarish_fstat(fd, buf)?;
7474
this.write_scalar(result, dest)?;
7575
}
7676
"readdir_r" | "readdir_r@FBSD_1.0" => {

src/tools/miri/src/shims/unix/fs.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl UnixFileDescription for FileHandle {
273273

274274
impl<'tcx> EvalContextExtPrivate<'tcx> for crate::MiriInterpCx<'tcx> {}
275275
trait EvalContextExtPrivate<'tcx>: crate::MiriInterpCxExt<'tcx> {
276-
fn macos_fbsd_solaris_write_buf(
276+
fn macos_fbsd_solarish_write_stat_buf(
277277
&mut self,
278278
metadata: FileMetadata,
279279
buf_op: &OpTy<'tcx>,
@@ -321,9 +321,9 @@ trait EvalContextExtPrivate<'tcx>: crate::MiriInterpCxExt<'tcx> {
321321
}
322322

323323
if matches!(&*this.tcx.sess.target.os, "solaris" | "illumos") {
324-
// FIXME: write st_fstype field once libc is updated.
325-
// https://github.com/rust-lang/libc/pull/4145
326-
//this.write_int_fields_named(&[("st_fstype", 0)], &buf)?;
324+
let st_fstype = this.project_field_named(&buf, "st_fstype")?;
325+
// This is an array; write 0 into first element so that it encodes the empty string.
326+
this.write_int(0, &this.project_index(&st_fstype, 0)?)?;
327327
}
328328

329329
interp_ok(0)
@@ -671,7 +671,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
671671
interp_ok(Scalar::from_i32(this.try_unwrap_io_result(result)?))
672672
}
673673

674-
fn macos_fbsd_solaris_stat(
674+
fn macos_fbsd_solarish_stat(
675675
&mut self,
676676
path_op: &OpTy<'tcx>,
677677
buf_op: &OpTy<'tcx>,
@@ -697,11 +697,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
697697
Err(err) => return this.set_last_error_and_return_i32(err),
698698
};
699699

700-
interp_ok(Scalar::from_i32(this.macos_fbsd_solaris_write_buf(metadata, buf_op)?))
700+
interp_ok(Scalar::from_i32(this.macos_fbsd_solarish_write_stat_buf(metadata, buf_op)?))
701701
}
702702

703703
// `lstat` is used to get symlink metadata.
704-
fn macos_fbsd_solaris_lstat(
704+
fn macos_fbsd_solarish_lstat(
705705
&mut self,
706706
path_op: &OpTy<'tcx>,
707707
buf_op: &OpTy<'tcx>,
@@ -729,10 +729,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
729729
Err(err) => return this.set_last_error_and_return_i32(err),
730730
};
731731

732-
interp_ok(Scalar::from_i32(this.macos_fbsd_solaris_write_buf(metadata, buf_op)?))
732+
interp_ok(Scalar::from_i32(this.macos_fbsd_solarish_write_stat_buf(metadata, buf_op)?))
733733
}
734734

735-
fn macos_fbsd_solaris_fstat(
735+
fn macos_fbsd_solarish_fstat(
736736
&mut self,
737737
fd_op: &OpTy<'tcx>,
738738
buf_op: &OpTy<'tcx>,
@@ -759,7 +759,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
759759
Ok(metadata) => metadata,
760760
Err(err) => return this.set_last_error_and_return_i32(err),
761761
};
762-
interp_ok(Scalar::from_i32(this.macos_fbsd_solaris_write_buf(metadata, buf_op)?))
762+
interp_ok(Scalar::from_i32(this.macos_fbsd_solarish_write_stat_buf(metadata, buf_op)?))
763763
}
764764

765765
fn linux_statx(

src/tools/miri/src/shims/unix/macos/foreign_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3939
}
4040
"stat" | "stat64" | "stat$INODE64" => {
4141
let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
42-
let result = this.macos_fbsd_solaris_stat(path, buf)?;
42+
let result = this.macos_fbsd_solarish_stat(path, buf)?;
4343
this.write_scalar(result, dest)?;
4444
}
4545
"lstat" | "lstat64" | "lstat$INODE64" => {
4646
let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
47-
let result = this.macos_fbsd_solaris_lstat(path, buf)?;
47+
let result = this.macos_fbsd_solarish_lstat(path, buf)?;
4848
this.write_scalar(result, dest)?;
4949
}
5050
"fstat" | "fstat64" | "fstat$INODE64" => {
5151
let [fd, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
52-
let result = this.macos_fbsd_solaris_fstat(fd, buf)?;
52+
let result = this.macos_fbsd_solarish_fstat(fd, buf)?;
5353
this.write_scalar(result, dest)?;
5454
}
5555
"opendir$INODE64" => {

src/tools/miri/src/shims/unix/solarish/foreign_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8787
// File related shims
8888
"stat" | "stat64" => {
8989
let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
90-
let result = this.macos_fbsd_solaris_stat(path, buf)?;
90+
let result = this.macos_fbsd_solarish_stat(path, buf)?;
9191
this.write_scalar(result, dest)?;
9292
}
9393
"lstat" | "lstat64" => {
9494
let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
95-
let result = this.macos_fbsd_solaris_lstat(path, buf)?;
95+
let result = this.macos_fbsd_solarish_lstat(path, buf)?;
9696
this.write_scalar(result, dest)?;
9797
}
9898
"fstat" | "fstat64" => {
9999
let [fd, buf] = this.check_shim(abi, Conv::C, link_name, args)?;
100-
let result = this.macos_fbsd_solaris_fstat(fd, buf)?;
100+
let result = this.macos_fbsd_solarish_fstat(fd, buf)?;
101101
this.write_scalar(result, dest)?;
102102
}
103103
"readdir" => {

0 commit comments

Comments
 (0)