Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes from suggestion
Browse files Browse the repository at this point in the history
devnexen committed Dec 12, 2024
1 parent f916655 commit 6d9b2bc
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
@@ -1048,7 +1048,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
}

fn linux_solarish_readdir64(&mut self, dirp_op: &OpTy<'tcx>) -> InterpResult<'tcx, Scalar> {
fn linux_solarish_readdir64(
&mut self,
dirent_type: &str,
dirp_op: &OpTy<'tcx>,
) -> InterpResult<'tcx, Scalar> {
let this = self.eval_context_mut();

if !matches!(&*this.tcx.sess.target.os, "linux" | "solaris" | "illumos") {
@@ -1097,7 +1101,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let name_bytes = name.as_encoded_bytes();
let name_len = u64::try_from(name_bytes.len()).unwrap();

let dirent_layout = this.libc_ty_layout("dirent");
let dirent_layout = this.libc_ty_layout(dirent_type);
let fields = &dirent_layout.fields;
let last_field = fields.count().strict_sub(1);
let d_name_offset = fields.offset(last_field).bytes();
2 changes: 1 addition & 1 deletion src/shims/unix/linux/foreign_items.rs
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
"readdir64" => {
let [dirp] =
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
let result = this.linux_solarish_readdir64(dirp)?;
let result = this.linux_solarish_readdir64("dirent64", dirp)?;
this.write_scalar(result, dest)?;
}
"sync_file_range" => {
2 changes: 1 addition & 1 deletion src/shims/unix/solarish/foreign_items.rs
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
"readdir" => {
let [dirp] =
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
let result = this.linux_solarish_readdir64(dirp)?;
let result = this.linux_solarish_readdir64("dirent", dirp)?;
this.write_scalar(result, dest)?;
}

0 comments on commit 6d9b2bc

Please sign in to comment.