blob: 60f0bb83b313af0e5429264bb83296735c8cdf01 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_UTSNAME_H
2#define _LINUX_UTSNAME_H
3
Cedric Le Goaterb119f132006-10-04 02:15:19 -07004
5#include <linux/sched.h>
6#include <linux/kref.h>
7#include <linux/nsproxy.h>
Al Viro435d5f42014-10-31 22:56:04 -04008#include <linux/ns_common.h>
Pavel Emelyanov58bfdd6d2008-02-08 04:18:21 -08009#include <linux/err.h>
David Howells607ca462012-10-13 10:46:48 +010010#include <uapi/linux/utsname.h>
Cedric Le Goaterb119f132006-10-04 02:15:19 -070011
Lucas De Marchif1ecf062011-11-02 13:39:22 -070012enum uts_proc {
13 UTS_PROC_OSTYPE,
14 UTS_PROC_OSRELEASE,
15 UTS_PROC_VERSION,
16 UTS_PROC_HOSTNAME,
17 UTS_PROC_DOMAINNAME,
18};
19
Serge E. Hallyn59607db2011-03-23 16:43:16 -070020struct user_namespace;
21extern struct user_namespace init_user_ns;
22
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070023struct uts_namespace {
24 struct kref kref;
25 struct new_utsname name;
Serge E. Hallyn59607db2011-03-23 16:43:16 -070026 struct user_namespace *user_ns;
Eric W. Biedermanf7af3d12016-08-08 14:11:25 -050027 struct ucounts *ucounts;
Al Viro435d5f42014-10-31 22:56:04 -040028 struct ns_common ns;
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070029};
30extern struct uts_namespace init_uts_ns;
31
Pavel Emelyanov58bfdd6d2008-02-08 04:18:21 -080032#ifdef CONFIG_UTS_NS
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070033static inline void get_uts_ns(struct uts_namespace *ns)
34{
35 kref_get(&ns->kref);
36}
37
Eric W. Biederman213dd262007-07-15 23:41:15 -070038extern struct uts_namespace *copy_utsname(unsigned long flags,
Eric W. Biedermanbcf58e72012-07-26 04:02:49 -070039 struct user_namespace *user_ns, struct uts_namespace *old_ns);
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070040extern void free_uts_ns(struct kref *kref);
41
42static inline void put_uts_ns(struct uts_namespace *ns)
43{
44 kref_put(&ns->kref, free_uts_ns);
45}
Pavel Emelyanov58bfdd6d2008-02-08 04:18:21 -080046#else
47static inline void get_uts_ns(struct uts_namespace *ns)
48{
49}
50
51static inline void put_uts_ns(struct uts_namespace *ns)
52{
53}
54
55static inline struct uts_namespace *copy_utsname(unsigned long flags,
Eric W. Biedermanbcf58e72012-07-26 04:02:49 -070056 struct user_namespace *user_ns, struct uts_namespace *old_ns)
Pavel Emelyanov58bfdd6d2008-02-08 04:18:21 -080057{
58 if (flags & CLONE_NEWUTS)
59 return ERR_PTR(-EINVAL);
60
Eric W. Biedermanbcf58e72012-07-26 04:02:49 -070061 return old_ns;
Pavel Emelyanov58bfdd6d2008-02-08 04:18:21 -080062}
63#endif
64
Lucas De Marchif1ecf062011-11-02 13:39:22 -070065#ifdef CONFIG_PROC_SYSCTL
66extern void uts_proc_notify(enum uts_proc proc);
67#else
68static inline void uts_proc_notify(enum uts_proc proc)
69{
70}
71#endif
72
Serge E. Hallyn0bdd7aa2006-10-02 02:18:10 -070073static inline struct new_utsname *utsname(void)
74{
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070075 return &current->nsproxy->uts_ns->name;
Serge E. Hallyn0bdd7aa2006-10-02 02:18:10 -070076}
77
78static inline struct new_utsname *init_utsname(void)
79{
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070080 return &init_uts_ns.name;
Serge E. Hallyn0bdd7aa2006-10-02 02:18:10 -070081}
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083extern struct rw_semaphore uts_sem;
Cedric Le Goaterb119f132006-10-04 02:15:19 -070084
Cedric Le Goaterb119f132006-10-04 02:15:19 -070085#endif /* _LINUX_UTSNAME_H */