]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/proc/base.c
[PATCH] sysctl: create sys/fs/binfmt_misc as an ordinary sysctl entry
[linux-2.6-omap-h63xx.git] / fs / proc / base.c
index 77a57b5799c41cfc2fe84b0bdba00d66b8072eec..4f5745af8c193809f37d9f2cfa78be383d42ef9c 100644 (file)
@@ -93,8 +93,8 @@ struct pid_entry {
        int len;
        char *name;
        mode_t mode;
-       struct inode_operations *iop;
-       struct file_operations *fop;
+       const struct inode_operations *iop;
+       const struct file_operations *fop;
        union proc_op op;
 };
 
@@ -352,7 +352,7 @@ static int proc_setattr(struct dentry *dentry, struct iattr *attr)
        return error;
 }
 
-static struct inode_operations proc_def_inode_operations = {
+static const struct inode_operations proc_def_inode_operations = {
        .setattr        = proc_setattr,
 };
 
@@ -371,9 +371,11 @@ static int mounts_open(struct inode *inode, struct file *file)
 
        if (task) {
                task_lock(task);
-               ns = task->nsproxy->mnt_ns;
-               if (ns)
-                       get_mnt_ns(ns);
+               if (task->nsproxy) {
+                       ns = task->nsproxy->mnt_ns;
+                       if (ns)
+                               get_mnt_ns(ns);
+               }
                task_unlock(task);
                put_task_struct(task);
        }
@@ -422,7 +424,7 @@ static unsigned mounts_poll(struct file *file, poll_table *wait)
        return res;
 }
 
