]> 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 0c2052c79243803dbc6674c590fd3f9ab44e13e4..a5fa1fdafc4e6df68df2cc87626f0d8d85bd95a6 100644 (file)
@@ -347,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;
 }
 
@@ -663,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;
@@ -671,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,
@@ -718,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)
 {
@@ -751,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
@@ -826,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)
@@ -834,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,
@@ -900,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;
@@ -908,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,
@@ -978,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);