I wrote: > But what I observe is that the behaviour is the same on all major file > systems on Linux. > > Tested on Linux 5.3.7 (fc31), with the trivial program below, on > - ext4 > - btrfs > - jfs > - reiserfs > - xfs
This are different when using the code which goes through the /proc file system: =============================================================================== #define _GNU_SOURCE 1 #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> int main (int argc, char *argv[]) { int mode = strtol (argv[1], NULL, 8); char* path = argv[2]; int ret; int fd = openat (AT_FDCWD, path, O_PATH | O_NOFOLLOW | O_CLOEXEC); if (fd < 0) ret = -1; else { char buf[100]; sprintf (buf, "/proc/self/fd/%d", fd); ret = chmod (buf, mode); } if (ret < 0) perror ("lchmod"); } =============================================================================== In this case: - On ext4, btrfs, jfs, xfs: mode changed, but error "Operation not supported". - On reiserfs: mode changed, success.