Browse Source

use new SYS_fchmodat2 syscall to implement fchmodat with flags

commit 0dc4824479e357a3e23a02d35527e23fca920343 worked around for lack
of flags argument in syscall for fchmodat.

linux 6.6 introduced a new syscall, SYS_fchmodat2, fixing this
deficiency. use it if any flags are passed, and fallback to the old
strategy on ENOSYS. continue using the old syscall when there are no
flags. this is the exact same strategy used when SYS_faccessat2 was used
to implement faccessat with flags.
Gaël PORTAY 1 năm trước cách đây
mục cha
commit
d0ed307e6f
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      src/stat/fchmodat.c

+ 4 - 1
src/stat/fchmodat.c

@@ -7,11 +7,14 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag)
 {
 	if (!flag) return syscall(SYS_fchmodat, fd, path, mode);
 
+	int ret = __syscall(SYS_fchmodat2, fd, path, mode, flag);
+	if (ret != -ENOSYS) return __syscall_ret(ret);
+
 	if (flag != AT_SYMLINK_NOFOLLOW)
 		return __syscall_ret(-EINVAL);
 
 	struct stat st;
-	int ret, fd2;
+	int fd2;
 	char proc[15+3*sizeof(int)];
 
 	if (fstatat(fd, path, &st, flag))