d_path: Make d_path() use a struct path
authorJan Blunck <jblunck@suse.de>
Fri, 15 Feb 2008 03:38:44 +0000 (19:38 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 15 Feb 2008 05:17:09 +0000 (21:17 -0800)
d_path() is used on a <dentry,vfsmount> pair.  Lets use a struct path to
reflect this.

[akpm@linux-foundation.org: fix build in mm/memory.c]
Signed-off-by: Jan Blunck <jblunck@suse.de>
Acked-by: Bryan Wu <bryan.wu@analog.com>
Acked-by: Christoph 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: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 files changed:
arch/blackfin/kernel/traps.c
drivers/md/bitmap.c
drivers/usb/gadget/file_storage.c
fs/compat_ioctl.c
fs/dcache.c
fs/dcookies.c
fs/nfsd/export.c
fs/proc/base.c
fs/seq_file.c
include/linux/dcache.h
kernel/audit.c
mm/memory.c

index 58717cb19707f30e667f5032703809de34d8f9c8..56a67ab698c7a6a69cee1a04d20b72b1e1d7cd6d 100644 (file)
@@ -126,15 +126,13 @@ static void decode_address(char *buf, unsigned long address)
                        struct vm_area_struct *vma = vml->vma;
 
                        if (address >= vma->vm_start && address < vma->vm_end) {
+                               char _tmpbuf[256];
                                char *name = p->comm;
                                struct file *file = vma->vm_file;
-                               if (file) {
-                                       char _tmpbuf[256];
-                                       name = d_path(file->f_dentry,
-                                                     file->f_vfsmnt,
-                                                     _tmpbuf,
-                                                     sizeof(_tmpbuf));
-                               }
+
+                               if (file)
+                                       name = d_path(&file->f_path, _tmpbuf,
+                                                     sizeof(_tmpbuf));
 
                                /* FLAT does not have its text aligned to the start of
                                 * the map while FDPIC ELF does ...
index a0585fb6da94304758e7294f7b5288f0bbe1846f..7aeceedcf7d46de93824a14ce9b93888350930dd 100644 (file)
@@ -206,16 +206,10 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
 /* copy the pathname of a file to a buffer */
 char *file_path(struct file *file, char *buf, int count)
 {
-       struct dentry *d;
-       struct vfsmount *v;
-
        if (!buf)
                return NULL;
 
-       d = file->f_path.dentry;
-       v = file->f_path.mnt;
-
-       buf = d_path(d, v, buf, count);
+       buf = d_path(&file->f_path, buf, count);
 
        return IS_ERR(buf) ? NULL : buf;
 }
index 3301167d4f2a9eba4827b818dbaaf67fbf1ddc90..017a196d041fe58d9617aa2c52148c9f3b258e64 100644 (file)
@@ -3563,8 +3563,7 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr,
 
        down_read(&fsg->filesem);
        if (backing_file_is_open(curlun)) {     // Get the complete pathname
-               p = d_path(curlun->filp->f_path.dentry,
-                               curlun->filp->f_path.mnt, buf, PAGE_SIZE - 1);
+               p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
                if (IS_ERR(p))
                        rc = PTR_ERR(p);
                else {
@@ -3981,9 +3980,8 @@ static int __init fsg_bind(struct usb_gadget *gadget)
                if (backing_file_is_open(curlun)) {
                        p = NULL;
                        if (pathbuf) {
-                               p = d_path(curlun->filp->f_path.dentry,
-                                       curlun->filp->f_path.mnt,
-                                       pathbuf, PATH_MAX);
+                               p = d_path(&curlun->filp->f_path,
+                                          pathbuf, PATH_MAX);
                                if (IS_ERR(p))
                                        p = NULL;
                        }
index ee32c0eac7c1078576d1a17bfa03b11c45c4146c..c6e72aebd16b43e7b16339cb69869472fccbdd24 100644 (file)
@@ -2853,7 +2853,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd,
        /* find the name of the device. */
        path = (char *)__get_free_page(GFP_KERNEL);
        if (path) {
-               fn = d_path(filp->f_path.dentry, filp->f_path.mnt, path, PAGE_SIZE);
+               fn = d_path(&filp->f_path, path, PAGE_SIZE);
                if (IS_ERR(fn))
                        fn = "?";
        }
index 170efbcb1a9b5be6639a53946812ce26f00554f3..7b4b080219f8e2238b8de00ff5351b72b2bf722a 100644 (file)
@@ -1845,8 +1845,7 @@ Elong:
 
 /**
  * d_path - return the path of a dentry
- * @dentry: dentry to report
- * @vfsmnt: vfsmnt to which the dentry belongs
+ * @path: path to report
  * @buf: buffer to return value in
  * @buflen: buffer length
  *
@@ -1857,8 +1856,7 @@ Elong:
  *
  * "buflen" should be positive. Caller holds the dcache_lock.
  */
-char *d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
-            char *buf, int buflen)
+char *d_path(struct path *path, char *buf, int buflen)
 {
        char *res;
        struct path root;
@@ -1870,15 +1868,15 @@ char *d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
         * user wants to identify the object in /proc/pid/fd/.  The little hack
         * below allows us to generate a name for these objects on demand:
         */
-       if (dentry->d_op && dentry->d_op->d_dname)
-               return dentry->d_op->d_dname(dentry, buf, buflen);
+       if (path->dentry->d_op && path->dentry->d_op->d_dname)
+               return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
 
        read_lock(&current->fs->lock);
        root = current->fs->root;
        path_get(&current->fs->root);
        read_unlock(&current->fs->lock);
        spin_lock(&dcache_lock);
-       res = __d_path(dentry, vfsmnt, &root, buf, buflen);
+       res = __d_path(path->dentry, path->mnt, &root, buf, buflen);
        spin_unlock(&dcache_lock);
        path_put(&root);
        return res;
index 13c29f1f711ff49900b5514312f97480a45b0017..855d4b1d619aec6244b182c3669b6efe2ec1f726 100644 (file)
@@ -171,7 +171,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
                goto out;
 
        /* FIXME: (deleted) ? */
-       path = d_path(dcs->path.dentry, dcs->path.mnt, kbuf, PAGE_SIZE);
+       path = d_path(&dcs->path, kbuf, PAGE_SIZE);
 
        if (IS_ERR(path)) {
                err = PTR_ERR(path);
index 4a85b40eef4fea0d9f74b552695b6ecabca6a547..8a6f7c924c7597d0e851a84f45ae479714856f33 100644 (file)
@@ -345,7 +345,7 @@ static void svc_export_request(struct cache_detail *cd,
        char *pth;
 
        qword_add(bpp, blen, exp->ex_client->name);
-       pth = d_path(exp->ex_path.dentry, exp->ex_path.mnt, *bpp, *blen);
+       pth = d_path(&exp->ex_path, *bpp, *blen);
        if (IS_ERR(pth)) {
                /* is this correct? */
                (*bpp)[0] = '\n';
index 47338d92db510d1493389e9534b88f292ad0238a..88f8edf18258ac50681474ffc9542c75de30ecda 100644 (file)
@@ -1185,7 +1185,7 @@ static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
        if (!tmp)
                return -ENOMEM;
 
-       pathname = d_path(path->dentry, path->mnt, tmp, PAGE_SIZE);
+       pathname = d_path(path, tmp, PAGE_SIZE);
        len = PTR_ERR(pathname);
        if (IS_ERR(pathname))
                goto out;
index 8d862907f060055f78dc0d0a1143edb67a0a3c7c..853770274f200ae36b49929b2afe55368ec1c047 100644 (file)
@@ -346,8 +346,7 @@ int seq_path(struct seq_file *m, struct path *path, char *esc)
 {
        if (m->count < m->size) {
                char *s = m->buf + m->count;
-               char *p = d_path(path->dentry, path->mnt, s,
-                                m->size - m->count);
+               char *p = d_path(path, s, m->size - m->count);
                if (!IS_ERR(p)) {
                        while (s <= p) {
                                char c = *p++;
index c2c153f97e8f83b233c2e5d2ea0fb19de640b4d2..6bd646096fa62e145786b97b022839c8de9928d4 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/rcupdate.h>
 
 struct nameidata;
+struct path;
 struct vfsmount;
 
 /*
@@ -300,8 +301,8 @@ extern int d_validate(struct dentry *, struct dentry *);
  */
 extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
 
-extern char * d_path(struct dentry *, struct vfsmount *, char *, int);
-  
+extern char *d_path(struct path *, char *, int);
+
 /* Allocation counts.. */
 
 /**
index 783e65701247f43cdb0d13d6ca161a5c1fbd0526..2eeea9a142408a156f0897a75c81343a5619c07c 100644 (file)
@@ -1325,7 +1325,7 @@ void audit_log_d_path(struct audit_buffer *ab, const char *prefix,
                audit_log_format(ab, "<no memory>");
                return;
        }
-       p = d_path(path->dentry, path->mnt, pathname, PATH_MAX+11);
+       p = d_path(path, pathname, PATH_MAX+11);
        if (IS_ERR(p)) { /* Should never happen since we send PATH_MAX */
                /* FIXME: can we save some information here? */
                audit_log_format(ab, "<too long>");
index 717aa0e3be2d7d9b0385411257a89d50f6ea3afc..e7a6dcacefc1d86f24bee62dfdf6ca134b2a25a4 100644 (file)
@@ -2719,7 +2719,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
                if (buf) {
                        char *p, *s;
 
-                       p = d_path(f->f_dentry, f->f_vfsmnt, buf, PAGE_SIZE);
+                       p = d_path(&f->f_path, buf, PAGE_SIZE);
                        if (IS_ERR(p))
                                p = "?";
                        s = strrchr(p, '/');