llvm-project
f17893d8 - [libc] Fix chmod syscall arguments and add symlink test (#226144)

Commit
62 days ago
[libc] Fix chmod syscall arguments and add symlink test (#226144) Our Linux chmod wrapper had two bugs in how it invoked syscalls: - the fchmodat syscall only takes three arguments (dfd, filename, mode), but we were passing four (with a trailing 0 for flags). - for fchmodat2, we were (mistakenly) passing AT_SYMLINK_NOFOLLOW, even though chmod is specified to follow symlinks. I reorder the checks to prefer fchmodat2 (with flags=0) if available, and otherwise invoke fchmodat with the three arguments it expects. I also add a test to verify that chmod follows symlinks and updates the target file's permissions, and that attempting to chmod a dangling symlink fails with ENOENT. Assisted-by: Gemini
Author
Parents
Loading