mknod: replace nix::sys::stat with rustix #12321
<!-- gnu-comment-bot -->
GNU testsuite comparison:
Congrats! The gnu test tests/shred/shred-remove is no longer failing!
I don't like including crate name at here.
Would you use let _ = writeln!(io::stderr(), *) to avoid SIGABRT with 2>/dev/full?
<!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
Merging this PR will not alter performance
<details>
<summary><b>1 warning, 1 note</b></summary>
:warning: 123 benchmarks are dominated by system calls
> System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
> Learn more about system calls
> See affected benchmarks
:information_source: 1 benchmark has no flamegraph
> The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.
> See affected benchmarks
</details>
✅ 405 untouched benchmarks ⏩ 70 skipped benchmarks[^skipped]
---
<sub>Comparing <code>mattsu2020:mknod_rustix</code> (85eb326) with <code>main</code> (630890c)[^unexpected-base]</sub>
<a href="https://app.codspeed.io/uutils/coreutils/branches/mattsu2020%3Amknod_rustix?utm_source=github&utm_medium=comment-v2&utm_content=button">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
<img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
</picture>
</a>
[^skipped]: 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.
[^unexpected-base]: No successful run was found on <code>main</code> (108e87b) during the generation of this report, so 630890c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
We will introduce sort check of toml keys soon.
mkfifo is subset of mknod. So it should be able to remake existing mkfifo wrapper without unsafe by this one.
fix it
fix it
mkfifois subset ofmknod. So it should be able to remake existingmkfifowrapper without unsafe by this one.
Thanks for the suggestion! You're right
mkfifo is essentially mknod with S_IFIFO and dev=0, so the do_mknod helper could be reused there to eliminate the nix dependency and unsafe as well.
Is it able to open a PR on rustix to support rustix::fs::mk*at on macOS?
I have no access on macOS now...
Is it able to open a PR on rustix to support rustix::fs::mk*at on macOS? I have no access on macOS now...
I created the PR, but there are some errors on the Rustix side during CI, so I'll review the code again once the fixes are complete.
https://github.com/bytecodealliance/rustix/pull/1625
Thankyou
Compiles successfully on Redox:
cargo check -q -p uu_mknod --target x86_64-unknown-redox
@mattsu2020 Please convert to draft and test with Cargo patch for upstream (will need to cargo update rustix):
[patch.crates-io]
rustix = { git = "https://github.com/mattsu2020/rustix.git", branch = "mknodat_macos" }
https://github.com/uutils/coreutils/issues/14908
Due to the issue above, testing cannot be performed on Windows.
@mattsu2020 https://github.com/uutils/coreutils/issues/14908 was resolved, please remove merge commits and rebase.
@mattsu2020 Please add Depends on https://github.com/bytecodealliance/rustix/pull/1625 to the PR description, and edit to include only important information.
If we drop nix, as RustixFileType is innecessary.
- Add tests for mknod permissions and umask handling.
Unrelated change. Please split PR.
thanks.
The code is much cleaner now.
I moved it to a separate PR.
rustix::fs::FileType has additional variants that we don't currently handle. This change could expose us to unexpected behavior when encountering those variants through the public API.
I see, so we need to set some restrictions.
I've added restrictions at the entry point.
mknod isn't the entry point, so the change is still not correct.
thanks for working on this!
This can't land while it depends on a rustix git rev. Please keep it in draft until a rustix release ships the change and bump the version instead, which should also fix the red CI.
Please also rebase without the merge commit and squash everything into one commit.
Can we use cargo vendor? But it might difficult to audit copied src.
This can't land while it depends on a rustix git rev.
We should ensure git sources fail CI: https://github.com/uutils/coreutils/pull/16366.
oech3
mattsu2020
Replace
nix::sys::statinmknodwithrustix::fsand remove the directnixdependency.Depends on https://github.com/bytecodealliance/rustix/pull/1625.
Additional FIFO tests are split into #16348.