chmod: Don't treat unnamed symlinks as errors

chmod ignore symlinks if they are not explicitly listed in the input
files. With this commit we don't consider non-listed symlinks as an
error anymore.

This behavior is not specified by POSIX, but if we trust a libcxx
comment, only AIX is returning an error in this case. So this aligns us
with other UNIXs.

This functionality is used by libcxx's test suite harness. Changing this
behavior makes us pass ~40 more tests in the input.output/filesystems
folder.
This commit is contained in:
Lucas Chollet authored and Sönke Holz committed 2026-08-23 12:36:39 +02:00
1 parent b7b8874f54
commit b6aad29331
1 file changed
+1 -1
+1 -1
View File
@@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (S_ISLNK(stat.st_mode)) {
// Symlinks don't get processed unless they are explicitly listed on the command line.
if (!paths.contains_slow(path))
return false;
return true;
// The chmod syscall changes the file that a link points to, so we will have to get
// the correct mode to base our modifications on.