You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4398381
Browse filesBrowse the repository at this point in the historyBrowse files
cp: apply the finalize chmod with a single fchmodat call
The no-follow chmod opened the destination's parent directory to get a
dirfd for every copied entry, which added an openat(2) and a close(2) per
file and directory on top of the chmod itself. On a 341-directory,
3410-file tree, cp -a went from 175055 to 182217 syscalls.
Resolve the whole path against AT_FDCWD instead: fchmodat2/fchmodat with
AT_SYMLINK_NOFOLLOW still refuses to follow a symlink at the final
component, which is the property the change is about, and it costs
exactly the chmod(2) it replaces. The dirfd variant only resolved the
parent immediately before the chmod, so nothing was pinned across the
copy and no protection is lost.
The fchmodat implementation, including the fchmodat2 fast path and the
musl O_PATH fallback, moves to a shared helper used by both
DirFd::chmod_at and the new uucore::safe_traversal::chmod_nofollow.
0 commit comments