user.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _LINUX_SCHED_USER_H
  2. #define _LINUX_SCHED_USER_H
  3. #include <linux/sched.h>
  4. struct key;
  5. /*
  6. * Some day this will be a full-fledged user tracking system..
  7. */
  8. struct user_struct {
  9. atomic_t __count; /* reference count */
  10. atomic_t processes; /* How many processes does this user have? */
  11. atomic_t sigpending; /* How many pending signals does this user have? */
  12. #ifdef CONFIG_FANOTIFY
  13. atomic_t fanotify_listeners;
  14. #endif
  15. #ifdef CONFIG_EPOLL
  16. atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
  17. #endif
  18. #ifdef CONFIG_POSIX_MQUEUE
  19. /* protected by mq_lock */
  20. unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
  21. #endif
  22. unsigned long locked_shm; /* How many pages of mlocked shm ? */
  23. unsigned long unix_inflight; /* How many files in flight in unix sockets */
  24. atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */
  25. #ifdef CONFIG_KEYS
  26. struct key *uid_keyring; /* UID specific keyring */
  27. struct key *session_keyring; /* UID's default session keyring */
  28. #endif
  29. /* Hash table maintenance information */
  30. struct hlist_node uidhash_node;
  31. kuid_t uid;
  32. #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL)
  33. atomic_long_t locked_vm;
  34. #endif
  35. };
  36. extern int uids_sysfs_init(void);
  37. extern struct user_struct *find_user(kuid_t);
  38. extern struct user_struct root_user;
  39. #define INIT_USER (&root_user)
  40. /* per-UID process charging. */
  41. extern struct user_struct * alloc_uid(kuid_t);
  42. static inline struct user_struct *get_uid(struct user_struct *u)
  43. {
  44. atomic_inc(&u->__count);
  45. return u;
  46. }
  47. extern void free_uid(struct user_struct *);
  48. #endif /* _LINUX_SCHED_USER_H */