-
Notifications
You must be signed in to change notification settings - Fork 414
feat: Support fstat in linux
#4714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,7 @@ impl UnixFileDescription for FileHandle { | |
|
|
||
| impl<'tcx> EvalContextExtPrivate<'tcx> for crate::MiriInterpCx<'tcx> {} | ||
| trait EvalContextExtPrivate<'tcx>: crate::MiriInterpCxExt<'tcx> { | ||
| fn macos_fbsd_solarish_write_stat_buf( | ||
hulxv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fn write_stat_buf( | ||
| &mut self, | ||
| metadata: FileMetadata, | ||
| buf_op: &OpTy<'tcx>, | ||
|
|
@@ -141,8 +141,11 @@ trait EvalContextExtPrivate<'tcx>: crate::MiriInterpCxExt<'tcx> { | |
| ("st_gid", metadata.gid.into()), | ||
| ("st_rdev", 0), | ||
| ("st_atime", access_sec.into()), | ||
| ("st_atime_nsec", access_nsec.into()), | ||
| ("st_mtime", modified_sec.into()), | ||
| ("st_mtime_nsec", modified_nsec.into()), | ||
| ("st_ctime", 0), | ||
| ("st_ctime_nsec", 0), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are now writing these fields twice on macos and freebsd. |
||
| ("st_size", metadata.size.into()), | ||
| ("st_blocks", 0), | ||
| ("st_blksize", 0), | ||
|
|
@@ -550,7 +553,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |
| Err(err) => return this.set_last_error_and_return_i32(err), | ||
| }; | ||
|
|
||
| interp_ok(Scalar::from_i32(this.macos_fbsd_solarish_write_stat_buf(metadata, buf_op)?)) | ||
| interp_ok(Scalar::from_i32(this.write_stat_buf(metadata, buf_op)?)) | ||
| } | ||
|
|
||
| // `lstat` is used to get symlink metadata. | ||
|
|
@@ -583,22 +586,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |
| Err(err) => return this.set_last_error_and_return_i32(err), | ||
| }; | ||
|
|
||
| interp_ok(Scalar::from_i32(this.macos_fbsd_solarish_write_stat_buf(metadata, buf_op)?)) | ||
| interp_ok(Scalar::from_i32(this.write_stat_buf(metadata, buf_op)?)) | ||
| } | ||
|
|
||
| fn macos_fbsd_solarish_fstat( | ||
| &mut self, | ||
| fd_op: &OpTy<'tcx>, | ||
| buf_op: &OpTy<'tcx>, | ||
| ) -> InterpResult<'tcx, Scalar> { | ||
| fn fstat(&mut self, fd_op: &OpTy<'tcx>, buf_op: &OpTy<'tcx>) -> InterpResult<'tcx, Scalar> { | ||
| let this = self.eval_context_mut(); | ||
|
|
||
| if !matches!(&this.tcx.sess.target.os, Os::MacOs | Os::FreeBsd | Os::Solaris | Os::Illumos) | ||
| { | ||
| panic!( | ||
| "`macos_fbsd_solaris_fstat` should not be called on {}", | ||
| this.tcx.sess.target.os | ||
| ); | ||
| if !matches!( | ||
| &this.tcx.sess.target.os, | ||
| Os::MacOs | Os::FreeBsd | Os::Solaris | Os::Illumos | Os::Linux | ||
| ) { | ||
| panic!("`fstat` should not be called on {}", this.tcx.sess.target.os); | ||
| } | ||
|
|
||
| let fd = this.read_scalar(fd_op)?.to_i32()?; | ||
|
|
@@ -614,7 +612,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |
| Ok(metadata) => metadata, | ||
| Err(err) => return this.set_last_error_and_return_i32(err), | ||
| }; | ||
| interp_ok(Scalar::from_i32(this.macos_fbsd_solarish_write_stat_buf(metadata, buf_op)?)) | ||
| interp_ok(Scalar::from_i32(this.write_stat_buf(metadata, buf_op)?)) | ||
| } | ||
|
|
||
| fn linux_statx( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |
| let result = this.linux_statx(dirfd, pathname, flags, mask, statxbuf)?; | ||
| this.write_scalar(result, dest)?; | ||
| } | ||
|
|
||
| "fstat" => { | ||
| let [fd, buf] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; | ||
| let result = this.fstat(fd, buf)?; | ||
| this.write_scalar(result, dest)?; | ||
| } | ||
|
Comment on lines
+56
to
+60
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As explained in the issue, this should be moved into
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to remove them from other unixes but it seems all of them are under different names
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You didn't yet add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, if we are fstat64 we should probably use the stat64 type, not the stat type... but somehow this worked before? Not entirely sure what is happening. This might be related to the freebsd test failure. |
||
| // epoll, eventfd | ||
| "epoll_create1" => { | ||
| let [flag] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,7 +102,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |
| } | ||
| "fstat" | "fstat64" => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I have already said twice, this match arm should be removed now. Please make sure you understand my comments before marking the PR as ready, and ask if anything is unclear. Do not just guess and update the PR. Only mark it as ready once you are confident everything is ready. It's a lot of extra work for me if I have to keep re-checking and repeating everything I already said. |
||
| let [fd, buf] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; | ||
| let result = this.macos_fbsd_solarish_fstat(fd, buf)?; | ||
| let result = this.fstat(fd, buf)?; | ||
| this.write_scalar(result, dest)?; | ||
| } | ||
| "readdir" => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As elsewhere, the "fstat" case should be removed here, since it is already handled in the "unix" handler now.