fchown.c 878 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * fchown() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@codepoet.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <unistd.h>
  10. #include <bits/wordsize.h>
  11. #if (__WORDSIZE == 32 && defined(__NR_fchown32)) || __WORDSIZE == 64
  12. # ifdef __NR_fchown32
  13. # undef __NR_fchown
  14. # define __NR_fchown __NR_fchown32
  15. # endif
  16. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group)
  17. #else
  18. # define __NR___syscall_fchown __NR_fchown
  19. static __inline__ _syscall3(int, __syscall_fchown, int, fd,
  20. __kernel_uid_t, owner, __kernel_gid_t, group)
  21. int fchown(int fd, uid_t owner, gid_t group)
  22. {
  23. if (((owner + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  24. || ((group + 1) > (gid_t) ((__kernel_gid_t) - 1U))) {
  25. __set_errno(EINVAL);
  26. return -1;
  27. }
  28. return (__syscall_fchown(fd, owner, group));
  29. }
  30. #endif