4 * Author: Eric Biederman <ebiederm@xmision.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the
12 #include <linux/export.h>
13 #include <linux/uts.h>
14 #include <linux/utsname.h>
15 #include <linux/sysctl.h>
17 static void *get_uts(ctl_table
*table
, int write
)
19 char *which
= table
->data
;
20 struct uts_namespace
*uts_ns
;
22 uts_ns
= current
->nsproxy
->uts_ns
;
23 which
= (which
- (char *)&init_uts_ns
) + (char *)uts_ns
;
32 static void put_uts(ctl_table
*table
, int write
, void *which
)
40 #ifdef CONFIG_PROC_SYSCTL
42 * Special case of dostring for the UTS structure. This has locks
43 * to observe. Should this be in kernel/sys.c ????
45 static int proc_do_uts_string(ctl_table
*table
, int write
,
46 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
48 struct ctl_table uts_table
;
50 memcpy(&uts_table
, table
, sizeof(uts_table
));
51 uts_table
.data
= get_uts(table
, write
);
52 r
= proc_dostring(&uts_table
,write
,buffer
,lenp
, ppos
);
53 put_uts(table
, write
, uts_table
.data
);
57 #define proc_do_uts_string NULL
60 static struct ctl_table uts_kern_table
[] = {
63 .data
= init_uts_ns
.name
.sysname
,
64 .maxlen
= sizeof(init_uts_ns
.name
.sysname
),
66 .proc_handler
= proc_do_uts_string
,
69 .procname
= "osrelease",
70 .data
= init_uts_ns
.name
.release
,
71 .maxlen
= sizeof(init_uts_ns
.name
.release
),
73 .proc_handler
= proc_do_uts_string
,
76 .procname
= "version",
77 .data
= init_uts_ns
.name
.version
,
78 .maxlen
= sizeof(init_uts_ns
.name
.version
),
80 .proc_handler
= proc_do_uts_string
,
83 .procname
= "hostname",
84 .data
= init_uts_ns
.name
.nodename
,
85 .maxlen
= sizeof(init_uts_ns
.name
.nodename
),
87 .proc_handler
= proc_do_uts_string
,
90 .procname
= "domainname",
91 .data
= init_uts_ns
.name
.domainname
,
92 .maxlen
= sizeof(init_uts_ns
.name
.domainname
),
94 .proc_handler
= proc_do_uts_string
,
99 static struct ctl_table uts_root_table
[] = {
101 .procname
= "kernel",
103 .child
= uts_kern_table
,
108 static int __init
utsname_sysctl_init(void)
110 register_sysctl_table(uts_root_table
);
114 __initcall(utsname_sysctl_init
);