Commit 3dcd25f3 authored by Jan Blunck's avatar Jan Blunck Committed by Linus Torvalds

d_path: Make proc_get_link() use a struct path argument

proc_get_link() is always called with a dentry and a vfsmount from a struct
path.  Make proc_get_link() take it directly as an argument.
Signed-off-by: default avatarJan Blunck <jblunck@suse.de>
Acked-by: default avatarChristoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Neil Brown <neilb@suse.de>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 44707fdf
...@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_struct *tsk) ...@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_struct *tsk)
return count; return count;
} }
static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) static int proc_cwd_link(struct inode *inode, struct path *path)
{ {
struct task_struct *task = get_proc_task(inode); struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL; struct fs_struct *fs = NULL;
...@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs ...@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs
} }
if (fs) { if (fs) {
read_lock(&fs->lock); read_lock(&fs->lock);
*mnt = mntget(fs->pwd.mnt); *path = fs->pwd;
*dentry = dget(fs->pwd.dentry); path_get(&fs->pwd);
read_unlock(&fs->lock); read_unlock(&fs->lock);
result = 0; result = 0;
put_fs_struct(fs); put_fs_struct(fs);
...@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs ...@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs
return result; return result;
} }
static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) static int proc_root_link(struct inode *inode, struct path *path)
{ {
struct task_struct *task = get_proc_task(inode); struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL; struct fs_struct *fs = NULL;
...@@ -186,8 +186,8 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf ...@@ -186,8 +186,8 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf
} }
if (fs) { if (fs) {
read_lock(&fs->lock); read_lock(&fs->lock);
*mnt = mntget(fs->root.mnt); *path = fs->root;
*dentry = dget(fs->root.dentry); path_get(&fs->root);
read_unlock(&fs->lock); read_unlock(&fs->lock);
result = 0; result = 0;
put_fs_struct(fs); put_fs_struct(fs);
...@@ -1170,34 +1170,30 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -1170,34 +1170,30 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
if (!proc_fd_access_allowed(inode)) if (!proc_fd_access_allowed(inode))
goto out; goto out;
error = PROC_I(inode)->op.proc_get_link(inode, &nd->path.dentry, error = PROC_I(inode)->op.proc_get_link(inode, &nd->path);
&nd->path.mnt);
nd->last_type = LAST_BIND; nd->last_type = LAST_BIND;
out: out:
return ERR_PTR(error); return ERR_PTR(error);
} }
static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt, static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
char __user *buffer, int buflen)
{ {
struct inode * inode;
char *tmp = (char*)__get_free_page(GFP_TEMPORARY); char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
char *path; char *pathname;
int len; int len;
if (!tmp) if (!tmp)
return -ENOMEM; return -ENOMEM;
inode = dentry->d_inode; pathname = d_path(path->dentry, path->mnt, tmp, PAGE_SIZE);
path = d_path(dentry, mnt, tmp, PAGE_SIZE); len = PTR_ERR(pathname);
len = PTR_ERR(path); if (IS_ERR(pathname))
if (IS_ERR(path))
goto out; goto out;
len = tmp + PAGE_SIZE - 1 - path; len = tmp + PAGE_SIZE - 1 - pathname;
if (len > buflen) if (len > buflen)
len = buflen; len = buflen;
if (copy_to_user(buffer, path, len)) if (copy_to_user(buffer, pathname, len))
len = -EFAULT; len = -EFAULT;
out: out:
free_page((unsigned long)tmp); free_page((unsigned long)tmp);
...@@ -1208,20 +1204,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b ...@@ -1208,20 +1204,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
{ {
int error = -EACCES; int error = -EACCES;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct dentry *de; struct path path;
struct vfsmount *mnt = NULL;
/* Are we allowed to snoop on the tasks file descriptors? */ /* Are we allowed to snoop on the tasks file descriptors? */
if (!proc_fd_access_allowed(inode)) if (!proc_fd_access_allowed(inode))
goto out; goto out;
error = PROC_I(inode)->op.proc_get_link(inode, &de, &mnt); error = PROC_I(inode)->op.proc_get_link(inode, &path);
if (error) if (error)
goto out; goto out;
error = do_proc_readlink(de, mnt, buffer, buflen); error = do_proc_readlink(&path, buffer, buflen);
dput(de); path_put(&path);
mntput(mnt);
out: out:
return error; return error;
} }
...@@ -1448,8 +1442,7 @@ static unsigned name_to_int(struct dentry *dentry) ...@@ -1448,8 +1442,7 @@ static unsigned name_to_int(struct dentry *dentry)
#define PROC_FDINFO_MAX 64 #define PROC_FDINFO_MAX 64
static int proc_fd_info(struct inode *inode, struct dentry **dentry, static int proc_fd_info(struct inode *inode, struct path *path, char *info)
struct vfsmount **mnt, char *info)
{ {
struct task_struct *task = get_proc_task(inode); struct task_struct *task = get_proc_task(inode);
struct files_struct *files = NULL; struct files_struct *files = NULL;
...@@ -1468,10 +1461,10 @@ static int proc_fd_info(struct inode *inode, struct dentry **dentry, ...@@ -1468,10 +1461,10 @@ static int proc_fd_info(struct inode *inode, struct dentry **dentry,
spin_lock(&files->file_lock); spin_lock(&files->file_lock);
file = fcheck_files(files, fd); file = fcheck_files(files, fd);
if (file) { if (file) {
if (mnt) if (path) {
*mnt = mntget(file->f_path.mnt); *path = file->f_path;
if (dentry) path_get(&file->f_path);
*dentry = dget(file->f_path.dentry); }
if (info) if (info)
snprintf(info, PROC_FDINFO_MAX, snprintf(info, PROC_FDINFO_MAX,
"pos:\t%lli\n" "pos:\t%lli\n"
...@@ -1488,10 +1481,9 @@ static int proc_fd_info(struct inode *inode, struct dentry **dentry, ...@@ -1488,10 +1481,9 @@ static int proc_fd_info(struct inode *inode, struct dentry **dentry,
return -ENOENT; return -ENOENT;
} }
static int proc_fd_link(struct inode *inode, struct dentry **dentry, static int proc_fd_link(struct inode *inode, struct path *path)
struct vfsmount **mnt)
{ {
return proc_fd_info(inode, dentry, mnt, NULL); return proc_fd_info(inode, path, NULL);
} }
static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
...@@ -1685,7 +1677,7 @@ static ssize_t proc_fdinfo_read(struct file *file, char __user *buf, ...@@ -1685,7 +1677,7 @@ static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
size_t len, loff_t *ppos) size_t len, loff_t *ppos)
{ {
char tmp[PROC_FDINFO_MAX]; char tmp[PROC_FDINFO_MAX];
int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, NULL, tmp); int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, tmp);
if (!err) if (!err)
err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp)); err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp));
return err; return err;
......
...@@ -48,7 +48,7 @@ extern int maps_protect; ...@@ -48,7 +48,7 @@ extern int maps_protect;
extern void create_seq_entry(char *name, mode_t mode, extern void create_seq_entry(char *name, mode_t mode,
const struct file_operations *f); const struct file_operations *f);
extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); extern int proc_exe_link(struct inode *, struct path *);
extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task); struct pid *pid, struct task_struct *task);
extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns,
......
...@@ -75,7 +75,7 @@ int task_statm(struct mm_struct *mm, int *shared, int *text, ...@@ -75,7 +75,7 @@ int task_statm(struct mm_struct *mm, int *shared, int *text,
return mm->total_vm; return mm->total_vm;
} }
int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) int proc_exe_link(struct inode *inode, struct path *path)
{ {
struct vm_area_struct * vma; struct vm_area_struct * vma;
int result = -ENOENT; int result = -ENOENT;
...@@ -98,8 +98,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount * ...@@ -98,8 +98,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount *
} }
if (vma) { if (vma) {
*mnt = mntget(vma->vm_file->f_path.mnt); *path = vma->vm_file->f_path;
*dentry = dget(vma->vm_file->f_path.dentry); path_get(&vma->vm_file->f_path);
result = 0; result = 0;
} }
......
...@@ -103,7 +103,7 @@ int task_statm(struct mm_struct *mm, int *shared, int *text, ...@@ -103,7 +103,7 @@ int task_statm(struct mm_struct *mm, int *shared, int *text,
return size; return size;
} }
int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) int proc_exe_link(struct inode *inode, struct path *path)
{ {
struct vm_list_struct *vml; struct vm_list_struct *vml;
struct vm_area_struct *vma; struct vm_area_struct *vma;
...@@ -126,8 +126,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount * ...@@ -126,8 +126,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount *
} }
if (vma) { if (vma) {
*mnt = mntget(vma->vm_file->f_path.mnt); *path = vma->vm_file->f_path;
*dentry = dget(vma->vm_file->f_path.dentry); path_get(&vma->vm_file->f_path);
result = 0; result = 0;
} }
......
...@@ -269,7 +269,7 @@ extern void kclist_add(struct kcore_list *, void *, size_t); ...@@ -269,7 +269,7 @@ extern void kclist_add(struct kcore_list *, void *, size_t);
#endif #endif
union proc_op { union proc_op {
int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **); int (*proc_get_link)(struct inode *, struct path *);
int (*proc_read)(struct task_struct *task, char *page); int (*proc_read)(struct task_struct *task, char *page);
int (*proc_show)(struct seq_file *m, int (*proc_show)(struct seq_file *m,
struct pid_namespace *ns, struct pid *pid, struct pid_namespace *ns, struct pid *pid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment