diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/include/linux/vserver/context.h linux-2.6.11.12-vs2.0-rc4-state_setup/include/linux/vserver/context.h --- linux-2.6.11.12-vs2.0-rc4/include/linux/vserver/context.h 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/include/linux/vserver/context.h 2005-06-18 03:02:36.000000000 +0200 @@ -144,6 +144,7 @@ struct vx_info { extern void claim_vx_info(struct vx_info *, struct task_struct *); extern void release_vx_info(struct vx_info *, struct task_struct *); +extern struct vx_info *__locate_vx_info(int); extern struct vx_info *locate_vx_info(int); extern struct vx_info *locate_or_create_vx_info(int); diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/ipc/mqueue.c linux-2.6.11.12-vs2.0-rc4-state_setup/ipc/mqueue.c --- linux-2.6.11.12-vs2.0-rc4/ipc/mqueue.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/ipc/mqueue.c 2005-06-18 03:02:57.000000000 +0200 @@ -259,7 +259,7 @@ static void mqueue_delete_inode(struct i (info->attr.mq_maxmsg * info->attr.mq_msgsize)); user = info->user; if (user) { - struct vx_info *vxi = locate_vx_info(user->xid); + struct vx_info *vxi = __locate_vx_info(user->xid); spin_lock(&mq_lock); user->mq_bytes -= mq_bytes; diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/ipc/shm.c linux-2.6.11.12-vs2.0-rc4-state_setup/ipc/shm.c --- linux-2.6.11.12-vs2.0-rc4/ipc/shm.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/ipc/shm.c 2005-06-18 03:03:08.000000000 +0200 @@ -113,7 +113,7 @@ static void shm_open (struct vm_area_str */ static void shm_destroy (struct shmid_kernel *shp) { - struct vx_info *vxi = locate_vx_info(shp->shm_perm.xid); + struct vx_info *vxi = __locate_vx_info(shp->shm_perm.xid); int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT; vx_ipcshm_sub(vxi, shp, numpages); diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/context.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/context.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/context.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/context.c 2005-06-18 03:06:08.000000000 +0200 @@ -387,13 +387,12 @@ void unhash_vx_info(struct vx_info *vxi) __wakeup_vx_info(vxi); } - -/* locate_vx_info() +/* __locate_vx_info() * search for a vx_info and get() it * negative id means current */ -struct vx_info *locate_vx_info(int id) +struct vx_info *__locate_vx_info(int id) { struct vx_info *vxi = NULL; @@ -407,6 +406,20 @@ struct vx_info *locate_vx_info(int id) return vxi; } +struct vx_info *locate_vx_info(int id) +{ + struct vx_info *vxi = __locate_vx_info(id); + + if (!vxi) { + vxi = ERR_PTR(-ESRCH); + } else if (vx_info_flags(vxi, VXF_STATE_SETUP, 0)) { + put_vx_info(vxi); + vxi = ERR_PTR(-EBUSY); + } + + return vxi; +} + /* xid_is_hashed() * verify that xid is still hashed */ @@ -630,8 +643,8 @@ int vc_vx_info(uint32_t id, void __user return -EPERM; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); vc_data.xid = vxi->vx_id; vc_data.initpid = vxi->vx_initpid; @@ -691,8 +704,8 @@ int vc_ctx_migrate(uint32_t id, void __u } vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); vx_migrate_task(current, vxi); put_vx_info(vxi); return 0; @@ -708,8 +721,8 @@ int vc_get_cflags(uint32_t id, void __us return -EPERM; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); vc_data.flagword = vxi->vx_flags; @@ -735,8 +748,8 @@ int vc_set_cflags(uint32_t id, void __us return -EFAULT; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); /* special STATE flag handling */ mask = vx_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME); @@ -763,8 +776,8 @@ int vc_get_ccaps(uint32_t id, void __use return -EPERM; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); vc_data.bcaps = vxi->vx_bcaps; vc_data.ccaps = vxi->vx_ccaps; @@ -787,8 +800,8 @@ int vc_set_ccaps(uint32_t id, void __use return -EFAULT; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); vxi->vx_bcaps &= vc_data.bcaps; vxi->vx_ccaps = vx_mask_flags(vxi->vx_ccaps, diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/legacy.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/legacy.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/legacy.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/legacy.c 2005-06-18 03:06:42.000000000 +0200 @@ -76,7 +76,7 @@ int vc_new_s_context(uint32_t ctx, void if ((ctx == VX_DYNAMIC_ID) || (ctx < MIN_D_CONTEXT)) new_vxi = locate_or_create_vx_info(ctx); else - new_vxi = locate_vx_info(ctx); + new_vxi = __locate_vx_info(ctx); if (!new_vxi) return -EINVAL; diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/limit.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/limit.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/limit.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/limit.c 2005-06-18 03:24:50.000000000 +0200 @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -83,8 +84,8 @@ int vc_get_rlimit(uint32_t id, void __us return -ENOTSUPP; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); vc_data.maximum = vc_get_rlim(vxi, vc_data.id); vc_data.minimum = CRLIM_UNSET; @@ -109,8 +110,8 @@ int vc_set_rlimit(uint32_t id, void __us return -ENOTSUPP; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); if (vc_data.maximum != CRLIM_KEEP) vxi->limit.rlim[vc_data.id] = vc_data.maximum; diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/namespace.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/namespace.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/namespace.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/namespace.c 2005-06-18 03:08:42.000000000 +0200 @@ -60,8 +60,8 @@ int vc_set_vhi_name(uint32_t id, void __ return -EFAULT; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); name = vx_vhi_name(vxi, vc_data.field); if (name) @@ -80,8 +80,8 @@ int vc_get_vhi_name(uint32_t id, void __ return -EFAULT; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); name = vx_vhi_name(vxi, vc_data.field); if (!name) @@ -129,8 +129,8 @@ int vc_enter_namespace(uint32_t id, void return -ENOSYS; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); ret = -EINVAL; if (!vxi->vx_namespace) diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/proc.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/proc.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/proc.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/proc.c 2005-06-18 03:10:22.000000000 +0200 @@ -77,7 +77,7 @@ int proc_xid_info (int vid, char *buffer struct vx_info *vxi; int length; - vxi = locate_vx_info(vid); + vxi = __locate_vx_info(vid); if (!vxi) return 0; length = sprintf(buffer, @@ -97,7 +97,7 @@ int proc_xid_status (int vid, char *buff struct vx_info *vxi; int length; - vxi = locate_vx_info(vid); + vxi = __locate_vx_info(vid); if (!vxi) return 0; length = sprintf(buffer, @@ -123,7 +123,7 @@ int proc_xid_limit (int vid, char *buffe struct vx_info *vxi; int length; - vxi = locate_vx_info(vid); + vxi = __locate_vx_info(vid); if (!vxi) return 0; length = vx_info_proc_limit(&vxi->limit, buffer); @@ -136,7 +136,7 @@ int proc_xid_sched (int vid, char *buffe struct vx_info *vxi; int length; - vxi = locate_vx_info(vid); + vxi = __locate_vx_info(vid); if (!vxi) return 0; length = vx_info_proc_sched(&vxi->sched, buffer); @@ -149,7 +149,7 @@ int proc_xid_cvirt (int vid, char *buffe struct vx_info *vxi; int length; - vxi = locate_vx_info(vid); + vxi = __locate_vx_info(vid); if (!vxi) return 0; vx_update_load(vxi); @@ -163,7 +163,7 @@ int proc_xid_cacct (int vid, char *buffe struct vx_info *vxi; int length; - vxi = locate_vx_info(vid); + vxi = __locate_vx_info(vid); if (!vxi) return 0; length = vx_info_proc_cacct(&vxi->cacct, buffer); @@ -554,7 +554,7 @@ struct dentry *proc_virtual_lookup(struc xid = atovid(name, len); if (xid < 0) goto out; - vxi = locate_vx_info(xid); + vxi = __locate_vx_info(xid); if (!vxi) goto out; diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/sched.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/sched.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/sched.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/sched.c 2005-06-18 03:25:06.000000000 +0200 @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -131,8 +132,8 @@ int vc_set_sched_v2(uint32_t xid, void _ return -EFAULT; vxi = locate_vx_info(xid); - if (!vxi) - return -EINVAL; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); spin_lock(&vxi->sched.tokens_lock); @@ -175,8 +176,8 @@ int vc_set_sched(uint32_t xid, void __us return -EFAULT; vxi = locate_vx_info(xid); - if (!vxi) - return -EINVAL; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); set_mask = vc_data.set_mask; diff -NurpP --minimal linux-2.6.11.12-vs2.0-rc4/kernel/vserver/signal.c linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/signal.c --- linux-2.6.11.12-vs2.0-rc4/kernel/vserver/signal.c 2005-06-16 17:37:27.000000000 +0200 +++ linux-2.6.11.12-vs2.0-rc4-state_setup/kernel/vserver/signal.c 2005-06-18 03:23:15.000000000 +0200 @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -33,8 +34,8 @@ int vc_ctx_kill(uint32_t id, void __user return -EFAULT; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); retval = -ESRCH; read_lock(&tasklist_lock); @@ -109,8 +110,8 @@ int vc_wait_exit(uint32_t id, void __use int ret; vxi = locate_vx_info(id); - if (!vxi) - return -ESRCH; + if (IS_ERR(vxi)) + return PTR_ERR(vxi); ret = __wait_exit(vxi); put_vx_info(vxi);