blob: afa54e1542b358fbf3517c4ebe36db71fb5ef6d7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_UTSNAME_H
2#define _LINUX_UTSNAME_H
3
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -07004#include <linux/sched.h>
5#include <linux/kref.h>
6#include <linux/nsproxy.h>
7#include <asm/atomic.h>
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#define __OLD_UTS_LEN 8
10
11struct oldold_utsname {
12 char sysname[9];
13 char nodename[9];
14 char release[9];
15 char version[9];
16 char machine[9];
17};
18
19#define __NEW_UTS_LEN 64
20
21struct old_utsname {
22 char sysname[65];
23 char nodename[65];
24 char release[65];
25 char version[65];
26 char machine[65];
27};
28
29struct new_utsname {
30 char sysname[65];
31 char nodename[65];
32 char release[65];
33 char version[65];
34 char machine[65];
35 char domainname[65];
36};
37
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070038struct uts_namespace {
39 struct kref kref;
40 struct new_utsname name;
41};
42extern struct uts_namespace init_uts_ns;
43
44static inline void get_uts_ns(struct uts_namespace *ns)
45{
46 kref_get(&ns->kref);
47}
48
49#ifdef CONFIG_UTS_NS
50extern int copy_utsname(int flags, struct task_struct *tsk);
51extern void free_uts_ns(struct kref *kref);
52
53static inline void put_uts_ns(struct uts_namespace *ns)
54{
55 kref_put(&ns->kref, free_uts_ns);
56}
57#else
58static inline int copy_utsname(int flags, struct task_struct *tsk)
59{
60 return 0;
61}
62static inline void put_uts_ns(struct uts_namespace *ns)
63{
64}
65#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Serge E. Hallyn0bdd7aa2006-10-02 02:18:10 -070067static inline struct new_utsname *utsname(void)
68{
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070069 return &current->nsproxy->uts_ns->name;
Serge E. Hallyn0bdd7aa2006-10-02 02:18:10 -070070}
71
72static inline struct new_utsname *init_utsname(void)
73{
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070074 return &init_uts_ns.name;
Serge E. Hallyn0bdd7aa2006-10-02 02:18:10 -070075}
76
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -070077#define system_utsname init_uts_ns.name
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern struct rw_semaphore uts_sem;
80#endif