getresuid.c 946 B

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