This commit was manufactured by cvs2svn to create branch
[linux-2.6.git] / fs / proc / base.c
index 9e3a70e..199e761 100644 (file)
@@ -32,6 +32,8 @@
 #include <linux/mount.h>
 #include <linux/security.h>
 #include <linux/ptrace.h>
+#include <linux/vs_network.h>
+#include <linux/vs_cvirt.h>
 
 /*
  * For hysterical raisins we keep the same inumbers as in the old procfs.
@@ -67,6 +69,8 @@ enum pid_directory_inos {
        PROC_TGID_ATTR_EXEC,
        PROC_TGID_ATTR_FSCREATE,
 #endif
+       PROC_TGID_VX_INFO,
+       PROC_TGID_IP_INFO,
        PROC_TGID_FD_DIR,
        PROC_TID_INO,
        PROC_TID_STATUS,
@@ -89,6 +93,12 @@ enum pid_directory_inos {
        PROC_TID_ATTR_PREV,
        PROC_TID_ATTR_EXEC,
        PROC_TID_ATTR_FSCREATE,
+#endif
+       PROC_TID_VX_INFO,
+       PROC_TID_IP_INFO,
+#ifdef CONFIG_DELAY_ACCT
+        PROC_TID_DELAY_ACCT,
+        PROC_TGID_DELAY_ACCT,
 #endif
        PROC_TID_FD_DIR = 0x8000,       /* 0x8000-0xffff */
 };
