Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_UTSNAME_H |
| 2 | #define _LINUX_UTSNAME_H |
| 3 | |
Cedric Le Goater | b119f13 | 2006-10-04 02:15:19 -0700 | [diff] [blame] | 4 | |
| 5 | #include <linux/sched.h> |
| 6 | #include <linux/kref.h> |
| 7 | #include <linux/nsproxy.h> |
Al Viro | 435d5f4 | 2014-10-31 22:56:04 -0400 | [diff] [blame] | 8 | #include <linux/ns_common.h> |
Pavel Emelyanov | 58bfdd6d | 2008-02-08 04:18:21 -0800 | [diff] [blame] | 9 | #include <linux/err.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 10 | #include <uapi/linux/utsname.h> |
Cedric Le Goater | b119f13 | 2006-10-04 02:15:19 -0700 | [diff] [blame] | 11 | |
Lucas De Marchi | f1ecf06 | 2011-11-02 13:39:22 -0700 | [diff] [blame] | 12 | enum 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. Hallyn | 59607db | 2011-03-23 16:43:16 -0700 | [diff] [blame] | 20 | struct user_namespace; |
| 21 | extern struct user_namespace init_user_ns; |
| 22 | |
Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame] | 23 | struct uts_namespace { |
| 24 | struct kref kref; |
| 25 | struct new_utsname name; |
Serge E. Hallyn | 59607db | 2011-03-23 16:43:16 -0700 | [diff] [blame] | 26 | struct user_namespace *user_ns; |
Al Viro | 435d5f4 | 2014-10-31 22:56:04 -0400 | [diff] [blame] | 27 | struct ns_common ns; |
Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame] | 28 | }; |
| 29 | extern struct uts_namespace init_uts_ns; |
| 30 | |
Pavel Emelyanov | 58bfdd6d | 2008-02-08 04:18:21 -0800 | [diff] [blame] | 31 | #ifdef CONFIG_UTS_NS |
Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame] | 32 | static inline void get_uts_ns(struct uts_namespace *ns) |
| 33 | { |
| 34 | kref_get(&ns->kref); |
| 35 | } |
| 36 | |
Eric W. Biederman | 213dd26 | 2007-07-15 23:41:15 -0700 | [diff] [blame] | 37 | extern struct uts_namespace *copy_utsname(unsigned long flags, |
Eric W. Biederman | bcf58e7 | 2012-07-26 04:02:49 -0700 | [diff] [blame] | 38 | struct user_namespace *user_ns, struct uts_namespace *old_ns); |
Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame] | 39 | extern void free_uts_ns(struct kref *kref); |
| 40 | |
| 41 | static inline void put_uts_ns(struct uts_namespace *ns) |
| 42 | { |
| 43 | kref_put(&ns->kref, free_uts_ns); |
| 44 | } |
Pavel Emelyanov | 58bfdd6d | 2008-02-08 04:18:21 -0800 | [diff] [blame] | 45 | #else |
| 46 | static inline void get_uts_ns(struct uts_namespace *ns) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | static inline void put_uts_ns(struct uts_namespace *ns) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | static inline struct uts_namespace *copy_utsname(unsigned long flags, |
Eric W. Biederman | bcf58e7 | 2012-07-26 04:02:49 -0700 | [diff] [blame] | 55 | struct user_namespace *user_ns, struct uts_namespace *old_ns) |
Pavel Emelyanov | 58bfdd6d | 2008-02-08 04:18:21 -0800 | [diff] [blame] | 56 | { |
| 57 | if (flags & CLONE_NEWUTS) |
| 58 | return ERR_PTR(-EINVAL); |
| 59 | |
Eric W. Biederman | bcf58e7 | 2012-07-26 04:02:49 -0700 | [diff] [blame] | 60 | return old_ns; |
Pavel Emelyanov | 58bfdd6d | 2008-02-08 04:18:21 -0800 | [diff] [blame] | 61 | } |
| 62 | #endif |
| 63 | |
Lucas De Marchi | f1ecf06 | 2011-11-02 13:39:22 -0700 | [diff] [blame] | 64 | #ifdef CONFIG_PROC_SYSCTL |
| 65 | extern void uts_proc_notify(enum uts_proc proc); |
| 66 | #else |
| 67 | static inline void uts_proc_notify(enum uts_proc proc) |
| 68 | { |
| 69 | } |
| 70 | #endif |
| 71 | |
Serge E. Hallyn | 0bdd7aa | 2006-10-02 02:18:10 -0700 | [diff] [blame] | 72 | static inline struct new_utsname *utsname(void) |
| 73 | { |
Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame] | 74 | return ¤t->nsproxy->uts_ns->name; |
Serge E. Hallyn | 0bdd7aa | 2006-10-02 02:18:10 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | static inline struct new_utsname *init_utsname(void) |
| 78 | { |
Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame] | 79 | return &init_uts_ns.name; |
Serge E. Hallyn | 0bdd7aa | 2006-10-02 02:18:10 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | extern struct rw_semaphore uts_sem; |
Cedric Le Goater | b119f13 | 2006-10-04 02:15:19 -0700 | [diff] [blame] | 83 | |
Cedric Le Goater | b119f13 | 2006-10-04 02:15:19 -0700 | [diff] [blame] | 84 | #endif /* _LINUX_UTSNAME_H */ |