Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

rm: Implement --one-file-system and --preserve-root=all#7569

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
shskwmt wants to merge9 commits intouutils:main
base:main
Choose a base branch
Loading
fromshskwmt:rm-one-file-system

Conversation

shskwmt
Copy link
Contributor

@shskwmtshskwmt commentedMar 25, 2025
edited by cakebaker
Loading

Fixes#7011

Implement--one-file-system and--preserve-root=all options for therm command.

Comment on lines 565 to 580
match validate_single_filesystem(path) {
Ok(()) => true,
Err(additional_reason) => {
if !additional_reason.is_empty() {
show_error!("{}", additional_reason);
}
show_error!(
"skipping {}, since it's on a different device",
path.quote()
);
if options.preserve_root == PreserveRoot::YesAll {
show_error!("and --preserve-root=all is in effect");
}
false
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can probably be simplified with something like:

Suggested change
matchvalidate_single_filesystem(path){
Ok(()) =>true,
Err(additional_reason) =>{
if !additional_reason.is_empty(){
show_error!("{}", additional_reason);
}
show_error!(
"skipping {}, since it's on a different device",
path.quote()
);
if options.preserve_root ==PreserveRoot::YesAll{
show_error!("and --preserve-root=all is in effect");
}
false
}
}
let result =validate_single_filesystem(path);
if result.is_ok(){
returntrue;
}
ifletErr(additional_reason) = result{
if !additional_reason.is_empty(){
show_error!("{}", additional_reason);
}
}
show_error!(
"skipping {}, since it's on a different device",
path.quote()
);
if options.preserve_root ==PreserveRoot::YesAll{
show_error!("and --preserve-root=all is in effect");
}
false

shskwmt reacted with heart emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thank you for pointing that out! I've implemented the suggested simplification.

c091369

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

some jobs are failing :)

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

does
bash -v util/run-gnu-test.sh tests/rm/one-file-system.sh
passes on your system ?

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

@shskwmt
Copy link
ContributorAuthor

The following is the test result. It has passed.

PASS: tests/rm/one-file-system.sh============================================================================Testsuite summary for GNU coreutils 9.6-dirty============================================================================# TOTAL: 1# PASS:  1# SKIP:  0# XFAIL: 0# FAIL:  0# XPASS: 0# ERROR: 0============================================================================

@shskwmt
Copy link
ContributorAuthor

I tried again and it failed, so I will fix it.

FAIL: tests/rm/one-file-system==============================--- exp 2025-03-31 00:11:32.336030079 +0900+++ out 2025-03-31 00:11:32.336030079 +0900@@ -1 +1 @@-rm: skipping 'a', since it's on a different device+rm: cannot remove 'a/b': Device or resource busyFAIL tests/rm/one-file-system.sh (exit status: 1)============================================================================Testsuite summary for GNU coreutils 9.6-dirty============================================================================# TOTAL: 1# PASS:  0# SKIP:  0# XFAIL: 0# FAIL:  1# XPASS: 0# ERROR: 0============================================================================See ./tests/test-suite.log for debugging.Some test(s) failed.  Please report this to bug-coreutils@gnu.org,together with the test-suite.log file (gzipped) and your systeminformation.  Thanks.============================================================================

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/chgrp/default-no-deref. tests/chgrp/default-no-deref is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/chgrp/recurse. tests/chgrp/recurse is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/chmod/thru-dangling. tests/chmod/thru-dangling is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/chown/deref. tests/chown/deref is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/chown/preserve-root. tests/chown/preserve-root is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/abuse. tests/cp/abuse is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/attr-existing. tests/cp/attr-existing is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/cp-HL. tests/cp/cp-HL is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/cross-dev-symlink. tests/cp/cross-dev-symlink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/keep-directory-symlink. tests/cp/keep-directory-symlink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/link-deref. tests/cp/link-deref is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/link-no-deref. tests/cp/link-no-deref is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/link-preserve. tests/cp/link-preserve is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/link-symlink. tests/cp/link-symlink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/no-deref-link1. tests/cp/no-deref-link1 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/no-deref-link2. tests/cp/no-deref-link2 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/no-deref-link3. tests/cp/no-deref-link3 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/preserve-slink-time. tests/cp/preserve-slink-time is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/r-vs-symlink. tests/cp/r-vs-symlink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/same-file. tests/cp/same-file is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/slink-2-slink. tests/cp/slink-2-slink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/cp/thru-dangling. tests/cp/thru-dangling is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/dd/misc. tests/dd/misc is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/du/deref. tests/du/deref is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/du/deref-args. tests/du/deref-args is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/du/long-sloop. tests/du/long-sloop is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/du/no-deref. tests/du/no-deref is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/du/one-file-system. tests/du/one-file-system is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/du/trailing-slash. tests/du/trailing-slash is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/env/env. tests/env/env is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ln/hard-to-sym. tests/ln/hard-to-sym is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ln/relative. tests/ln/relative is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ln/sf-1. tests/ln/sf-1 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ln/target-1. tests/ln/target-1 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/classify. tests/ls/classify is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/dangle. tests/ls/dangle is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/dired. tests/ls/dired is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/file-type. tests/ls/file-type is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/follow-slink. tests/ls/follow-slink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/group-dirs. tests/ls/group-dirs is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/hyperlink. tests/ls/hyperlink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/no-arg. tests/ls/no-arg is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/selinux-segfault. tests/ls/selinux-segfault is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/slink-acl. tests/ls/slink-acl is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/stat-dtype. tests/ls/stat-dtype is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/stat-failed. tests/ls/stat-failed is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/stat-free-color. tests/ls/stat-free-color is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/symlink-loop. tests/ls/symlink-loop is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/ls/symlink-quote. tests/ls/symlink-quote is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/misc/realpath. tests/misc/realpath is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/mv/atomic. tests/mv/atomic is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/mv/part-symlink. tests/mv/part-symlink is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/mv/symlink-onto-hardlink-to-self. tests/mv/symlink-onto-hardlink-to-self is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/pwd/pwd-option. tests/pwd/pwd-option is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/can-e. tests/readlink/can-e is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/can-f. tests/readlink/can-f is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/can-m. tests/readlink/can-m is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/multi. tests/readlink/multi is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/readlink-fp-loop. tests/readlink/readlink-fp-loop is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/readlink-root. tests/readlink/readlink-root is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/readlink/rl-1. tests/readlink/rl-1 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/rm/ext3-perf. tests/rm/ext3-perf is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/rm/fail-eacces. tests/rm/fail-eacces is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/rm/rm2. tests/rm/rm2 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/rm/rm3. tests/rm/rm3 is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/rmdir/symlink-errors. tests/rmdir/symlink-errors is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/stat/stat-slash. tests/stat/stat-slash is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/touch/no-dereference. tests/touch/no-dereference is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/touch/trailing-slash. tests/touch/trailing-slash is passing on 'main'. Maybe you have to rebase?GNU test failed: tests/truncate/truncate-dangling-symlink. tests/truncate/truncate-dangling-symlink is passing on 'main'. Maybe you have to rebase?Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)Congrats! The gnu test tests/rm/one-file-system is no longer failing!

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)Congrats! The gnu test tests/rm/one-file-system is no longer failing!

