Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Miklos Szeredi and committed by
Al Viro
9bf39ab2 4bacc9c9

+25 -21
+3 -7
arch/arc/kernel/troubleshoot.c
··· 67 67 mmput(mm); 68 68 69 69 if (exe_file) { 70 - path = exe_file->f_path; 71 - path_get(&exe_file->f_path); 70 + path_nm = file_path(exe_file, buf, 255); 72 71 fput(exe_file); 73 - path_nm = d_path(&path, buf, 255); 74 - path_put(&path); 75 72 } 76 73 77 74 done: 78 - pr_info("Path: %s\n", path_nm); 75 + pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?"); 79 76 } 80 77 81 78 static void show_faulting_vma(unsigned long address, char *buf) ··· 96 99 if (vma && (vma->vm_start <= address)) { 97 100 struct file *file = vma->vm_file; 98 101 if (file) { 99 - struct path *path = &file->f_path; 100 - nm = d_path(path, buf, PAGE_SIZE - 1); 102 + nm = file_path(file, buf, PAGE_SIZE - 1); 101 103 inode = file_inode(vma->vm_file); 102 104 dev = inode->i_sb->s_dev; 103 105 ino = inode->i_ino;
+1 -1
arch/blackfin/kernel/trace.c
··· 136 136 struct file *file = vma->vm_file; 137 137 138 138 if (file) { 139 - char *d_name = d_path(&file->f_path, _tmpbuf, 139 + char *d_name = file_path(file, _tmpbuf, 140 140 sizeof(_tmpbuf)); 141 141 if (!IS_ERR(d_name)) 142 142 name = d_name;
+1 -1
arch/tile/kernel/stack.c
··· 334 334 } 335 335 336 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 338 if (IS_ERR(p)) 339 339 p = "?"; 340 340 name = kbasename(p);
+1 -1
arch/tile/mm/elf.c
··· 56 56 if (exe_file == NULL) 57 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 60 if (IS_ERR(path)) 61 61 goto done_put; 62 62
+1 -1
drivers/block/loop.c
··· 568 568 569 569 spin_lock_irq(&lo->lo_lock); 570 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 572 spin_unlock_irq(&lo->lo_lock); 573 573 574 574 if (IS_ERR_OR_NULL(p))
+1 -1
drivers/md/bitmap.c
··· 834 834 if (bitmap->storage.file) { 835 835 path = kmalloc(PAGE_SIZE, GFP_KERNEL); 836 836 if (path) 837 - ptr = d_path(&bitmap->storage.file->f_path, 837 + ptr = file_path(bitmap->storage.file, 838 838 path, PAGE_SIZE); 839 839 840 840 printk(KERN_ALERT
+1 -1
drivers/md/md.c
··· 5741 5741 /* bitmap disabled, zero the first byte and copy out */ 5742 5742 if (!mddev->bitmap_info.file) 5743 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 5745 file->pathname, sizeof(file->pathname))), 5746 5746 IS_ERR(ptr)) 5747 5747 err = PTR_ERR(ptr);
+1 -1
drivers/usb/gadget/function/f_mass_storage.c
··· 2936 2936 if (fsg_lun_is_open(lun)) { 2937 2937 p = "(error)"; 2938 2938 if (pathbuf) { 2939 - p = d_path(&lun->filp->f_path, pathbuf, PATH_MAX); 2939 + p = file_path(lun->filp, pathbuf, PATH_MAX); 2940 2940 if (IS_ERR(p)) 2941 2941 p = "(error)"; 2942 2942 }
+1 -1
drivers/usb/gadget/function/storage_common.c
··· 341 341 342 342 down_read(filesem); 343 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 345 if (IS_ERR(p)) 346 346 rc = PTR_ERR(p); 347 347 else {
+2 -2
fs/binfmt_elf.c
··· 1530 1530 file = vma->vm_file; 1531 1531 if (!file) 1532 1532 continue; 1533 - filename = d_path(&file->f_path, name_curpos, remaining); 1533 + filename = file_path(file, name_curpos, remaining); 1534 1534 if (IS_ERR(filename)) { 1535 1535 if (PTR_ERR(filename) == -ENAMETOOLONG) { 1536 1536 vfree(data); ··· 1540 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 1544 /* n = strlen(filename) + 1: */ 1545 1545 n = (name_curpos + remaining) - filename; 1546 1546 remaining = filename - name_curpos;
+1 -1
fs/coredump.c
··· 138 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 142 if (IS_ERR(path)) { 143 143 ret = PTR_ERR(path); 144 144 goto free_buf;
+1 -1
fs/ext4/super.c
··· 449 449 es = EXT4_SB(inode->i_sb)->s_es; 450 450 es->s_last_error_ino = cpu_to_le32(inode->i_ino); 451 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 453 if (IS_ERR(path)) 454 454 path = "(unknown)"; 455 455 va_start(args, fmt);
+6
fs/open.c
··· 823 823 } 824 824 EXPORT_SYMBOL(finish_no_open); 825 825 826 + char *file_path(struct file *filp, char *buf, int buflen) 827 + { 828 + return d_path(&filp->f_path, buf, buflen); 829 + } 830 + EXPORT_SYMBOL(file_path); 831 + 826 832 /** 827 833 * vfs_open - open the file at the given path 828 834 * @path: path to open
+2
include/linux/fs.h
··· 2500 2500 extern int is_subdir(struct dentry *, struct dentry *); 2501 2501 extern int path_is_under(struct path *, struct path *); 2502 2502 2503 + extern char *file_path(struct file *, char *, int); 2504 + 2503 2505 #include <linux/err.h> 2504 2506 2505 2507 /* needed for stackable file system support */
+1 -1
kernel/events/core.c
··· 5791 5791 * need to add enough zero bytes after the string to handle 5792 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 5795 if (IS_ERR(name)) { 5796 5796 name = "//toolong"; 5797 5797 goto cpy_name;
+1 -1
mm/memory.c
··· 3724 3724 if (buf) { 3725 3725 char *p; 3726 3726 3727 - p = d_path(&f->f_path, buf, PAGE_SIZE); 3727 + p = file_path(f, buf, PAGE_SIZE); 3728 3728 if (IS_ERR(p)) 3729 3729 p = "?"; 3730 3730 printk("%s%s[%lx+%lx]", prefix, kbasename(p),