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