aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2015-06-19 04:29:13 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-06-23 18:00:05 -0400
commit9bf39ab2adafd7cf8740859cb49e7b7952813a5d (patch)
tree2dc4ff57033635f0900328c99020af7bf71a31d2
parent4bacc9c9234c7c8eec44f5ed4e960d9f96fa0f01 (diff)
vfs: add file_path() helper
Turn d_path(&file->f_path, ...); into file_path(file, ...); Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/arc/kernel/troubleshoot.c10
-rw-r--r--arch/blackfin/kernel/trace.c2
-rw-r--r--arch/tile/kernel/stack.c2
-rw-r--r--arch/tile/mm/elf.c2
-rw-r--r--drivers/block/loop.c2
-rw-r--r--drivers/md/bitmap.c2
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c2
-rw-r--r--drivers/usb/gadget/function/storage_common.c2
-rw-r--r--fs/binfmt_elf.c4
-rw-r--r--fs/coredump.c2
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/open.c6
-rw-r--r--include/linux/fs.h2
-rw-r--r--kernel/events/core.c2
-rw-r--r--mm/memory.c2
16 files changed, 25 insertions, 21 deletions
diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index e00a01879025..9f80c5adcb68 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -67,15 +67,12 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf)
67 mmput(mm); 67 mmput(mm);
68 68
69 if (exe_file) { 69 if (exe_file) {
70 path = exe_file->f_path; 70 path_nm = file_path(exe_file, buf, 255);
71 path_get(&exe_file->f_path);
72 fput(exe_file); 71 fput(exe_file);
73 path_nm = d_path(&path, buf, 255);
74 path_put(&path);
75 } 72 }
76 73
77done: 74done:
78 pr_info("Path: %s\n", path_nm); 75 pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
79} 76}
80 77
81static void show_faulting_vma(unsigned long address, char *buf) 78static void show_faulting_vma(unsigned long address, char *buf)
@@ -99,8 +96,7 @@ static void show_faulting_vma(unsigned long address, char *buf)
99 if (vma && (vma->vm_start <= address)) { 96 if (vma && (vma->vm_start <= address)) {
100 struct file *file = vma->vm_file; 97 struct file *file = vma->vm_file;
101 if (file) { 98 if (file) {
102 struct path *path = &file->f_path; 99 nm = file_path(file, buf, PAGE_SIZE - 1);
103 nm = d_path(path, buf, PAGE_SIZE - 1);
104 inode = file_inode(vma->vm_file); 100 inode = file_inode(vma->vm_file);
105 dev = inode->i_sb->s_dev; 101 dev = inode->i_sb->s_dev;
106 ino = inode->i_ino; 102 ino = inode->i_ino;
diff --git a/arch/blackfin/kernel/trace.c b/arch/blackfin/kernel/trace.c
index c36efa0c7163..719dd796c12c 100644
--- a/arch/blackfin/kernel/trace.c
+++ b/arch/blackfin/kernel/trace.c
@@ -136,7 +136,7 @@ void decode_address(char *buf, unsigned long address)
136 struct file *file = vma->vm_file; 136 struct file *file = vma->vm_file;
137 137
138 if (file) { 138 if (file) {
139 char *d_name = d_path(&file->f_path, _tmpbuf, 139 char *d_name = file_path(file, _tmpbuf,
140 sizeof(_tmpbuf)); 140 sizeof(_tmpbuf));
141 if (!IS_ERR(d_name)) 141 if (!IS_ERR(d_name))
142 name = d_name; 142 name = d_name;
diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c
index c42dce50acd8..8d62cf12c2c0 100644
--- a/arch/tile/kernel/stack.c
+++ b/arch/tile/kernel/stack.c
@@ -334,7 +334,7 @@ static void describe_addr(struct KBacktraceIterator *kbt,
334 } 334 }
335 335
336 if (vma->vm_file) { 336 if (vma->vm_file) {
337 p = d_path(&vma->vm_file->f_path, buf, bufsize); 337 p = file_path(vma->vm_file, buf, bufsize);
338 if (IS_ERR(p)) 338 if (IS_ERR(p))
339 p = "?"; 339 p = "?";
340 name = kbasename(p); 340 name = kbasename(p);
diff --git a/arch/tile/mm/elf.c b/arch/tile/mm/elf.c
index f7ddae3725a4..6225cc998db1 100644
--- a/arch/tile/mm/elf.c
+++ b/arch/tile/mm/elf.c
@@ -56,7 +56,7 @@ static int notify_exec(struct mm_struct *mm)
56 if (exe_file == NULL) 56 if (exe_file == NULL)
57 goto done_free; 57 goto done_free;
58 58
59 path = d_path(&exe_file->f_path, buf, PAGE_SIZE); 59 path = file_path(exe_file, buf, PAGE_SIZE);
60 if (IS_ERR(path)) 60 if (IS_ERR(path))
61 goto done_put; 61 goto done_put;
62 62
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d7173cb1ea76..0d8ad59413cd 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -568,7 +568,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
568 568
569 spin_lock_irq(&lo->lo_lock); 569 spin_lock_irq(&lo->lo_lock);
570 if (lo->lo_backing_file) 570 if (lo->lo_backing_file)
571 p = d_path(&lo->lo_backing_file->f_path, buf, PAGE_SIZE - 1); 571 p = file_path(lo->lo_backing_file, buf, PAGE_SIZE - 1);
572 spin_unlock_irq(&lo->lo_lock); 572 spin_unlock_irq(&lo->lo_lock);
573 573
574 if (IS_ERR_OR_NULL(p)) 574 if (IS_ERR_OR_NULL(p))
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 2bc56e2a3526..dda33d648354 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -834,7 +834,7 @@ static void bitmap_file_kick(struct bitmap *bitmap)
834 if (bitmap->storage.file) { 834 if (bitmap->storage.file) {
835 path = kmalloc(PAGE_SIZE, GFP_KERNEL); 835 path = kmalloc(PAGE_SIZE, GFP_KERNEL);
836 if (path) 836 if (path)
837 ptr = d_path(&bitmap->storage.file->f_path, 837 ptr = file_path(bitmap->storage.file,
838 path, PAGE_SIZE); 838 path, PAGE_SIZE);
839 839
840 printk(KERN_ALERT 840 printk(KERN_ALERT
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 593a02476c78..e67f3ac137bf 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5741,7 +5741,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg)
5741 /* bitmap disabled, zero the first byte and copy out */ 5741 /* bitmap disabled, zero the first byte and copy out */
5742 if (!mddev->bitmap_info.file) 5742 if (!mddev->bitmap_info.file)
5743 file->pathname[0] = '\0'; 5743 file->pathname[0] = '\0';
5744 else if ((ptr = d_path(&mddev->bitmap_info.file->f_path, 5744 else if ((ptr = file_path(mddev->bitmap_info.file,
5745 file->pathname, sizeof(file->pathname))), 5745 file->pathname, sizeof(file->pathname))),
5746 IS_ERR(ptr)) 5746 IS_ERR(ptr))
5747 err = PTR_ERR(ptr); 5747 err = PTR_ERR(ptr);
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 3cc109f3c9c8..d2259c663996 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2936,7 +2936,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
2936 if (fsg_lun_is_open(lun)) { 2936 if (fsg_lun_is_open(lun)) {
2937 p = "(error)"; 2937 p = "(error)";
2938 if (pathbuf) { 2938 if (pathbuf) {
2939 p = d_path(&lun->filp->f_path, pathbuf, PATH_MAX); 2939 p = file_path(lun->filp, pathbuf, PATH_MAX);
2940 if (IS_ERR(p)) 2940 if (IS_ERR(p))
2941 p = "(error)"; 2941 p = "(error)";
2942 } 2942 }
diff --git a/drivers/usb/gadget/function/storage_common.c b/drivers/usb/gadget/function/storage_common.c
index 648f9e489b39..d62683017cf3 100644
--- a/drivers/usb/gadget/function/storage_common.c
+++ b/drivers/usb/gadget/function/storage_common.c
@@ -341,7 +341,7 @@ ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
341 341
342 down_read(filesem); 342 down_read(filesem);
343 if (fsg_lun_is_open(curlun)) { /* Get the complete pathname */ 343 if (fsg_lun_is_open(curlun)) { /* Get the complete pathname */
344 p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1); 344 p = file_path(curlun->filp, buf, PAGE_SIZE - 1);
345 if (IS_ERR(p)) 345 if (IS_ERR(p))
346 rc = PTR_ERR(p); 346 rc = PTR_ERR(p);
347 else { 347 else {
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 241ef68d2893..5046b6247103 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1530,7 +1530,7 @@ static int fill_files_note(struct memelfnote *note)
1530 file = vma->vm_file; 1530 file = vma->vm_file;
1531 if (!file) 1531 if (!file)
1532 continue; 1532 continue;
1533 filename = d_path(&file->f_path, name_curpos, remaining); 1533 filename = file_path(file, name_curpos, remaining);
1534 if (IS_ERR(filename)) { 1534 if (IS_ERR(filename)) {
1535 if (PTR_ERR(filename) == -ENAMETOOLONG) { 1535 if (PTR_ERR(filename) == -ENAMETOOLONG) {
1536 vfree(data); 1536 vfree(data);
@@ -1540,7 +1540,7 @@ static int fill_files_note(struct memelfnote *note)
1540 continue; 1540 continue;
1541 } 1541 }
1542 1542
1543 /* d_path() fills at the end, move name down */ 1543 /* file_path() fills at the end, move name down */
1544 /* n = strlen(filename) + 1: */ 1544 /* n = strlen(filename) + 1: */
1545 n = (name_curpos + remaining) - filename; 1545 n = (name_curpos + remaining) - filename;
1546 remaining = filename - name_curpos; 1546 remaining = filename - name_curpos;
diff --git a/fs/coredump.c b/fs/coredump.c
index bbbe139ab280..5b771b36cc6e 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -138,7 +138,7 @@ static int cn_print_exe_file(struct core_name *cn)
138 goto put_exe_file; 138 goto put_exe_file;
139 } 139 }
140 140
141 path = d_path(&exe_file->f_path, pathbuf, PATH_MAX); 141 path = file_path(exe_file, pathbuf, PATH_MAX);
142 if (IS_ERR(path)) { 142 if (IS_ERR(path)) {
143 ret = PTR_ERR(path); 143 ret = PTR_ERR(path);
144 goto free_buf; 144 goto free_buf;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f06d0589ddba..0ae853d2e1f1 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -449,7 +449,7 @@ void __ext4_error_file(struct file *file, const char *function,
449 es = EXT4_SB(inode->i_sb)->s_es; 449 es = EXT4_SB(inode->i_sb)->s_es;
450 es->s_last_error_ino = cpu_to_le32(inode->i_ino); 450 es->s_last_error_ino = cpu_to_le32(inode->i_ino);
451 if (ext4_error_ratelimit(inode->i_sb)) { 451 if (ext4_error_ratelimit(inode->i_sb)) {
452 path = d_path(&(file->f_path), pathname, sizeof(pathname)); 452 path = file_path(file, pathname, sizeof(pathname));
453 if (IS_ERR(path)) 453 if (IS_ERR(path))
454 path = "(unknown)"; 454 path = "(unknown)";
455 va_start(args, fmt); 455 va_start(args, fmt);
diff --git a/fs/open.c b/fs/open.c
index b1c5823b7f11..1dbc79358d59 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -823,6 +823,12 @@ int finish_no_open(struct file *file, struct dentry *dentry)
823} 823}
824EXPORT_SYMBOL(finish_no_open); 824EXPORT_SYMBOL(finish_no_open);
825 825
826char *file_path(struct file *filp, char *buf, int buflen)
827{
828 return d_path(&filp->f_path, buf, buflen);
829}
830EXPORT_SYMBOL(file_path);
831
826/** 832/**
827 * vfs_open - open the file at the given path 833 * vfs_open - open the file at the given path
828 * @path: path to open 834 * @path: path to open
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2bd77e10e8e5..2c135ad741a9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2500,6 +2500,8 @@ extern struct file * open_exec(const char *);
2500extern int is_subdir(struct dentry *, struct dentry *); 2500extern int is_subdir(struct dentry *, struct dentry *);
2501extern int path_is_under(struct path *, struct path *); 2501extern int path_is_under(struct path *, struct path *);
2502 2502
2503extern char *file_path(struct file *, char *, int);
2504
2503#include <linux/err.h> 2505#include <linux/err.h>
2504 2506
2505/* needed for stackable file system support */ 2507/* needed for stackable file system support */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 81aa3a4ece9f..5c964e845483 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5791,7 +5791,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
5791 * need to add enough zero bytes after the string to handle 5791 * need to add enough zero bytes after the string to handle
5792 * the 64bit alignment we do later. 5792 * the 64bit alignment we do later.
5793 */ 5793 */
5794 name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64)); 5794 name = file_path(file, buf, PATH_MAX - sizeof(u64));
5795 if (IS_ERR(name)) { 5795 if (IS_ERR(name)) {
5796 name = "//toolong"; 5796 name = "//toolong";
5797 goto cpy_name; 5797 goto cpy_name;
diff --git a/mm/memory.c b/mm/memory.c
index 22e037e3364e..28c10da1efbc 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3724,7 +3724,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
3724 if (buf) { 3724 if (buf) {
3725 char *p; 3725 char *p;
3726 3726
3727 p = d_path(&f->f_path, buf, PAGE_SIZE); 3727 p = file_path(f, buf, PAGE_SIZE);
3728 if (IS_ERR(p)) 3728 if (IS_ERR(p))
3729 p = "?"; 3729 p = "?";
3730 printk("%s%s[%lx+%lx]", prefix, kbasename(p), 3730 printk("%s%s[%lx+%lx]", prefix, kbasename(p),