]>
Commit | Line | Data |
---|---|---|
769071ac AV |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _LINUX_TIMENS_H | |
3 | #define _LINUX_TIMENS_H | |
4 | ||
5 | ||
6 | #include <linux/sched.h> | |
7 | #include <linux/kref.h> | |
8 | #include <linux/nsproxy.h> | |
9 | #include <linux/ns_common.h> | |
10 | #include <linux/err.h> | |
11 | ||
12 | struct user_namespace; | |
13 | extern struct user_namespace init_user_ns; | |
14 | ||
15 | struct time_namespace { | |
16 | struct kref kref; | |
17 | struct user_namespace *user_ns; | |
18 | struct ucounts *ucounts; | |
19 | struct ns_common ns; | |
20 | } __randomize_layout; | |
21 | ||
22 | extern struct time_namespace init_time_ns; | |
23 | ||
24 | #ifdef CONFIG_TIME_NS | |
25 | static inline struct time_namespace *get_time_ns(struct time_namespace *ns) | |
26 | { | |
27 | kref_get(&ns->kref); | |
28 | return ns; | |
29 | } | |
30 | ||
31 | struct time_namespace *copy_time_ns(unsigned long flags, | |
32 | struct user_namespace *user_ns, | |
33 | struct time_namespace *old_ns); | |
34 | void free_time_ns(struct kref *kref); | |
35 | int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); | |
36 | ||
37 | static inline void put_time_ns(struct time_namespace *ns) | |
38 | { | |
39 | kref_put(&ns->kref, free_time_ns); | |
40 | } | |
41 | ||
42 | #else | |
43 | static inline struct time_namespace *get_time_ns(struct time_namespace *ns) | |
44 | { | |
45 | return NULL; | |
46 | } | |
47 | ||
48 | static inline void put_time_ns(struct time_namespace *ns) | |
49 | { | |
50 | } | |
51 | ||
52 | static inline | |
53 | struct time_namespace *copy_time_ns(unsigned long flags, | |
54 | struct user_namespace *user_ns, | |
55 | struct time_namespace *old_ns) | |
56 | { | |
57 | if (flags & CLONE_NEWTIME) | |
58 | return ERR_PTR(-EINVAL); | |
59 | ||
60 | return old_ns; | |
61 | } | |
62 | ||
63 | static inline int timens_on_fork(struct nsproxy *nsproxy, | |
64 | struct task_struct *tsk) | |
65 | { | |
66 | return 0; | |
67 | } | |
68 | ||
69 | #endif | |
70 | ||
71 | #endif /* _LINUX_TIMENS_H */ |