Repository navigation
mv: recreate special files in directories moved across devices - #15123
abendrothj wants to merge 4 commits into
Conversation
|
GNU testsuite comparison: |
Merging this PR will improve performance by 4.24%1 warning, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
60d24ea to
5b7ce0f
Compare
5b7ce0f to
7ffe3a7
Compare
Move the temporary name and renameat logic of replace_link into DirFd::replace_entry_at, which creates the entry through a callback relative to the directory, so other callers can replace entries the same way. The parent is now opened with DirFd::open_anchor, so ln -sf and cp -sf replacing an entry in a directory with write and search but no read permission work, as they do with GNU, instead of failing with EACCES.
Create fifos, sockets and device nodes relative to an open directory. nix and rustix do not provide mknodat on Apple targets, so this calls libc directly.
7ffe3a7 to
a9dc76d
Compare
A cross-device move of a socket or device node went through the regular file copy, which removed the destination and then failed to open the source. A fifo also removed the destination before creating the new one, and lost its mode. Fifos, sockets and device nodes are now created with their mode and ownership in a private directory next to the destination and renamed over it, so the destination is kept if the node cannot be created, and the ownership and mode cannot land on another file linked over the destination name meanwhile. The private directory is made 0700 by name right after it is created, before it is opened, without changing the umask; the check after the open rejects a directory moved there in between. As for regular files, setuid and setgid are dropped when the ownership cannot be kept. Fixes uutils#13145
Sockets and device nodes inside a directory moved across devices went through the regular file copy, which cannot open them, so the move failed. Fifos were recreated with mode 0666 minus the umask. Recreate all of them with copy_special_file, which keeps the mode.
a9dc76d to
7334d83
Compare
Based on #13334; only the last commit is new here (+38/−6).
Sockets and device nodes inside a directory moved across devices went through the regular file copy, which can't open them, so the move failed. FIFOs were recreated with mode 0666 minus the umask. All of them now go through
copy_special_file, which keeps the mode. Run on macOS and Linux. On Debian GNU/Hurd the mv tests fail only where main does (the new ones are Linux-only), and a cross-device move of a 0640 FIFO, alone or in a directory, keeps its mode as with GNU 9.10. AIX is only cross-checked with clippy.Closes #15113
Related to #13145