From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Blunck <jblunck@suse.de>,
Andreas Gruenbacher <agruen@suse.de>,
Christoph Hellwig <hch@lst.de>,
viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Subject: [PATCH 12/13] Use struct path argument in proc_get_link()
Date: Mon, 22 Oct 2007 12:33:29 +0530 [thread overview]
Message-ID: <20071022070329.GM6489@in.ibm.com> (raw)
In-Reply-To: <20071022065352.GA6489@in.ibm.com>
Replace the (vfsmnt, dentry) arguments in proc_inode operation proc_get_link()
by struct path.
Also, this should eventually allow do_proc_readlink() to call d_path() with
a struct path argument.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
fs/proc/base.c | 60 +++++++++++++++++++++---------------------------
fs/proc/internal.h | 2 -
fs/proc/task_mmu.c | 6 ++--
fs/proc/task_nommu.c | 6 ++--
include/linux/proc_fs.h | 2 -
5 files changed, 35 insertions(+), 41 deletions(-)
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_st
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 fs_struct *fs = NULL;
@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *i
}
if (fs) {
read_lock(&fs->lock);
- *mnt = mntget(fs->pwd.mnt);
- *dentry = dget(fs->pwd.dentry);
+ *path = fs->pwd;
+ path_get(path);
read_unlock(&fs->lock);
result = 0;
put_fs_struct(fs);
@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *i
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 fs_struct *fs = NULL;
@@ -186,8 +186,8 @@ static int proc_root_link(struct inode *
}
if (fs) {
read_lock(&fs->lock);
- *mnt = mntget(fs->root.mnt);
- *dentry = dget(fs->root.dentry);
+ *path = fs->root;
+ path_get(path);
read_unlock(&fs->lock);
result = 0;
put_fs_struct(fs);
@@ -1039,34 +1039,32 @@ static void *proc_pid_follow_link(struct
if (!proc_fd_access_allowed(inode))
goto out;
- error = PROC_I(inode)->op.proc_get_link(inode, &nd->path.dentry,
- &nd->path.mnt);
+ error = PROC_I(inode)->op.proc_get_link(inode, &nd->path);
nd->last_type = LAST_BIND;
out:
return ERR_PTR(error);
}
-static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,
- char __user *buffer, int buflen)
+static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
{
struct inode * inode;
char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
- char *path;
+ char *pathname;
int len;
if (!tmp)
return -ENOMEM;
- inode = dentry->d_inode;
- path = d_path(dentry, mnt, tmp, PAGE_SIZE);
- len = PTR_ERR(path);
- if (IS_ERR(path))
+ inode = path->dentry->d_inode;
+ pathname = d_path(path->dentry, path->mnt, tmp, PAGE_SIZE);
+ len = PTR_ERR(pathname);
+ if (IS_ERR(pathname))
goto out;
- len = tmp + PAGE_SIZE - 1 - path;
+ len = tmp + PAGE_SIZE - 1 - pathname;
if (len > buflen)
len = buflen;
- if (copy_to_user(buffer, path, len))
+ if (copy_to_user(buffer, pathname, len))
len = -EFAULT;
out:
free_page((unsigned long)tmp);
@@ -1077,20 +1075,18 @@ static int proc_pid_readlink(struct dent
{
int error = -EACCES;
struct inode *inode = dentry->d_inode;
- struct dentry *de;
- struct vfsmount *mnt = NULL;
+ struct path path;
/* Are we allowed to snoop on the tasks file descriptors? */
if (!proc_fd_access_allowed(inode))
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)
goto out;
- error = do_proc_readlink(de, mnt, buffer, buflen);
- dput(de);
- mntput(mnt);
+ error = do_proc_readlink(&path, buffer, buflen);
+ path_put(&path);
out:
return error;
}
@@ -1317,8 +1313,7 @@ out:
#define PROC_FDINFO_MAX 64
-static int proc_fd_info(struct inode *inode, struct dentry **dentry,
- struct vfsmount **mnt, char *info)
+static int proc_fd_info(struct inode *inode, struct path *path, char *info)
{
struct task_struct *task = get_proc_task(inode);
struct files_struct *files = NULL;
@@ -1337,10 +1332,10 @@ static int proc_fd_info(struct inode *in
spin_lock(&files->file_lock);
file = fcheck_files(files, fd);
if (file) {
- if (mnt)
- *mnt = mntget(file->f_path.mnt);
- if (dentry)
- *dentry = dget(file->f_path.dentry);
+ if (path) {
+ *path = file->f_path;
+ path_get(path);
+ }
if (info)
snprintf(info, PROC_FDINFO_MAX,
"pos:\t%lli\n"
@@ -1357,10 +1352,9 @@ static int proc_fd_info(struct inode *in
return -ENOENT;
}
-static int proc_fd_link(struct inode *inode, struct dentry **dentry,
- struct vfsmount **mnt)
+static int proc_fd_link(struct inode *inode, struct path *path)
{
- 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)
@@ -1554,7 +1548,7 @@ static ssize_t proc_fdinfo_read(struct f
size_t len, loff_t *ppos)
{
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)
err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp));
return err;
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -45,7 +45,7 @@ extern int nommu_vma_show(struct seq_fil
extern int maps_protect;
extern void create_seq_entry(char *name, mode_t mode, 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 task_struct *, char *);
extern int proc_tgid_stat(struct task_struct *, char *);
extern int proc_pid_status(struct task_struct *, char *);
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -73,7 +73,7 @@ int task_statm(struct mm_struct *mm, int
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;
int result = -ENOENT;
@@ -96,8 +96,8 @@ int proc_exe_link(struct inode *inode, s
}
if (vma) {
- *mnt = mntget(vma->vm_file->f_path.mnt);
- *dentry = dget(vma->vm_file->f_path.dentry);
+ *path = vma->vm_file->f_path;
+ path_get(path);
result = 0;
}
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -104,7 +104,7 @@ int task_statm(struct mm_struct *mm, int
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_area_struct *vma;
@@ -127,8 +127,8 @@ int proc_exe_link(struct inode *inode, s
}
if (vma) {
- *mnt = mntget(vma->vm_file->f_path.mnt);
- *dentry = dget(vma->vm_file->f_path.dentry);
+ *path = vma->vm_file->f_path;
+ path_get(path);
result = 0;
}
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -257,7 +257,7 @@ extern void kclist_add(struct kcore_list
#endif
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);
};
next prev parent reply other threads:[~2007-10-22 7:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-22 6:53 [PATCH 00/13] Use struct path in struct nameidata Bharata B Rao
2007-10-22 6:54 ` [PATCH 01/13] Don't touch fs_struct in drivers Bharata B Rao
2007-10-22 6:55 ` [PATCH 02/13] Don't touch fs_struct in usermodehelper Bharata B Rao
2007-10-22 6:56 ` [PATCH 03/13] Remove path_release_on_umount() Bharata B Rao
2007-10-22 6:57 ` [PATCH 04/13] Move struct path into its own header Bharata B Rao
2007-10-22 6:58 ` [PATCH 05/13] Embed a struct path into struct nameidata instead of nd->{dentry,mnt} Bharata B Rao
2007-10-22 6:59 ` [PATCH 06/13] Introduce path_put() Bharata B Rao
2007-10-22 6:59 ` [PATCH 07/13] Use path_put() in a few places instead of {mnt,d}put() Bharata B Rao
2007-10-22 7:00 ` [PATCH 08/13] Introduce path_get() Bharata B Rao
2007-10-22 7:01 ` [PATCH 09/13] Use struct path in fs_struct Bharata B Rao
2007-10-22 7:02 ` [PATCH 10/13] Make set_fs_{root,pwd} take a struct path Bharata B Rao
2007-10-22 7:02 ` [PATCH 11/13] Make __d_path() to take a struct path argument Bharata B Rao
2007-10-22 7:03 ` Bharata B Rao [this message]
2007-10-22 7:04 ` [PATCH 13/13] Rename {__}d_path() to {__}print_path() and fix comments Bharata B Rao
2007-10-22 10:14 ` Christoph Hellwig
2007-10-22 22:56 ` Andrew Morton
2007-10-22 13:57 ` [PATCH 00/13] Use struct path in struct nameidata Christoph Hellwig
2007-10-22 22:56 ` Andrew Morton
2007-10-23 8:39 ` Jan Blunck
2007-10-23 2:33 ` Bharata B Rao
2007-10-23 8:43 ` Jan Blunck
2007-10-24 3:31 ` Bharata B Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071022070329.GM6489@in.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=agruen@suse.de \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=jblunck@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.