llseek: automatically add .llseek fop
[sfrench/cifs-2.6.git] / fs / proc / base.c
index c806dfb24e082d94a14e8516ee6cecd327f926ab..bc307d7a5b7677a3c81845cf5e13ebf5273f1ffe 100644 (file)
@@ -149,18 +149,13 @@ static unsigned int pid_entry_count_dirs(const struct pid_entry *entries,
        return count;
 }
 
-static int get_fs_path(struct task_struct *task, struct path *path, bool root)
+static int get_task_root(struct task_struct *task, struct path *root)
 {
-       struct fs_struct *fs;
        int result = -ENOENT;
 
        task_lock(task);
-       fs = task->fs;
-       if (fs) {
-               read_lock(&fs->lock);
-               *path = root ? fs->root : fs->pwd;
-               path_get(path);
-               read_unlock(&fs->lock);
+       if (task->fs) {
+               get_fs_root(task->fs, root);
                result = 0;
        }
        task_unlock(task);
@@ -173,7 +168,12 @@ static int proc_cwd_link(struct inode *inode, struct path *path)
        int result = -ENOENT;
 
        if (task) {
-               result = get_fs_path(task, path, 0);
+               task_lock(task);
+               if (task->fs) {
+                       get_fs_pwd(task->fs, path);
+                       result = 0;
+               }
+               task_unlock(task);
                put_task_struct(task);
        }
        return result;
@@ -185,7 +185,7 @@ static int proc_root_link(struct inode *inode, struct path *path)
        int result = -ENOENT;
 
        if (task) {
-               result = get_fs_path(task, path, 1);
+               result = get_task_root(task, path);
                put_task_struct(task);
        }
        return result;
@@ -597,7 +597,7 @@ static int mounts_open_common(struct inode *inode, struct file *file,
                                get_mnt_ns(ns);
                }
                rcu_read_unlock();
-               if (ns && get_fs_path(task, &root, 1) == 0)
+               if (ns && get_task_root(task, &root) == 0)
                        ret = 0;
                put_task_struct(task);
        }
@@ -1151,6 +1151,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 static const struct file_operations proc_oom_score_adj_operations = {
        .read           = oom_score_adj_read,
        .write          = oom_score_adj_write,
+       .llseek         = default_llseek,
 };
 
 #ifdef CONFIG_AUDITSYSCALL
@@ -1526,7 +1527,7 @@ static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
        if (!tmp)
                return -ENOMEM;
 
-       pathname = d_path(path, tmp, PAGE_SIZE);
+       pathname = d_path_with_unreachable(path, tmp, PAGE_SIZE);
        len = PTR_ERR(pathname);
        if (IS_ERR(pathname))
                goto out;
@@ -2039,11 +2040,13 @@ static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
 static const struct file_operations proc_fdinfo_file_operations = {
        .open           = nonseekable_open,
        .read           = proc_fdinfo_read,
+       .llseek         = no_llseek,
 };
 
 static const struct file_operations proc_fd_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_readfd,
+       .llseek         = default_llseek,
 };
 
 /*
@@ -2112,6 +2115,7 @@ static int proc_readfdinfo(struct file *filp, void *dirent, filldir_t filldir)
 static const struct file_operations proc_fdinfo_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_readfdinfo,
+       .llseek         = default_llseek,
 };
 
 /*
@@ -2343,6 +2347,7 @@ static int proc_attr_dir_readdir(struct file * filp,
 static const struct file_operations proc_attr_dir_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_attr_dir_readdir,
+       .llseek         = default_llseek,
 };
 
 static struct dentry *proc_attr_dir_lookup(struct inode *dir,
@@ -2751,6 +2756,7 @@ static int proc_tgid_base_readdir(struct file * filp,
 static const struct file_operations proc_tgid_base_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_tgid_base_readdir,
+       .llseek         = default_llseek,
 };
 
 static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd){
@@ -3088,6 +3094,7 @@ static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *den
 static const struct file_operations proc_tid_base_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_tid_base_readdir,
+       .llseek         = default_llseek,
 };
 
 static const struct inode_operations proc_tid_base_inode_operations = {
@@ -3324,4 +3331,5 @@ static const struct inode_operations proc_task_inode_operations = {
 static const struct file_operations proc_task_operations = {
        .read           = generic_read_dir,
        .readdir        = proc_task_readdir,
+       .llseek         = default_llseek,
 };