fchmodat.c 855 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * fchmodat() for uClibc
  3. *
  4. * Copyright (C) 2009 Analog Devices Inc.
  5. * Copyright (C) 2012 Mike Frysinger
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <fcntl.h>
  10. #include <sys/syscall.h>
  11. #include <sys/stat.h>
  12. #ifdef __NR_fchmodat
  13. /*
  14. * The kernel takes 3 args, but userland takes 4.
  15. * We have to process all the flags ourselves.
  16. */
  17. int fchmodat(int fd, const char *file, mode_t mode, int flag)
  18. {
  19. /* We only support one flag atm ... */
  20. if (flag & ~AT_SYMLINK_NOFOLLOW) {
  21. __set_errno(EINVAL);
  22. return -1;
  23. }
  24. /* ... but Linux doesn't support perms on symlinks. */
  25. if (flag & AT_SYMLINK_NOFOLLOW) {
  26. __set_errno(ENOTSUP);
  27. return -1;
  28. }
  29. return INLINE_SYSCALL(fchmodat, 3, fd, file, mode);
  30. }
  31. libc_hidden_def(fchmodat)
  32. #else
  33. /* should add emulation with fchmod() and /proc/self/fd/ ... */
  34. #endif