-static struct file_operations proc_mounts_operations = {
+static const struct file_operations proc_mounts_operations = {
        .open           = mounts_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -460,7 +462,7 @@ static int mountstats_open(struct inode *inode, struct file *file)
        return ret;
 }
 
-static struct file_operations proc_mountstats_operations = {
+static const struct file_operations proc_mountstats_operations = {
        .open           = mountstats_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -499,7 +501,7 @@ out_no_task:
        return length;
 }
 
-static struct file_operations proc_info_file_operations = {
+static const struct file_operations proc_info_file_operations = {
        .read           = proc_info_read,
 };
 
@@ -644,7 +646,7 @@ static loff_t mem_lseek(struct file * file, loff_t offset, int orig)
        return file->f_pos;
 }
 
-static struct file_operations proc_mem_operations = {
+static const struct file_operations proc_mem_operations = {
        .llseek         = mem_lseek,
        .read           = mem_read,
        .write          = mem_write,
@@ -708,7 +710,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
        return end - buffer;
 }
 
-static struct file_operations proc_oom_adjust_operations = {
+static const struct file_operations proc_oom_adjust_operations = {
        .read           = oom_adjust_read,
        .write          = oom_adjust_write,
 };
@@ -775,7 +777,7 @@ out_free_page:
        return length;
 }
 
-static struct file_operations proc_loginuid_operations = {
+static const struct file_operations proc_loginuid_operations = {
        .read           = proc_loginuid_read,
        .write          = proc_loginuid_write,
 };
@@ -847,7 +849,7 @@ out_no_task:
        return result;
 }
 
-static struct file_operations proc_seccomp_operations = {
+static const struct file_operations proc_seccomp_operations = {
        .read           = seccomp_read,
        .write          = seccomp_write,
 };
@@ -906,7 +908,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
        return end - buffer;
 }
 
-static struct file_operations proc_fault_inject_operations = {
+static const struct file_operations proc_fault_inject_operations = {
        .read           = proc_fault_inject_read,
        .write          = proc_fault_inject_write,
 };
@@ -978,7 +980,7 @@ out:
        return error;
 }
 
-static struct inode_operations proc_pid_link_inode_operations = {
+static const struct inode_operations proc_pid_link_inode_operations = {
        .readlink       = proc_pid_readlink,
        .follow_link    = proc_pid_follow_link,
        .setattr        = proc_setattr,
@@ -1406,7 +1408,7 @@ out_no_task:
        return retval;
 }
 
-static struct file_operations proc_fd_operations = {
+static const struct file_operations proc_fd_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_readfd,
 };
@@ -1414,7 +1416,7 @@ static struct file_operations proc_fd_operations = {
 /*
  * proc directories can do almost nothing..
  */
-static struct inode_operations proc_fd_inode_operations = {
+static const struct inode_operations proc_fd_inode_operations = {
        .lookup         = proc_lookupfd,
        .setattr        = proc_setattr,
 };
@@ -1621,7 +1623,7 @@ out_no_task:
        return length;
 }
 
-static struct file_operations proc_pid_attr_operations = {
+static const struct file_operations proc_pid_attr_operations = {
        .read           = proc_pid_attr_read,
        .write          = proc_pid_attr_write,
 };
@@ -1642,7 +1644,7 @@ static int proc_attr_dir_readdir(struct file * filp,
                                   attr_dir_stuff,ARRAY_SIZE(attr_dir_stuff));
 }
 
-static struct file_operations proc_attr_dir_operations = {
+static const struct file_operations proc_attr_dir_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_attr_dir_readdir,
 };
@@ -1654,7 +1656,7 @@ static struct dentry *proc_attr_dir_lookup(struct inode *dir,
                                  attr_dir_stuff, ARRAY_SIZE(attr_dir_stuff));
 }
 
-static struct inode_operations proc_attr_dir_inode_operations = {
+static const struct inode_operations proc_attr_dir_inode_operations = {
        .lookup         = proc_attr_dir_lookup,
        .getattr        = pid_getattr,
        .setattr        = proc_setattr,
@@ -1680,7 +1682,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
        return ERR_PTR(vfs_follow_link(nd,tmp));
 }
 
-static struct inode_operations proc_self_inode_operations = {
+static const struct inode_operations proc_self_inode_operations = {
        .readlink       = proc_self_readlink,
        .follow_link    = proc_self_follow_link,
 };
@@ -1808,17 +1810,21 @@ static int proc_base_fill_cache(struct file *filp, void *dirent, filldir_t filld
 static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
 {
        return sprintf(buffer,
+#ifdef CONFIG_TASK_XACCT
                        "rchar: %llu\n"
                        "wchar: %llu\n"
                        "syscr: %llu\n"
                        "syscw: %llu\n"
+#endif
                        "read_bytes: %llu\n"
                        "write_bytes: %llu\n"
                        "cancelled_write_bytes: %llu\n",
+#ifdef CONFIG_TASK_XACCT
                        (unsigned long long)task->rchar,
                        (unsigned long long)task->wchar,
                        (unsigned long long)task->syscr,
                        (unsigned long long)task->syscw,
+#endif
                        (unsigned long long)task->ioac.read_bytes,
                        (unsigned long long)task->ioac.write_bytes,
                        (unsigned long long)task->ioac.cancelled_write_bytes);
@@ -1828,8 +1834,8 @@ static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
 /*
  * Thread groups
  */
-static struct file_operations proc_task_operations;
-static struct inode_operations proc_task_inode_operations;
+static const struct file_operations proc_task_operations;
+static const struct inode_operations proc_task_inode_operations;
 
 static struct pid_entry tgid_base_stuff[] = {
        DIR("task",       S_IRUGO|S_IXUGO, task),
@@ -1888,7 +1894,7 @@ static int proc_tgid_base_readdir(struct file * filp,
                                   tgid_base_stuff,ARRAY_SIZE(tgid_base_stuff));
 }
 
-static struct file_operations proc_tgid_base_operations = {
+static const struct file_operations proc_tgid_base_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_tgid_base_readdir,
 };
@@ -1898,7 +1904,7 @@ static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *de
                                  tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));
 }
 
-static struct inode_operations proc_tgid_base_inode_operations = {
+static const struct inode_operations proc_tgid_base_inode_operations = {
        .lookup         = proc_tgid_base_lookup,
        .getattr        = pid_getattr,
        .setattr        = proc_setattr,
@@ -2171,12 +2177,12 @@ static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *den
                                  tid_base_stuff, ARRAY_SIZE(tid_base_stuff));
 }
 
-static struct file_operations proc_tid_base_operations = {
+static const struct file_operations proc_tid_base_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_tid_base_readdir,
 };
 
-static struct inode_operations proc_tid_base_inode_operations = {
+static const struct inode_operations proc_tid_base_inode_operations = {
        .lookup         = proc_tid_base_lookup,
        .getattr        = pid_getattr,
        .setattr        = proc_setattr,
@@ -2326,13 +2332,23 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
 {
        struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
-       struct task_struct *leader = get_proc_task(inode);
+       struct task_struct *leader = NULL;
        struct task_struct *task;
        int retval = -ENOENT;
        ino_t ino;
        int tid;
        unsigned long pos = filp->f_pos;  /* avoiding "long long" filp->f_pos */
 
+       task = get_proc_task(inode);
+       if (!task)
+               goto out_no_task;
+       rcu_read_lock();
+       if (pid_alive(task)) {
+               leader = task->group_leader;
+               get_task_struct(leader);
+       }
+       rcu_read_unlock();
+       put_task_struct(task);
        if (!leader)
                goto out_no_task;
        retval = 0;
@@ -2392,13 +2408,13 @@ static int proc_task_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
        return 0;
 }
 
-static struct inode_operations proc_task_inode_operations = {
+static const struct inode_operations proc_task_inode_operations = {
        .lookup         = proc_task_lookup,
        .getattr        = proc_task_getattr,
        .setattr        = proc_setattr,
 };
 
-static struct file_operations proc_task_operations = {
+static const struct file_operations proc_task_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_task_readdir,
 };