X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fvserver%2Fnamespace.c;h=84e58c5ae25ce82e73d1322f04883d2bb37986b1;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=f1c95c49e33c37ebefb0bdbfd1014d6345023c86;hpb=d46bc780027c5439db9f72d42c0732775b53925a;p=linux-2.6.git diff --git a/kernel/vserver/namespace.c b/kernel/vserver/namespace.c index f1c95c49e..84e58c5ae 100644 --- a/kernel/vserver/namespace.c +++ b/kernel/vserver/namespace.c @@ -3,96 +3,26 @@ * * Virtual Server: Context Namespace Support * - * Copyright (C) 2003-2004 Herbert Pötzl + * Copyright (C) 2003-2005 Herbert Pötzl * * V0.01 broken out from context.c 0.07 * V0.02 added task locking for namespace * */ -#include #include +#include +#include #include -#include -#include +#include #include +#include +#include #include #include -/* virtual host info names */ - -static char * vx_vhi_name(struct vx_info *vxi, int id) -{ - switch (id) { - case VHIN_CONTEXT: - return vxi->vx_name; - case VHIN_SYSNAME: - return vxi->cvirt.utsname.sysname; - case VHIN_NODENAME: - return vxi->cvirt.utsname.nodename; - case VHIN_RELEASE: - return vxi->cvirt.utsname.release; - case VHIN_VERSION: - return vxi->cvirt.utsname.version; - case VHIN_MACHINE: - return vxi->cvirt.utsname.machine; - case VHIN_DOMAINNAME: - return vxi->cvirt.utsname.domainname; - default: - return NULL; - } - return NULL; -} - -int vc_set_vhi_name(uint32_t id, void __user *data) -{ - struct vx_info *vxi; - struct vcmd_vx_vhi_name_v0 vc_data; - char *name; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (copy_from_user (&vc_data, data, sizeof(vc_data))) - return -EFAULT; - - vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; - - name = vx_vhi_name(vxi, vc_data.field); - if (name) - memcpy(name, vc_data.name, 65); - put_vx_info(vxi); - return (name ? 0 : -EFAULT); -} - -int vc_get_vhi_name(uint32_t id, void __user *data) -{ - struct vx_info *vxi; - struct vcmd_vx_vhi_name_v0 vc_data; - char *name; - - if (copy_from_user (&vc_data, data, sizeof(vc_data))) - return -EFAULT; - - vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; - - name = vx_vhi_name(vxi, vc_data.field); - if (!name) - goto out_put; - - memcpy(vc_data.name, name, 65); - if (copy_to_user (data, &vc_data, sizeof(vc_data))) - return -EFAULT; -out_put: - put_vx_info(vxi); - return (name ? 0 : -EFAULT); -} - /* namespace functions */ #include @@ -116,7 +46,7 @@ int vx_set_namespace(struct vx_info *vxi, struct namespace *ns, struct fs_struct return 0; } -int vc_enter_namespace(uint32_t id, void *data) +int vc_enter_namespace(uint32_t id, void __user *data) { struct vx_info *vxi; struct fs_struct *old_fs, *fs; @@ -126,7 +56,7 @@ int vc_enter_namespace(uint32_t id, void *data) if (!vx_check(0, VX_ADMIN)) return -ENOSYS; - vxi = locate_vx_info(id); + vxi = lookup_vx_info(id); if (!vxi) return -ESRCH; @@ -144,7 +74,7 @@ int vc_enter_namespace(uint32_t id, void *data) old_ns = current->namespace; old_fs = current->fs; get_namespace(vxi->vx_namespace); - current->namespace = vxi->vx_namespace; + current->namespace = vxi->vx_namespace; current->fs = fs; task_unlock(current); @@ -155,13 +85,13 @@ out_put: return ret; } -int vc_cleanup_namespace(uint32_t id, void *data) +int vc_cleanup_namespace(uint32_t id, void __user *data) { - down_write(¤t->namespace->sem); + // down_write(¤t->namespace->sem); spin_lock(&vfsmount_lock); umount_unused(current->namespace->root, current->fs); spin_unlock(&vfsmount_lock); - up_write(¤t->namespace->sem); + // up_write(¤t->namespace->sem); return 0; } @@ -172,11 +102,11 @@ int vc_set_namespace(uint32_t id, void __user *data) struct vx_info *vxi; int ret; - if (vx_check(0, VX_ADMIN|VX_WATCH)) - return -ENOSYS; + vxi = lookup_vx_info(id); + if (!vxi) + return -ESRCH; task_lock(current); - vxi = get_vx_info(current->vx_info); fs = current->fs; atomic_inc(&fs->count); ns = current->namespace;