Skip to content

fix(mv): don't panic if apply_xattrs fails#6936

Merged
sylvestre merged 1 commit intouutils:mainfrom
alexs-sh:fix-mv-issue-6727
Dec 9, 2024
Merged

fix(mv): don't panic if apply_xattrs fails#6936
sylvestre merged 1 commit intouutils:mainfrom
alexs-sh:fix-mv-issue-6727

Conversation

@alexs-sh
Copy link
Contributor

@alexs-sh alexs-sh commented Dec 7, 2024

About

This commit fixes #6727 by returning the error status instead of causing a panic. It aligns with the original GNU mv more closely

Before

cargo run -q mv dummy /run/media/user/8EC5-8BC8
thread 'main' panicked at src/uu/mv/src/mv.rs:682:47:
called `Result::unwrap()` on an `Err` value: Os { code: 95, kind: Uncategorized, message: "Operation not supported" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After

cargo run -q mv dummy /run/media/user/8EC5-8BC8
mv: cannot move 'dummy' to '/run/media/user/8EC5-8BC8/dummy': Operation not supported

GNU mv

mv dummy /run/media/user/8EC5-8BC8
mv: preserving permissions for ‘/run/media/user/8EC5-8BC8/dummy’: Operation not supported

Testing environment

  • ArchLinux
  • rustc 1.83.0 (90b35a623 2024-11-26)
  • Destination filesystem is FAT32

Commands for preparing a directory with xattrs

mkdir -p dummy/1
setfacl -m u:user:r dummy

Thank you

This commit fixes issue uutils#6727 by returning the error status instead of
causing a panic. It aligns with the original GNU mv more closely.
@sylvestre
Copy link
Contributor

Could you please add a test to make sure we don't regress? Thanks

@alexs-sh
Copy link
Contributor Author

alexs-sh commented Dec 7, 2024

@sylvestre Thx.

I thought about adding a test. However, it seems we have a problem here.

The most reliable way to reproduce the issue is by moving the directory to a filesystem that does not support xattrs. But this requires mounting the filesystem first, which requires root privileges. Running or requiring tests with root privileges seems like a very questionable approach.

dd if=/dev/zero of=fs bs=1M count=32
mkfs.vfat fs
mkdir dst
sudo mount fs dst #<--problem 

Possibly, I overlooked something. If you have any ideas, please let me know.

@sylvestre
Copy link
Contributor

ok, it is good enough then :)
thanks

@sylvestre sylvestre merged commit bc1bbf3 into uutils:main Dec 9, 2024
@alexs-sh alexs-sh deleted the fix-mv-issue-6727 branch December 14, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mv: shouldn't panic when xattr application fails

2 participants