-
Notifications
You must be signed in to change notification settings - Fork 349
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
filesystem support for solarish: stat #4031
Conversation
13b741d
to
ea9eafa
Compare
☔ The latest upstream changes (presumably #4049) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Generally looks good, but it seems that some type is wrong somewhere, judging from CI:
error: Undefined Behavior: scalar size mismatch: expected 2 bytes but got 4 bytes instead
--> /Users/runner/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/pal/unix/fs.rs:1777:22
|
LL | cvt(unsafe { stat64(p.as_ptr(), &mut stat) })?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ scalar size mismatch: expected 2 bytes but got 4 bytes instead
Maybe the mode
has a different size on Solaris than on BSD?
c29a187
to
2f8c45b
Compare
unfortunately, libc crate does not contain it.
In that case please add a comment so that we can remember to add it in the future.
|
d6f67a7
to
7be5a35
Compare
tests/pass/shims/fs.rs
Outdated
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))] | ||
test_directory(); | ||
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))] | ||
test_canonicalize(); |
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.
Please use if cfg!(...)
instead of #[cfg]
, then you can avoid making the imports so messy.
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.
but what would be the condition tough ?
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.
if cfg!(not(any(target_os = "solaris", target_os = "illumos"))) { ... }
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.
but that s the thing, I tried this and the tests are expected to be called still on my illumos instance. would you like a cfg_if ? even tough a bit overkill here...
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.
I tried this and the tests are expected to be called still on my illumos instance.
Please try again and commit the code to the PR. Sounds like there was a mistake somewhere else.
All the #[cfg]
that you added elsewhere in the test should be removed.
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.
ok will give it a go in few hours.
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.
so, yes that was an error on my part indeed :) let s see how it goes ..
tests/pass/shims/fs.rs
Outdated
@@ -27,7 +28,10 @@ fn main() { | |||
test_file_sync(); | |||
test_errors(); | |||
test_rename(); | |||
// solarish needs to intercept readdir/readdir64 for these tests. |
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.
I'd say "support" rather than "intercept"
@@ -82,7 +82,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |||
let result = this.macos_fbsd_solaris_readdir_r(dirp, entry, result)?; | |||
this.write_scalar(result, dest)?; | |||
} | |||
// TODO readdir ? | |||
// TODO readdir/readdir64: for tests fs::test_directory/canonicalize |
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.
Please remove this, open an issue instead.
src/shims/unix/fs.rs
Outdated
if matches!(&*this.tcx.sess.target.os, "solaris" | "illumos") { | ||
let mode: u32 = metadata.mode.to_u32()?; | ||
|
||
// FIXME: libc crate as `st_fstype` will be uninitialised | ||
//this.write_int_fields_named(&[("st_mode", mode.into()), ("st_fstype", 0)], &buf)?; | ||
this.write_int_fields_named(&[("st_mode", mode.into())], &buf)?; | ||
} else { | ||
let mode: u16 = metadata.mode.to_u16()?; | ||
|
||
this.write_int_fields_named(&[("st_mode", mode.into())], &buf)?; | ||
} |
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.
Why is this code still there?
☔ The latest upstream changes (presumably #4016) made this pull request unmergeable. Please resolve the merge conflicts. |
7be5a35
to
0c40776
Compare
broader question would be should we wait the libc crate update or do we keep the missing field as TODO ? |
TODO is fine for now. |
1923269
to
bccec41
Compare
@rustbot ready |
src/shims/unix/fs.rs
Outdated
// FIXME: libc crate, update stat struct, as `st_fstype` will be uninitialised | ||
// https://github.com/rust-lang/libc/pull/4145 |
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.
// FIXME: libc crate, update stat struct, as `st_fstype` will be uninitialised | |
// https://github.com/rust-lang/libc/pull/4145 | |
// FIXME: write st_fstype field once libc is updated | |
// https://github.com/rust-lang/libc/pull/4145 |
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.
@rustbot author
"readdir_r" => { | ||
let [dirp, entry, result] = | ||
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?; | ||
let result = this.macos_fbsd_solaris_readdir_r(dirp, entry, result)?; | ||
this.write_scalar(result, dest)?; | ||
} |
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.
I am confused -- why is readdir implemented now?
Please don't add untested code. If it "just works" without any other changes, enable the test, otherwise remove the implementation.
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.
I did not add readdir**_r** it had been there since in the early phase. Anyhow, I do not need it at all for now.
bccec41
to
fc819a4
Compare
@@ -64,7 +64,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |||
"readdir_r" | "readdir_r$INODE64" => { | |||
let [dirp, entry, result] = | |||
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?; | |||
let result = this.macos_fbsd_readdir_r(dirp, entry, result)?; | |||
let result = this.macos_fbsd_solaris_readdir_r(dirp, entry, result)?; |
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.
Please also un-do this rename then.
src/shims/unix/fs.rs
Outdated
if !matches!(&*this.tcx.sess.target.os, "macos" | "freebsd" | "solaris" | "illumos") { | ||
panic!( | ||
"`macos_fbsd_solaris_readdir_r` should not be called on {}", | ||
this.tcx.sess.target.os | ||
); |
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.
and undo this as well
fc819a4
to
d49b20c
Compare
Thanks :) |
part of #3890