setfsgid.c 742 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * setfsgid() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.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 <sys/fsuid.h>
  10. #include <bits/wordsize.h>
  11. #if (__WORDSIZE == 32 && defined(__NR_setfsgid32)) || __WORDSIZE == 64
  12. # ifdef __NR_setfsgid32
  13. # undef __NR_setfsgid
  14. # define __NR_setfsgid __NR_setfsgid32
  15. # endif
  16. _syscall1(int, setfsgid, gid_t, gid)
  17. #else
  18. # define __NR___syscall_setfsgid __NR_setfsgid
  19. static __inline__ _syscall1(int, __syscall_setfsgid, __kernel_gid_t, gid)
  20. int setfsgid(gid_t gid)
  21. {
  22. if (gid != (gid_t) ((__kernel_gid_t) gid)) {
  23. __set_errno(EINVAL);
  24. return -1;
  25. }
  26. return (__syscall_setfsgid(gid));
  27. }
  28. #endif