setresgid.c 978 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * setresgid() 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. #ifdef __USE_GNU
  10. #include <unistd.h>
  11. #if defined(__NR_setresgid32)
  12. # undef __NR_setresgid
  13. # define __NR_setresgid __NR_setresgid32
  14. _syscall3(int, setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
  15. libc_hidden_weak(setresgid)
  16. #elif defined(__NR_setresgid)
  17. # define __NR___syscall_setresgid __NR_setresgid
  18. static __inline__ _syscall3(int, __syscall_setresgid,
  19. __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid)
  20. int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
  21. {
  22. if (((rgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
  23. || ((egid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
  24. || ((sgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))) {
  25. __set_errno(EINVAL);
  26. return -1;
  27. }
  28. return (__syscall_setresgid(rgid, egid, sgid));
  29. }
  30. libc_hidden_weak(setresgid)
  31. #endif
  32. #endif