]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/time_namespace.h
ns: Introduce Time Namespace
[mirror_ubuntu-jammy-kernel.git] / include / linux / time_namespace.h
CommitLineData
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
12struct user_namespace;
13extern struct user_namespace init_user_ns;
14
15struct 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
22extern struct time_namespace init_time_ns;
23
24#ifdef CONFIG_TIME_NS
25static inline struct time_namespace *get_time_ns(struct time_namespace *ns)
26{
27 kref_get(&ns->kref);
28 return ns;
29}
30
31struct time_namespace *copy_time_ns(unsigned long flags,
32 struct user_namespace *user_ns,
33 struct time_namespace *old_ns);
34void free_time_ns(struct kref *kref);
35int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk);
36
37static inline void put_time_ns(struct time_namespace *ns)
38{
39 kref_put(&ns->kref, free_time_ns);
40}
41
42#else
43static inline struct time_namespace *get_time_ns(struct time_namespace *ns)
44{
45 return NULL;
46}
47
48static inline void put_time_ns(struct time_namespace *ns)
49{
50}
51
52static inline
53struct 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
63static 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 */