cp: better permissions mode handling with umask awareness#10904
cp: better permissions mode handling with umask awareness#10904my4ng wants to merge 6 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
|
Is there any way to split this PR up into something smaller? When its this big it gets pretty hard to review |
|
I'm afraid not. Most changes are actually from the noise of propagating There is a GNU test regression: tests/cp/cp-parents, caused by the second to last test in that file due to created parent dir not having attributes set correctly. Will fix soon. |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Merging this PR will improve performance by 50.52%
Performance Changes
Comparing Footnotes
|
|
There are some residual problems with |
|
GNU testsuite comparison: |
Fix CI-failing checks.
|
@ChrisDryden I have condensed the tests into two instead of the original 12, so it should be a lot more workable now. |
|
GNU testsuite comparison: |
Fix #9750, #10011, #10787, #10862, Supersede #10859.
This PR reworks the permissions mode handling such that its behaviour is in line with GNU's implementation. Specifically:
set umask to !0o077, which means (1) cp can actually create and work with new directories/files which will have 700 permissions mode before their final calculated mode is set. the original umask is kept and passed around for calculation in the case of newly created and non-mode-preserving dir/files. umask is restored to original on exit.
for explicit non-mode-preserving, newly created dir/files, use 777 and 666 modes for calculation respectively.
for existing dir/files, leave existing mode unchanged except when preserving mode.
for newly created dir/files, always set their permission mode to the correct one.
added 12 new tests for the combination of existing/not-existing, no-preserve/default/preserve, dir/fileone each for directory and file with rstest.improve performance by eliminating redundant heap allocations (e.g. PathBuf, String), ~25% from benchmark.