You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

  1. /*
  2. Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. #include <stdlib.h>
  15. #include <sys/types.h>
  16. #include <unistd.h>
  17. #include <pthread.h>
  18. #include <vector>
  19. namespace mergerfs
  20. {
  21. namespace ugid
  22. {
  23. uid_t currentuid;
  24. gid_t currentgid;
  25. pthread_rwlock_t rwlock;
  26. void
  27. init()
  28. {
  29. pthread_rwlockattr_t attr;
  30. pthread_rwlockattr_init(&attr);
  31. # if defined PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
  32. pthread_rwlockattr_setkind_np(&attr,PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
  33. # endif
  34. pthread_rwlock_init(&rwlock,&attr);
  35. currentuid = ::geteuid();
  36. currentgid = ::getegid();
  37. }
  38. }
  39. }