@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)Congrats! The gnu test tests/rm/one-file-system is no longer failing!

@sylvestre
Copy link
Contributor

Sorry, i think i made a mistake with the conflict resolution :( could you please fix it? thanks

@shskwmt
Copy link
ContributorAuthor

No warries, I'll fix it.
Thanks for reaching out!

- Implement --one-file-system option logic- Add mount point detection and filesystem validation- Create helper functions to check and validate filesystem boundaries- Prevent recursive removal across different filesystem devices
- Add PreserveRoot enum to replace boolean preserve_root option- Extend preserve-root functionality with 'all' and 'no' modes- Update preserve-root option parsing- Remove TODO comment for one-file-system implementation
- Restructured the function to separate result handling and error reporting- Fixed a typo in the comment ("neigher" -> "neither")- Simplified the match statement with a more linear control flow
- Update test_rm_one_file_system and test_rm_preserve_root to use relative paths (fs.img, fs) instead of hardcoded /tmp paths.- Enhance cleanup logic by ensuring all temporary files and directories, including mount points, are removed after tests.
- Set `mount_dir` in Windows- Modify the `new` function of the `Filesystem` accordingly to reflect these changes
- Eliminated unnecessary `PathBuf` import in `features/fsext.rs`.- Replaced `unwrap_or(PathBuf::new())` with the more idiomatic `unwrap_or_default()`.
- Removed platform-specific branching for the `delay` variable- Increased delay time to address insufficient wait periods during test execution
- Rename `validate_single_filesystem` to `check_one_fs` for improved clarity and alignment with its functionality.- Refactore `check_one_fs` to directly handle options such as `--one-file-system` and `--preserve-root=all` and return detailed error messages when the conditions are not met.- Integrate `check_one_fs` into `remove_dir_recursive` and `handle_dir` for consistent handling of files and directories on different file systems.
- Reorder the call to `check_one_fs` within `remove_dir_recursive` for better structure and logical flow.- Update comment descriptions to match the new sequence of operations.
@github-actionsGitHub Actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)Congrats! The gnu test tests/rm/one-file-system is no longer failing!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sylvestresylvestresylvestre left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

rm --one-file-system should fail wihrm: skipping 'a/b', since it's on a different device
2 participants
@shskwmt@sylvestre

[8]ページ先頭

©2009-2025 Movatter.jp