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

Configure Feed

Select the types of activity you want to include in your feed.

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: Jan Blunck <jblunck@suse.de>
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: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Blunck and committed by
Linus Torvalds
3dcd25f3 44707fdf

+34 -42
+26 -34
fs/proc/base.c
··· 153 153 return count; 154 154 } 155 155 156 - static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 156 + static int proc_cwd_link(struct inode *inode, struct path *path) 157 157 { 158 158 struct task_struct *task = get_proc_task(inode); 159 159 struct fs_struct *fs = NULL; ··· 165 165 } 166 166 if (fs) { 167 167 read_lock(&fs->lock); 168 - *mnt = mntget(fs->pwd.mnt); 169 - *dentry = dget(fs->pwd.dentry); 168 + *path = fs->pwd; 169 + path_get(&fs->pwd); 170 170 read_unlock(&fs->lock); 171 171 result = 0; 172 172 put_fs_struct(fs); ··· 174 174 return result; 175 175 } 176 176 177 - static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 177 + static int proc_root_link(struct inode *inode, struct path *path) 178 178 { 179 179 struct task_struct *task = get_proc_task(inode); 180 180 struct fs_struct *fs = NULL; ··· 186 186 } 187 187 if (fs) { 188 188 read_lock(&fs->lock); 189 - *mnt = mntget(fs->root.mnt); 190 - *dentry = dget(fs->root.dentry); 189 + *path = fs->root; 190 + path_get(&fs->root); 191 191 read_unlock(&fs->lock); 192 192 result = 0; 193 193 put_fs_struct(fs); ··· 1170 1170 if (!proc_fd_access_allowed(inode)) 1171 1171 goto out; 1172 1172 1173 - error = PROC_I(inode)->op.proc_get_link(inode, &nd->path.dentry, 1174 - &nd->path.mnt); 1173 + error = PROC_I(inode)->op.proc_get_link(inode, &nd->path); 1175 1174 nd->last_type = LAST_BIND; 1176 1175 out: 1177 1176 return ERR_PTR(error); 1178 1177 } 1179 1178 1180 - static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt, 1181 - char __user *buffer, int buflen) 1179 + static int do_proc_readlink(struct path *path, char __user *buffer, int buflen) 1182 1180 { 1183 - struct inode * inode; 1184 1181 char *tmp = (char*)__get_free_page(GFP_TEMPORARY); 1185 - char *path; 1182 + char *pathname; 1186 1183 int len; 1187 1184 1188 1185 if (!tmp) 1189 1186 return -ENOMEM; 1190 1187 1191 - inode = dentry->d_inode; 1192 - path = d_path(dentry, mnt, tmp, PAGE_SIZE); 1193 - len = PTR_ERR(path); 1194 - if (IS_ERR(path)) 1188 + pathname = d_path(path->dentry, path->mnt, tmp, PAGE_SIZE); 1189 + len = PTR_ERR(pathname); 1190 + if (IS_ERR(pathname)) 1195 1191 goto out; 1196 - len = tmp + PAGE_SIZE - 1 - path; 1192 + len = tmp + PAGE_SIZE - 1 - pathname; 1197 1193 1198 1194 if (len > buflen) 1199 1195 len = buflen; 1200 - if (copy_to_user(buffer, path, len)) 1196 + if (copy_to_user(buffer, pathname, len)) 1201 1197 len = -EFAULT; 1202 1198 out: 1203 1199 free_page((unsigned long)tmp); ··· 1204 1208 { 1205 1209 int error = -EACCES; 1206 1210 struct inode *inode = dentry->d_inode; 1207 - struct dentry *de; 1208 - struct vfsmount *mnt = NULL; 1211 + struct path path; 1209 1212 1210 1213 /* Are we allowed to snoop on the tasks file descriptors? */ 1211 1214 if (!proc_fd_access_allowed(inode)) 1212 1215 goto out; 1213 1216 1214 - error = PROC_I(inode)->op.proc_get_link(inode, &de, &mnt); 1217 + error = PROC_I(inode)->op.proc_get_link(inode, &path); 1215 1218 if (error) 1216 1219 goto out; 1217 1220 1218 - error = do_proc_readlink(de, mnt, buffer, buflen); 1219 - dput(de); 1220 - mntput(mnt); 1221 + error = do_proc_readlink(&path, buffer, buflen); 1222 + path_put(&path); 1221 1223 out: 1222 1224 return error; 1223 1225 } ··· 1442 1448 1443 1449 #define PROC_FDINFO_MAX 64 1444 1450 1445 - static int proc_fd_info(struct inode *inode, struct dentry **dentry, 1446 - struct vfsmount **mnt, char *info) 1451 + static int proc_fd_info(struct inode *inode, struct path *path, char *info) 1447 1452 { 1448 1453 struct task_struct *task = get_proc_task(inode); 1449 1454 struct files_struct *files = NULL; ··· 1461 1468 spin_lock(&files->file_lock); 1462 1469 file = fcheck_files(files, fd); 1463 1470 if (file) { 1464 - if (mnt) 1465 - *mnt = mntget(file->f_path.mnt); 1466 - if (dentry) 1467 - *dentry = dget(file->f_path.dentry); 1471 + if (path) { 1472 + *path = file->f_path; 1473 + path_get(&file->f_path); 1474 + } 1468 1475 if (info) 1469 1476 snprintf(info, PROC_FDINFO_MAX, 1470 1477 "pos:\t%lli\n" ··· 1481 1488 return -ENOENT; 1482 1489 } 1483 1490 1484 - static int proc_fd_link(struct inode *inode, struct dentry **dentry, 1485 - struct vfsmount **mnt) 1491 + static int proc_fd_link(struct inode *inode, struct path *path) 1486 1492 { 1487 - return proc_fd_info(inode, dentry, mnt, NULL); 1493 + return proc_fd_info(inode, path, NULL); 1488 1494 } 1489 1495 1490 1496 static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) ··· 1677 1685 size_t len, loff_t *ppos) 1678 1686 { 1679 1687 char tmp[PROC_FDINFO_MAX]; 1680 - int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, NULL, tmp); 1688 + int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, tmp); 1681 1689 if (!err) 1682 1690 err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp)); 1683 1691 return err;
+1 -1
fs/proc/internal.h
··· 48 48 49 49 extern void create_seq_entry(char *name, mode_t mode, 50 50 const struct file_operations *f); 51 - extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); 51 + extern int proc_exe_link(struct inode *, struct path *); 52 52 extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, 53 53 struct pid *pid, struct task_struct *task); 54 54 extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns,
+3 -3
fs/proc/task_mmu.c
··· 75 75 return mm->total_vm; 76 76 } 77 77 78 - int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 78 + int proc_exe_link(struct inode *inode, struct path *path) 79 79 { 80 80 struct vm_area_struct * vma; 81 81 int result = -ENOENT; ··· 98 98 } 99 99 100 100 if (vma) { 101 - *mnt = mntget(vma->vm_file->f_path.mnt); 102 - *dentry = dget(vma->vm_file->f_path.dentry); 101 + *path = vma->vm_file->f_path; 102 + path_get(&vma->vm_file->f_path); 103 103 result = 0; 104 104 } 105 105
+3 -3
fs/proc/task_nommu.c
··· 103 103 return size; 104 104 } 105 105 106 - int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 106 + int proc_exe_link(struct inode *inode, struct path *path) 107 107 { 108 108 struct vm_list_struct *vml; 109 109 struct vm_area_struct *vma; ··· 126 126 } 127 127 128 128 if (vma) { 129 - *mnt = mntget(vma->vm_file->f_path.mnt); 130 - *dentry = dget(vma->vm_file->f_path.dentry); 129 + *path = vma->vm_file->f_path; 130 + path_get(&vma->vm_file->f_path); 131 131 result = 0; 132 132 } 133 133
+1 -1
include/linux/proc_fs.h
··· 269 269 #endif 270 270 271 271 union proc_op { 272 - int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **); 272 + int (*proc_get_link)(struct inode *, struct path *); 273 273 int (*proc_read)(struct task_struct *task, char *page); 274 274 int (*proc_show)(struct seq_file *m, 275 275 struct pid_namespace *ns, struct pid *pid,