Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 43767
b: refs/heads/master
c: cf9f151
h: refs/heads/master
i:
  43765: f728121
  43763: 48f99b9
  43759: 1ce831c
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Dec 8, 2006
1 parent bca3c08 commit b761b81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 103 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6b1b60f41eef3ba7b188fd72f1d6de478aafd93c
refs/heads/master: cf9f151c7257683f489df85f94baf408d1d5694a
128 changes: 26 additions & 102 deletions trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,28 @@ extern ctl_table inotify_table[];
int sysctl_legacy_va_layout;
#endif

static void *get_uts(ctl_table *table, int write)
{
char *which = table->data;
#ifdef CONFIG_UTS_NS
struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
#endif
if (!write)
down_read(&uts_sem);
else
down_write(&uts_sem);
return which;
}

static void put_uts(ctl_table *table, int write, void *which)
{
if (!write)
up_read(&uts_sem);
else
up_write(&uts_sem);
}

/* /proc declarations: */

#ifdef CONFIG_PROC_SYSCTL
Expand Down Expand Up @@ -229,7 +251,6 @@ static ctl_table root_table[] = {
};

static ctl_table kern_table[] = {
#ifndef CONFIG_UTS_NS
{
.ctl_name = KERN_OSTYPE,
.procname = "ostype",
Expand Down Expand Up @@ -275,54 +296,6 @@ static ctl_table kern_table[] = {
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string,
},
#else /* !CONFIG_UTS_NS */
{
.ctl_name = KERN_OSTYPE,
.procname = "ostype",
.data = NULL,
/* could maybe use __NEW_UTS_LEN here? */
.maxlen = FIELD_SIZEOF(struct new_utsname, sysname),
.mode = 0444,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string,
},
{
.ctl_name = KERN_OSRELEASE,
.procname = "osrelease",
.data = NULL,
.maxlen = FIELD_SIZEOF(struct new_utsname, release),
.mode = 0444,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string,
},
{
.ctl_name = KERN_VERSION,
.procname = "version",
.data = NULL,
.maxlen = FIELD_SIZEOF(struct new_utsname, version),
.mode = 0444,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string,
},
{
.ctl_name = KERN_NODENAME,
.procname = "hostname",
.data = NULL,
.maxlen = FIELD_SIZEOF(struct new_utsname, nodename),
.mode = 0644,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string,
},
{
.ctl_name = KERN_DOMAINNAME,
.procname = "domainname",
.data = NULL,
.maxlen = FIELD_SIZEOF(struct new_utsname, domainname),
.mode = 0644,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string,
},
#endif /* !CONFIG_UTS_NS */
{
.ctl_name = KERN_PANIC,
.procname = "panic",
Expand Down Expand Up @@ -1753,66 +1726,17 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
* Special case of dostring for the UTS structure. This has locks
* to observe. Should this be in kernel/sys.c ????
*/

#ifndef CONFIG_UTS_NS
static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int r;

if (!write) {
down_read(&uts_sem);
r=proc_dostring(table,0,filp,buffer,lenp, ppos);
up_read(&uts_sem);
} else {
down_write(&uts_sem);
r=proc_dostring(table,1,filp,buffer,lenp, ppos);
up_write(&uts_sem);
}
return r;
}
#else /* !CONFIG_UTS_NS */
static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int r;
struct uts_namespace* uts_ns = current->nsproxy->uts_ns;
char* which;

switch (table->ctl_name) {
case KERN_OSTYPE:
which = uts_ns->name.sysname;
break;
case KERN_NODENAME:
which = uts_ns->name.nodename;
break;
case KERN_OSRELEASE:
which = uts_ns->name.release;
break;
case KERN_VERSION:
which = uts_ns->name.version;
break;
case KERN_DOMAINNAME:
which = uts_ns->name.domainname;
break;
default:
r = -EINVAL;
goto out;
}

if (!write) {
down_read(&uts_sem);
r=_proc_do_string(which,table->maxlen,0,filp,buffer,lenp, ppos);
up_read(&uts_sem);
} else {
down_write(&uts_sem);
r=_proc_do_string(which,table->maxlen,1,filp,buffer,lenp, ppos);
up_write(&uts_sem);
}
out:
void *which;
which = get_uts(table, write);
r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
put_uts(table, write, which);
return r;
}
#endif /* !CONFIG_UTS_NS */

static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
int *valp,
Expand Down

0 comments on commit b761b81

Please sign in to comment.