-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
rm: improve handling of very deep directories with -r #7324
Comments
Related to #7217 |
Instead of changing current working directory it's usually better to use syscalls like openat() or unlinkat() that can open path relative to a opened directory file descriptor (I expect |
I'm currently working on #7217 and I agree that using I looked to see if I could find a cross-platform implementation of But if it is also an issue for For Unix-like platforms,
I haven't tested this myself yet, but do we also hit the path length errors when calling Whether we also need a Windows implementation or not, if it seems like we have at least two utilities that need Sorry for the huge info dump, I'd love to hear other folks' thoughts on this! |
In |
On Windows the rust standard library will to care of opening long paths so there's no error. That said, an |
In pull request #7304, we added a "quick fix" to support removing very deep directories with
rm -r
. The corresponding test case in GNU coreutils is intests/rm/deep-2.sh
. It would be better to have a more robust solution.The issue is that calling
path.metadata()
on a path that is too long returns anInvalidFilename
error. Instead what we should do is use a relative path name and keep setting the working directory as we recurse. It must be possible becausestd::fs::remove_dir_all(path)
seems to work on the very long path.Originally posted by @jfinkels in #7304 (comment)
The text was updated successfully, but these errors were encountered: