Skip to content
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

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

devnexen
Copy link
Contributor

@devnexen devnexen commented Nov 12, 2024

part of #3890

@bors
Copy link
Contributor

bors commented Nov 22, 2024

☔ The latest upstream changes (presumably #4049) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@RalfJung RalfJung left a 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?

src/shims/unix/fs.rs Show resolved Hide resolved
@RalfJung
Copy link
Member

RalfJung commented Nov 25, 2024 via email

src/shims/unix/fs.rs Outdated Show resolved Hide resolved
@RalfJung RalfJung added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Nov 25, 2024
Comment on lines 32 to 35
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
test_directory();
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
test_canonicalize();
Copy link
Member

@RalfJung RalfJung Nov 26, 2024

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.

Copy link
Contributor Author

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 ?

Copy link
Member

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"))) { ... }

Copy link
Contributor Author

@devnexen devnexen Nov 26, 2024

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...

Copy link
Member

@RalfJung RalfJung Nov 26, 2024

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 ..

@@ -27,7 +28,10 @@ fn main() {
test_file_sync();
test_errors();
test_rename();
// solarish needs to intercept readdir/readdir64 for these tests.
Copy link
Member

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
Copy link
Member

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.

Comment on lines 315 to 319
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)?;
}
Copy link
Member

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?

@bors
Copy link
Contributor

bors commented Nov 26, 2024

☔ The latest upstream changes (presumably #4016) made this pull request unmergeable. Please resolve the merge conflicts.

@devnexen
Copy link
Contributor Author

broader question would be should we wait the libc crate update or do we keep the missing field as TODO ?

@RalfJung
Copy link
Member

TODO is fine for now.

@devnexen devnexen marked this pull request as ready for review November 26, 2024 13:01
@devnexen
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Nov 26, 2024
Comment on lines 316 to 317
// FIXME: libc crate, update stat struct, as `st_fstype` will be uninitialised
// https://github.com/rust-lang/libc/pull/4145
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rustbot author

Comment on lines 79 to 84
"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)?;
}
Copy link
Member

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.

Copy link
Contributor Author

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.

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Nov 26, 2024
@@ -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)?;
Copy link
Member

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.

Comment on lines 1141 to 1145
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
);
Copy link
Member

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

@RalfJung RalfJung changed the title filesystem support for solarish. filesystem support for solarish: stat Nov 26, 2024
@RalfJung
Copy link
Member

Thanks :)

@RalfJung RalfJung added this pull request to the merge queue Nov 26, 2024
Merged via the queue into rust-lang:master with commit 3125c69 Nov 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: Waiting for the PR author to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants