setresgid.c 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * setresgid() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #ifdef __USE_GNU
  11. #include <unistd.h>
  12. #if defined(__NR_setresgid32)
  13. # undef __NR_setresgid
  14. # define __NR_setresgid __NR_setresgid32
  15. _syscall3(int, setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
  16. libc_hidden_weak(setresgid)
  17. #elif defined(__NR_setresgid)
  18. # define __NR___syscall_setresgid __NR_setresgid
  19. static __inline__ _syscall3(int, __syscall_setresgid,
  20. __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid)
  21. int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
  22. {
  23. if (((rgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
  24. || ((egid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
  25. || ((sgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))) {
  26. __set_errno(EINVAL);
  27. return -1;
  28. }
  29. return (__syscall_setresgid(rgid, egid, sgid));
  30. }
  31. libc_hidden_weak(setresgid)
  32. #endif
  33. #endif