Merge to Fedora kernel-2.6.18-1.2239_FC5 patched with stable patch-2.6.18.2-vs2.0...
[linux-2.6.git] / include / linux / vs_cvirt.h
index 616706e..c6aa9d3 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "vserver/cvirt.h"
 #include "vserver/debug.h"
-#include "vs_base.h"
 
 
 /* utsname virtualization */
@@ -23,6 +22,7 @@ static inline struct new_utsname *vx_new_utsname(void)
 
 #define vx_info_map_pid(v,p) \
        __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
+#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
 #define vx_map_pid(p)  vx_info_map_pid(current->vx_info, p)
 #define vx_map_tgid(p) vx_map_pid(p)
 
@@ -70,11 +70,9 @@ static inline void vx_activate_task(struct task_struct *p)
 {
        struct vx_info *vxi;
 
-       // if ((vxi = task_get_vx_info(p))) {
        if ((vxi = p->vx_info)) {
                vx_update_load(vxi);
                atomic_inc(&vxi->cvirt.nr_running);
-               // put_vx_info(vxi);
        }
 }
 
@@ -82,14 +80,77 @@ static inline void vx_deactivate_task(struct task_struct *p)
 {
        struct vx_info *vxi;
 
-       // if ((vxi = task_get_vx_info(p))) {
        if ((vxi = p->vx_info)) {
                vx_update_load(vxi);
                atomic_dec(&vxi->cvirt.nr_running);
-               // put_vx_info(vxi);
        }
 }
 
+static inline void vx_uninterruptible_inc(struct task_struct *p)
+{
+       struct vx_info *vxi;
+
+       if ((vxi = p->vx_info))
+               atomic_inc(&vxi->cvirt.nr_uninterruptible);
+}
+
+static inline void vx_uninterruptible_dec(struct task_struct *p)
+{
+       struct vx_info *vxi;
+
+       if ((vxi = p->vx_info))
+               atomic_dec(&vxi->cvirt.nr_uninterruptible);
+}
+
+
+struct inode;
+
+#define VXF_FAKE_INIT  (VXF_INFO_INIT|VXF_STATE_INIT)
+
+static inline
+int proc_pid_visible(struct task_struct *task, int pid)
+{
+       if ((pid == 1) &&
+               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
+               /* show a blend through init */
+               goto visible;
+       if (vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               goto visible;
+       return 0;
+visible:
+       return 1;
+}
+
+static inline
+struct task_struct *find_proc_task_by_pid(int pid)
+{
+       struct task_struct *task = find_task_by_pid(pid);
+
+       if (task && !proc_pid_visible(task, pid)) {
+               vxdprintk(VXD_CBIT(misc, 6),
+                       "dropping task %p[#%u,%u] for %p[#%u,%u]",
+                       task, task->xid, task->pid,
+                       current, current->xid, current->pid);
+               task = NULL;
+       }
+       return task;
+}
+
+static inline
+struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
+{
+       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
+
+       if (task && !proc_pid_visible(task, pid->nr)) {
+               vxdprintk(VXD_CBIT(misc, 6),
+                       "dropping task %p[#%u,%u] for %p[#%u,%u]",
+                       task, task->xid, task->pid,
+                       current, current->xid, current->pid);
+               put_task_struct(task);
+               task = NULL;
+       }
+       return task;
+}
 
 #else
 #warning duplicate inclusion