@@ -111,7 +121,7 @@ static struct pid_entry tgid_base_stuff[] = {
        E(PROC_TGID_CMDLINE,   "cmdline", S_IFREG|S_IRUGO),
        E(PROC_TGID_STAT,      "stat",    S_IFREG|S_IRUGO),
        E(PROC_TGID_STATM,     "statm",   S_IFREG|S_IRUGO),
-       E(PROC_TGID_MAPS,      "maps",    S_IFREG|S_IRUGO),
+       E(PROC_TGID_MAPS,      "maps",    S_IFREG|S_IRUSR),
        E(PROC_TGID_MEM,       "mem",     S_IFREG|S_IRUSR|S_IWUSR),
        E(PROC_TGID_CWD,       "cwd",     S_IFLNK|S_IRWXUGO),
        E(PROC_TGID_ROOT,      "root",    S_IFLNK|S_IRWXUGO),
@@ -120,9 +130,14 @@ static struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_SECURITY
        E(PROC_TGID_ATTR,      "attr",    S_IFDIR|S_IRUGO|S_IXUGO),
 #endif
+#ifdef CONFIG_DELAY_ACCT
+       E(PROC_TGID_DELAY_ACCT,"delay",   S_IFREG|S_IRUGO),
+#endif
 #ifdef CONFIG_KALLSYMS
        E(PROC_TGID_WCHAN,     "wchan",   S_IFREG|S_IRUGO),
 #endif
+       E(PROC_TGID_VX_INFO,   "vinfo",   S_IFREG|S_IRUGO),
+       E(PROC_TGID_IP_INFO,   "ninfo",   S_IFREG|S_IRUGO),
        {0,0,NULL,0}
 };
 static struct pid_entry tid_base_stuff[] = {
@@ -133,7 +148,7 @@ static struct pid_entry tid_base_stuff[] = {
        E(PROC_TID_CMDLINE,    "cmdline", S_IFREG|S_IRUGO),
        E(PROC_TID_STAT,       "stat",    S_IFREG|S_IRUGO),
        E(PROC_TID_STATM,      "statm",   S_IFREG|S_IRUGO),
-       E(PROC_TID_MAPS,       "maps",    S_IFREG|S_IRUGO),
+       E(PROC_TID_MAPS,       "maps",    S_IFREG|S_IRUSR),
        E(PROC_TID_MEM,        "mem",     S_IFREG|S_IRUSR|S_IWUSR),
        E(PROC_TID_CWD,        "cwd",     S_IFLNK|S_IRWXUGO),
        E(PROC_TID_ROOT,       "root",    S_IFLNK|S_IRWXUGO),
@@ -142,9 +157,14 @@ static struct pid_entry tid_base_stuff[] = {
 #ifdef CONFIG_SECURITY
        E(PROC_TID_ATTR,       "attr",    S_IFDIR|S_IRUGO|S_IXUGO),
 #endif
+#ifdef CONFIG_DELAY_ACCT
+       E(PROC_TGID_DELAY_ACCT,"delay",   S_IFREG|S_IRUGO),
+#endif
 #ifdef CONFIG_KALLSYMS
        E(PROC_TID_WCHAN,      "wchan",   S_IFREG|S_IRUGO),
 #endif
+       E(PROC_TID_VX_INFO,    "vinfo",   S_IFREG|S_IRUGO),
+       E(PROC_TID_IP_INFO,    "ninfo",   S_IFREG|S_IRUGO),
        {0,0,NULL,0}
 };
 
@@ -181,6 +201,7 @@ int proc_pid_stat(struct task_struct*,char*);
 int proc_pid_status(struct task_struct*,char*);
 int proc_pid_statm(struct task_struct*,char*);
 int proc_pid_cpu(struct task_struct*,char*);
+int proc_pid_delay(struct task_struct*,char*);
 
 static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
 {
@@ -954,6 +975,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
                inode->i_uid = task->euid;
                inode->i_gid = task->egid;
        }
+       inode->i_xid = vx_task_xid(task);
        security_task_to_inode(task, inode);
 
 out:
@@ -979,6 +1001,11 @@ static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *inode = dentry->d_inode;
        struct task_struct *task = proc_task(inode);
+
+       if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               goto out_drop;
+       /* discard wrong fakeinit */
+
        if (pid_alive(task)) {
                if (proc_type(inode) == PROC_TGID_INO || proc_type(inode) == PROC_TID_INO || task_dumpable(task)) {
                        inode->i_uid = task->euid;
@@ -990,6 +1017,7 @@ static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
                security_task_to_inode(task, inode);
                return 1;
        }
+out_drop:
        d_drop(dentry);
        return 0;
 }
@@ -1374,6 +1402,23 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
                        inode->i_fop = &proc_info_file_operations;
                        ei->op.proc_read = proc_pid_wchan;
                        break;
+#endif
+               case PROC_TID_VX_INFO:
+               case PROC_TGID_VX_INFO:
+                       inode->i_fop = &proc_info_file_operations;
+                       ei->op.proc_read = proc_pid_vx_info;
+                       break;
+               case PROC_TID_IP_INFO:
+               case PROC_TGID_IP_INFO:
+                       inode->i_fop = &proc_info_file_operations;
+                       ei->op.proc_read = proc_pid_nx_info;
+                       break;
+#ifdef CONFIG_DELAY_ACCT
+               case PROC_TID_DELAY_ACCT:
+               case PROC_TGID_DELAY_ACCT:
+                       inode->i_fop = &proc_info_file_operations;
+                       ei->op.proc_read = proc_pid_delay;
+                       break;
 #endif
                default:
                        printk("procfs: impossible type (%d)",p->type);
@@ -1526,6 +1571,7 @@ struct dentry *proc_pid_unhash(struct task_struct *p)
        
 void proc_pid_flush(struct dentry *proc_dentry)
 {
+       might_sleep();
        if(proc_dentry != NULL) {
                shrink_dcache_parent(proc_dentry);
                dput(proc_dentry);
@@ -1556,7 +1602,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
                d_add(dentry, inode);
                return NULL;
        }
-       tgid = name_to_int(dentry);
+       tgid = vx_rmap_tgid(current->vx_info, name_to_int(dentry));
        if (tgid == ~0U)
                goto out;
 
@@ -1568,8 +1614,9 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
        if (!task)
                goto out;
 
-       inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
-
+       inode = NULL;
+       if (vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
 
        if (!inode) {
                put_task_struct(task);
@@ -1611,10 +1658,12 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry
        struct inode *inode;
        unsigned tid;
 
-       tid = name_to_int(dentry);
+       tid = vx_rmap_tgid(current->vx_info, name_to_int(dentry));
        if (tid == ~0U)
                goto out;
 
+/*     handle fakeinit */
+
        read_lock(&tasklist_lock);
        task = find_task_by_pid(tid);
        if (task)
@@ -1625,8 +1674,9 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry
        if (leader->tgid != task->tgid)
                goto out_drop_task;
 
-       inode = proc_pid_make_inode(dir->i_sb, task, PROC_TID_INO);
-
+       inode = NULL;
+       if (vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               inode = proc_pid_make_inode(dir->i_sb, task, PROC_TID_INO);
 
        if (!inode)
                goto out_drop_task;
@@ -1677,11 +1727,14 @@ static int get_tgid_list(int index, unsigned long version, unsigned int *tgids)
 
        for ( ; p != &init_task; p = next_task(p)) {
                int tgid = p->pid;
+
                if (!pid_alive(p))
                        continue;
+               if (!vx_check(vx_task_xid(p), VX_WATCH|VX_IDENT))
+                       continue;
                if (--index >= 0)
                        continue;
-               tgids[nr_tgids] = tgid;
+               tgids[nr_tgids] = vx_map_tgid(current->vx_info, tgid);
                nr_tgids++;
                if (nr_tgids >= PROC_MAXPIDS)
                        break;
@@ -1711,9 +1764,11 @@ static int get_tid_list(int index, unsigned int *tids, struct inode *dir)
        if (pid_alive(task)) do {
                int tid = task->pid;
 
+               if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+                       continue;
                if (--index >= 0)
                        continue;
-               tids[nr_tids] = tid;
+               tids[nr_tids] = vx_map_tgid(current->vx_info, tid);
                nr_tids++;
                if (nr_tids >= PROC_MAXPIDS)
                        break;
@@ -1769,11 +1824,14 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
        unsigned int nr_tids, i;
        struct dentry *dentry = filp->f_dentry;
        struct inode *inode = dentry->d_inode;
+       struct task_struct *task = proc_task(inode);
        int retval = -ENOENT;
        ino_t ino;
        unsigned long pos = filp->f_pos;  /* avoiding "long long" filp->f_pos */
 
-       if (!pid_alive(proc_task(inode)))
+       if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               goto out;
+       if (!pid_alive(task))
                goto out;
        retval = 0;