]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/proc/base.c
smaps: only define clear_refs for CONFIG_MMU
[linux-2.6-omap-h63xx.git] / fs / proc / base.c
index 0697fd089de892e6f8eb5c456f01211cc81ebfe9..a5fa1fdafc4e6df68df2cc87626f0d8d85bd95a6 100644 (file)
@@ -61,7 +61,6 @@
 #include <linux/namei.h>
 #include <linux/mnt_namespace.h>
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
 #include <linux/rcupdate.h>
 #include <linux/kallsyms.h>
 #include <linux/module.h>
@@ -279,17 +278,15 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
  */
 static int proc_pid_wchan(struct task_struct *task, char *buffer)
 {
-       char *modname;
-       const char *sym_name;
-       unsigned long wchan, size, offset;
-       char namebuf[KSYM_NAME_LEN+1];
+       unsigned long wchan;
+       char symname[KSYM_NAME_LEN+1];
 
        wchan = get_wchan(task);
 
-       sym_name = kallsyms_lookup(wchan, &size, &offset, &modname, namebuf);
-       if (sym_name)
-               return sprintf(buffer, "%s", sym_name);
-       return sprintf(buffer, "%lu", wchan);
+       if (lookup_symbol_name(wchan, symname) < 0)
+               return sprintf(buffer, "%lu", wchan);
+       else
+               return sprintf(buffer, "%s", symname);
 }
 #endif /* CONFIG_KALLSYMS */
 
@@ -314,7 +311,9 @@ static int proc_oom_score(struct task_struct *task, char *buffer)
        struct timespec uptime;
 
        do_posix_clock_monotonic_gettime(&uptime);
+       read_lock(&tasklist_lock);
        points = badness(task, uptime.tv_sec);
+       read_unlock(&tasklist_lock);
        return sprintf(buffer, "%lu\n", points);
 }
 
@@ -348,11 +347,8 @@ static int proc_setattr(struct dentry *dentry, struct iattr *attr)
                return -EPERM;
 
        error = inode_change_ok(inode, attr);
-       if (!error) {
-               error = security_inode_setattr(dentry, attr);
-               if (!error)
-                       error = inode_setattr(inode, attr);
-       }
+       if (!error)
+               error = inode_setattr(inode, attr);
        return error;
 }
 
@@ -664,7 +660,6 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
        char buffer[PROC_NUMBUF];
        size_t len;
        int oom_adjust;
-       loff_t __ppos = *ppos;
 
        if (!task)
                return -ESRCH;
@@ -672,14 +667,8 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
        put_task_struct(task);
 
        len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
-       if (__ppos >= len)
-               return 0;
-       if (count > len-__ppos)
-               count = len-__ppos;
-       if (copy_to_user(buf, buffer + __ppos, count))
-               return -EFAULT;
-       *ppos = __ppos + count;
-       return count;
+
+       return simple_read_from_buffer(buf, count, ppos, buffer, len);
 }
 
 static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
@@ -719,6 +708,7 @@ static const struct file_operations proc_oom_adjust_operations = {
        .write          = oom_adjust_write,
 };
 
+#ifdef CONFIG_MMU
 static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                                size_t count, loff_t *ppos)
 {
@@ -752,6 +742,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 static struct file_operations proc_clear_refs_operations = {
        .write          = clear_refs_write,
 };
+#endif
 
 #ifdef CONFIG_AUDITSYSCALL
 #define TMPBUFLEN 21
@@ -827,7 +818,6 @@ static ssize_t seccomp_read(struct file *file, char __user *buf,
 {
        struct task_struct *tsk = get_proc_task(file->f_dentry->d_inode);
        char __buf[20];
-       loff_t __ppos = *ppos;
        size_t len;
 
        if (!tsk)
@@ -835,14 +825,8 @@ static ssize_t seccomp_read(struct file *file, char __user *buf,
        /* no need to print the trailing zero, so use only len */
        len = sprintf(__buf, "%u\n", tsk->seccomp.mode);
        put_task_struct(tsk);
-       if (__ppos >= len)
-               return 0;
-       if (count > len - __ppos)
-               count = len - __ppos;
-       if (copy_to_user(buf, __buf + __ppos, count))
-               return -EFAULT;
-       *ppos = __ppos + count;
-       return count;
+
+       return simple_read_from_buffer(buf, count, ppos, __buf, len);
 }
 
 static ssize_t seccomp_write(struct file *file, const char __user *buf,
@@ -901,7 +885,6 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
        char buffer[PROC_NUMBUF];
        size_t len;
        int make_it_fail;
-       loff_t __ppos = *ppos;
 
        if (!task)
                return -ESRCH;
@@ -909,14 +892,8 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
        put_task_struct(task);
 
        len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail);
-       if (__ppos >= len)
-               return 0;
-       if (count > len-__ppos)
-               count = len-__ppos;
-       if (copy_to_user(buf, buffer + __ppos, count))
-               return -EFAULT;
-       *ppos = __ppos + count;
-       return count;
+
+       return simple_read_from_buffer(buf, count, ppos, buffer, len);
 }
 
 static ssize_t proc_fault_inject_write(struct file * file,
@@ -979,7 +956,7 @@ static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,
 
        if (!tmp)
                return -ENOMEM;
-               
+
        inode = dentry->d_inode;
        path = d_path(dentry, mnt, tmp, PAGE_SIZE);
        len = PTR_ERR(path);