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