setresgid.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. libc_hidden_proto(setresgid)
  16. _syscall3(int, setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
  17. libc_hidden_def(setresgid)
  18. #elif defined(__NR_setresgid)
  19. # define __NR___syscall_setresgid __NR_setresgid
  20. static __inline__ _syscall3(int, __syscall_setresgid,
  21. __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid);
  22. libc_hidden_proto(setresgid)
  23. int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
  24. {
  25. if (((rgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
  26. || ((egid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
  27. || ((sgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))) {
  28. __set_errno(EINVAL);
  29. return -1;
  30. }
  31. return (__syscall_setresgid(rgid, egid, sgid));
  32. }
  33. libc_hidden_def(setresgid)
  34. #endif
  35. #endif