fchmod.c 427 B

12345678910111213141516171819
  1. #include <sys/stat.h>
  2. #include <errno.h>
  3. #include <fcntl.h>
  4. #include "syscall.h"
  5. int fchmod(int fd, mode_t mode)
  6. {
  7. int ret = __syscall(SYS_fchmod, fd, mode);
  8. if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0)
  9. return __syscall_ret(ret);
  10. char buf[15+3*sizeof(int)];
  11. __procfdname(buf, fd);
  12. #ifdef SYS_chmod
  13. return syscall(SYS_chmod, buf, mode);
  14. #else
  15. return syscall(SYS_fchmodat, AT_FDCWD, buf, mode);
  16. #endif
  17. }