6 int fchmodat(int fd, const char *path, mode_t mode, int flag)
8 if (!flag) return syscall(SYS_fchmodat, fd, path, mode, flag);
10 if (flag != AT_SYMLINK_NOFOLLOW)
11 return __syscall_ret(-EINVAL);
15 char proc[15+3*sizeof(int)];
17 if (fstatat(fd, path, &st, flag))
19 if (S_ISLNK(st.st_mode))
20 return __syscall_ret(-EOPNOTSUPP);
22 if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY|O_CLOEXEC)) < 0) {
24 return __syscall_ret(-EOPNOTSUPP);
25 return __syscall_ret(fd2);
28 __procfdname(proc, fd2);
29 ret = stat(proc, &st);
31 if (S_ISLNK(st.st_mode)) ret = __syscall_ret(-EOPNOTSUPP);
32 else ret = syscall(SYS_fchmodat, AT_FDCWD, proc, mode);
35 __syscall(SYS_close, fd2);