7 void __procfdname(char *, unsigned);
9 int fchmodat(int fd, const char *path, mode_t mode, int flag)
11 if (!flag) return syscall(SYS_fchmodat, fd, path, mode, flag);
13 if (flag != AT_SYMLINK_NOFOLLOW)
14 return __syscall_ret(-EINVAL);
18 char proc[15+3*sizeof(int)];
20 if ((ret = __syscall(SYS_fstatat, fd, path, &st, flag)))
21 return __syscall_ret(ret);
22 if (S_ISLNK(st.st_mode))
23 return __syscall_ret(-EOPNOTSUPP);
25 if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY)) < 0) {
27 return __syscall_ret(-EOPNOTSUPP);
28 return __syscall_ret(fd2);
31 __procfdname(proc, fd2);
32 if (!(ret = __syscall(SYS_stat, proc, &st)) && !S_ISLNK(st.st_mode))
33 ret = __syscall(SYS_chmod, proc, mode);
35 __syscall(SYS_close, fd2);
36 return __syscall_ret(ret);