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.

Make set_fs_{root,pwd} take a struct path

In nearly all cases the set_fs_{root,pwd}() calls work on a struct
path. Change the function to reflect this and use path_get() here.

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
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
ac748a09 6ac08c39

+20 -24
+14 -14
fs/namespace.c
··· 1650 1650 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. 1651 1651 * It can block. Requires the big lock held. 1652 1652 */ 1653 - void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt, 1654 - struct dentry *dentry) 1653 + void set_fs_root(struct fs_struct *fs, struct path *path) 1655 1654 { 1656 1655 struct path old_root; 1657 1656 1658 1657 write_lock(&fs->lock); 1659 1658 old_root = fs->root; 1660 - fs->root.mnt = mntget(mnt); 1661 - fs->root.dentry = dget(dentry); 1659 + fs->root = *path; 1660 + path_get(path); 1662 1661 write_unlock(&fs->lock); 1663 1662 if (old_root.dentry) 1664 1663 path_put(&old_root); ··· 1667 1668 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. 1668 1669 * It can block. Requires the big lock held. 1669 1670 */ 1670 - void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, 1671 - struct dentry *dentry) 1671 + void set_fs_pwd(struct fs_struct *fs, struct path *path) 1672 1672 { 1673 1673 struct path old_pwd; 1674 1674 1675 1675 write_lock(&fs->lock); 1676 1676 old_pwd = fs->pwd; 1677 - fs->pwd.mnt = mntget(mnt); 1678 - fs->pwd.dentry = dget(dentry); 1677 + fs->pwd = *path; 1678 + path_get(path); 1679 1679 write_unlock(&fs->lock); 1680 1680 1681 1681 if (old_pwd.dentry) ··· 1695 1697 task_unlock(p); 1696 1698 if (fs->root.dentry == old_nd->path.dentry 1697 1699 && fs->root.mnt == old_nd->path.mnt) 1698 - set_fs_root(fs, new_nd->path.mnt, 1699 - new_nd->path.dentry); 1700 + set_fs_root(fs, &new_nd->path); 1700 1701 if (fs->pwd.dentry == old_nd->path.dentry 1701 1702 && fs->pwd.mnt == old_nd->path.mnt) 1702 - set_fs_pwd(fs, new_nd->path.mnt, 1703 - new_nd->path.dentry); 1703 + set_fs_pwd(fs, &new_nd->path); 1704 1704 put_fs_struct(fs); 1705 1705 } else 1706 1706 task_unlock(p); ··· 1841 1845 { 1842 1846 struct vfsmount *mnt; 1843 1847 struct mnt_namespace *ns; 1848 + struct path root; 1844 1849 1845 1850 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); 1846 1851 if (IS_ERR(mnt)) ··· 1860 1863 init_task.nsproxy->mnt_ns = ns; 1861 1864 get_mnt_ns(ns); 1862 1865 1863 - set_fs_pwd(current->fs, ns->root, ns->root->mnt_root); 1864 - set_fs_root(current->fs, ns->root, ns->root->mnt_root); 1866 + root.mnt = ns->root; 1867 + root.dentry = ns->root->mnt_root; 1868 + 1869 + set_fs_pwd(current->fs, &root); 1870 + set_fs_root(current->fs, &root); 1865 1871 } 1866 1872 1867 1873 void __init mnt_init(void)
+4 -8
fs/open.c
··· 490 490 if (error) 491 491 goto dput_and_out; 492 492 493 - set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry); 493 + set_fs_pwd(current->fs, &nd.path); 494 494 495 495 dput_and_out: 496 496 path_put(&nd.path); ··· 501 501 asmlinkage long sys_fchdir(unsigned int fd) 502 502 { 503 503 struct file *file; 504 - struct dentry *dentry; 505 504 struct inode *inode; 506 - struct vfsmount *mnt; 507 505 int error; 508 506 509 507 error = -EBADF; ··· 509 511 if (!file) 510 512 goto out; 511 513 512 - dentry = file->f_path.dentry; 513 - mnt = file->f_path.mnt; 514 - inode = dentry->d_inode; 514 + inode = file->f_path.dentry->d_inode; 515 515 516 516 error = -ENOTDIR; 517 517 if (!S_ISDIR(inode->i_mode)) ··· 517 521 518 522 error = file_permission(file, MAY_EXEC); 519 523 if (!error) 520 - set_fs_pwd(current->fs, mnt, dentry); 524 + set_fs_pwd(current->fs, &file->f_path); 521 525 out_putf: 522 526 fput(file); 523 527 out: ··· 541 545 if (!capable(CAP_SYS_CHROOT)) 542 546 goto dput_and_out; 543 547 544 - set_fs_root(current->fs, nd.path.mnt, nd.path.dentry); 548 + set_fs_root(current->fs, &nd.path); 545 549 set_fs_altroot(); 546 550 error = 0; 547 551 dput_and_out:
+2 -2
include/linux/fs_struct.h
··· 20 20 21 21 extern void exit_fs(struct task_struct *); 22 22 extern void set_fs_altroot(void); 23 - extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *); 24 - extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *); 23 + extern void set_fs_root(struct fs_struct *, struct path *); 24 + extern void set_fs_pwd(struct fs_struct *, struct path *); 25 25 extern struct fs_struct *copy_fs_struct(struct fs_struct *); 26 26 extern void put_fs_struct(struct fs_struct *); 27 27