getresuid.c 920 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * getresuid() 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_getresuid32)
  12. # undef __NR_getresuid
  13. # define __NR_getresuid __NR_getresuid32
  14. _syscall3(int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid)
  15. #elif defined(__NR_getresuid)
  16. # define __NR___syscall_getresuid __NR_getresuid
  17. static __inline__ _syscall3(int, __syscall_getresuid, __kernel_uid_t *, ruid,
  18. __kernel_uid_t *, euid, __kernel_uid_t *, suid)
  19. int getresuid(uid_t * ruid, uid_t * euid, uid_t * suid)
  20. {
  21. int result;
  22. __kernel_uid_t k_ruid, k_euid, k_suid;
  23. result = __syscall_getresuid(&k_ruid, &k_euid, &k_suid);
  24. if (result == 0) {
  25. *ruid = (uid_t) k_ruid;
  26. *euid = (uid_t) k_euid;
  27. *suid = (uid_t) k_suid;
  28. }
  29. return result;
  30. }
  31. #endif
  32. #endif