-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
UNIX remove_dir_all()
: Try recursing first on the slow path
#94446
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
5128a57
to
1c1ed44
Compare
1c1ed44
to
70ea2f0
Compare
Even with NFS to a server OS that does allow unlinking a directory? |
According to the man pages it is guaranteed in deviation from the standard POSIX text and other UNIX man pages. I will look into the kernel sources. |
740f683
to
6ec0fad
Compare
remove_dir_all()
: Only unlink first if it is guaranteed to error for directoriesremove_dir_all()
: Try recursing first on the slow path
After glossing over the NFSv3/v4 specs it is clear that the OS cannot guarantee that if |
r? @cuviper |
da1a6cd
to
c654255
Compare
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.
Looks good, r=me
after squashing.
This only affects the `slow` code path, if there is no `dirent.d_type` or if the type is `DT_UNKNOWN`. POSIX specifies that calling `unlink()` or `unlinkat(..., 0)` on a directory can succeed: > "The _path_ argument shall not name a directory unless the process has > appropriate privileges and the implementation supports using _unlink()_ on > directories." This however can cause orphaned directories requiring an fsck e.g. on Illumos UFS, so we have to avoid that in the common case. We now just try to recurse into it first and unlink() if we can't open it as a directory.
c654255
to
5ac2345
Compare
5ac2345
to
735f60c
Compare
@cuviper Squashed and reworded the macos-impl. commit messages. |
@bors r+ |
📌 Commit 735f60c has been approved by |
…fix, r=cuviper UNIX `remove_dir_all()`: Try recursing first on the slow path This only affects the _slow_ code path - if there is no `dirent.d_type` or if it is `DT_UNKNOWN`. POSIX specifies that calling `unlink()` or `unlinkat(..., 0)` on a directory is allowed to succeed: > The _path_ argument shall not name a directory unless the process has appropriate privileges and the implementation supports using _unlink()_ on directories. This however can cause dangling inodes requiring an fsck e.g. on Illumos UFS, so we have to avoid that in the common case. We now just try to recurse into it first and unlink() if we can't open it as a directory. The other two commits integrate the Macos x86-64 implementation reducing redundancy. Split into two commits for better reviewing. Fixes rust-lang#94335.
Rollup of 6 pull requests Successful merges: - rust-lang#94446 (UNIX `remove_dir_all()`: Try recursing first on the slow path) - rust-lang#94460 (Reenable generator drop tracking tests and fix mutation handling) - rust-lang#94620 (Edit docs on consistency of `PartialOrd` and `PartialEq`) - rust-lang#94624 (Downgrade `#[test]` on macro call to warning) - rust-lang#94626 (Add known-bug directive to issue rust-lang#47511 test case) - rust-lang#94631 (Fix typo in c-variadic) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This only affects the slow code path - if there is no
dirent.d_type
or if it isDT_UNKNOWN
.POSIX specifies that calling
unlink()
orunlinkat(..., 0)
on a directory is allowed to succeed:This however can cause dangling inodes requiring an fsck e.g. on Illumos UFS, so we have to avoid that in the common case. We now just try to recurse into it first and unlink() if we can't open it as a directory.
The other two commits integrate the Macos x86-64 implementation reducing redundancy. Split into two commits for better reviewing.
Fixes #94335.