diff -NurpP --minimal linux-2.6.11.7-vs2.0-pre3/include/linux/sysctl.h linux-2.6.11.7-vs2.0-pre3-uts/include/linux/sysctl.h --- linux-2.6.11.7-vs2.0-pre3/include/linux/sysctl.h 2005-05-01 03:10:33.000000000 +0200 +++ linux-2.6.11.7-vs2.0-pre3-uts/include/linux/sysctl.h 2005-05-01 06:04:13.000000000 +0200 @@ -786,6 +786,9 @@ typedef int ctl_handler (ctl_table *tabl typedef int proc_handler (ctl_table *ctl, int write, struct file * filp, void __user *buffer, size_t *lenp, loff_t *ppos); +typedef int virt_handler (struct ctl_table *ctl, int write, xid_t xid, + void **datap, size_t *lenp); + extern int proc_dostring(ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); extern int proc_dointvec(ctl_table *, int, struct file *, @@ -867,6 +870,7 @@ struct ctl_table mode_t mode; ctl_table *child; proc_handler *proc_handler; /* Callback for text formatting */ + virt_handler *virt_handler; /* Context virtualization */ ctl_handler *strategy; /* Callback function for all r/w */ struct proc_dir_entry *de; /* /proc control block */ void *extra1; diff -NurpP --minimal linux-2.6.11.7-vs2.0-pre3/include/linux/vserver/cvirt.h linux-2.6.11.7-vs2.0-pre3-uts/include/linux/vserver/cvirt.h --- linux-2.6.11.7-vs2.0-pre3/include/linux/vserver/cvirt.h 2005-05-01 03:10:33.000000000 +0200 +++ linux-2.6.11.7-vs2.0-pre3-uts/include/linux/vserver/cvirt.h 2005-05-01 06:09:46.000000000 +0200 @@ -13,6 +13,10 @@ struct vx_info; void vx_update_load(struct vx_info *); +int vx_uts_virt_handler(struct ctl_table *ctl, int write, xid_t xid, + void **datap, size_t *lenp); + + int vx_do_syslog(int, char __user *, int); #endif /* __KERNEL__ */ diff -NurpP --minimal linux-2.6.11.7-vs2.0-pre3/kernel/sysctl.c linux-2.6.11.7-vs2.0-pre3-uts/kernel/sysctl.c --- linux-2.6.11.7-vs2.0-pre3/kernel/sysctl.c 2005-05-01 03:10:33.000000000 +0200 +++ linux-2.6.11.7-vs2.0-pre3-uts/kernel/sysctl.c 2005-05-01 06:10:32.000000000 +0200 @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -227,6 +228,7 @@ static ctl_table kern_table[] = { .maxlen = sizeof(system_utsname.sysname), .mode = 0444, .proc_handler = &proc_doutsstring, + .virt_handler = &vx_uts_virt_handler, .strategy = &sysctl_string, }, { @@ -236,6 +238,7 @@ static ctl_table kern_table[] = { .maxlen = sizeof(system_utsname.release), .mode = 0444, .proc_handler = &proc_doutsstring, + .virt_handler = &vx_uts_virt_handler, .strategy = &sysctl_string, }, { @@ -245,6 +248,7 @@ static ctl_table kern_table[] = { .maxlen = sizeof(system_utsname.version), .mode = 0444, .proc_handler = &proc_doutsstring, + .virt_handler = &vx_uts_virt_handler, .strategy = &sysctl_string, }, { @@ -254,6 +258,7 @@ static ctl_table kern_table[] = { .maxlen = sizeof(system_utsname.nodename), .mode = 0644, .proc_handler = &proc_doutsstring, + .virt_handler = &vx_uts_virt_handler, .strategy = &sysctl_string, }, { @@ -263,6 +268,7 @@ static ctl_table kern_table[] = { .maxlen = sizeof(system_utsname.domainname), .mode = 0644, .proc_handler = &proc_doutsstring, + .virt_handler = &vx_uts_virt_handler, .strategy = &sysctl_string, }, { @@ -1392,13 +1398,22 @@ int proc_dostring(ctl_table *table, int size_t len; char __user *p; char c; + void *data; + size_t maxlen; if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) { *lenp = 0; return 0; } - + + if (!table->virt_handler) { + data = table->data; + maxlen = table->maxlen; + } else { + table->virt_handler(table, write, filp->f_xid, &data, &maxlen); + } + if (write) { len = 0; p = buffer; @@ -1409,20 +1424,20 @@ int proc_dostring(ctl_table *table, int break; len++; } - if (len >= table->maxlen) - len = table->maxlen-1; - if(copy_from_user(table->data, buffer, len)) + if (len >= maxlen) + len = maxlen-1; + if(copy_from_user(data, buffer, len)) return -EFAULT; - ((char *) table->data)[len] = 0; + ((char *) data)[len] = 0; *ppos += *lenp; } else { - len = strlen(table->data); - if (len > table->maxlen) - len = table->maxlen; + len = strlen(data); + if (len > maxlen) + len = maxlen; if (len > *lenp) len = *lenp; if (len) - if(copy_to_user(buffer, table->data, len)) + if(copy_to_user(buffer, data, len)) return -EFAULT; if (len < *lenp) { if(put_user('\n', ((char __user *) buffer) + len)) diff -NurpP --minimal linux-2.6.11.7-vs2.0-pre3/kernel/vserver/cvirt.c linux-2.6.11.7-vs2.0-pre3-uts/kernel/vserver/cvirt.c --- linux-2.6.11.7-vs2.0-pre3/kernel/vserver/cvirt.c 2005-05-01 03:10:33.000000000 +0200 +++ linux-2.6.11.7-vs2.0-pre3-uts/kernel/vserver/cvirt.c 2005-05-01 06:13:47.000000000 +0200 @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -94,6 +95,36 @@ out: } +int vx_uts_virt_handler(struct ctl_table *ctl, int write, xid_t xid, + void **datap, size_t *lenp) +{ + *lenp = ctl->maxlen; + + switch (ctl->ctl_name) { + case KERN_OSTYPE: + *datap = vx_new_uts(sysname); + break; + case KERN_OSRELEASE: + *datap = vx_new_uts(release); + break; + case KERN_VERSION: + *datap = vx_new_uts(version); + break; + case KERN_NODENAME: + *datap = vx_new_uts(nodename); + break; + case KERN_DOMAINNAME: + *datap = vx_new_uts(domainname); + break; + default: /* Not virtualized is still better than an Oops... */ + *datap = ctl->data; + } + + return 0; +} + + + /* * Commands to do_syslog: *