Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756900AbXJISKw (ORCPT ); Tue, 9 Oct 2007 14:10:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755179AbXJISHx (ORCPT ); Tue, 9 Oct 2007 14:07:53 -0400 Received: from ns.suse.de ([195.135.220.2]:35899 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbXJISHn (ORCPT ); Tue, 9 Oct 2007 14:07:43 -0400 Message-Id: <20071009180514.231727260@X40.localnet> References: <20071009180503.075306583@X40.localnet> User-Agent: quilt/0.46-62.1 Date: Tue, 09 Oct 2007 20:05:13 +0200 From: Jan Blunck To: Andrew Morton Cc: Linux-Kernel Mailinglist , Christoph Hellwig , Andreas Gruenbacher Subject: [patch 10/10] Make set_fs_{root,pwd} take a struct path Content-Disposition: inline; filename=vfs/nameidata-path-7.diff Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5124 Lines: 166 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 Signed-off-by: Andreas Gruenbacher Acked-by: Christoph Hellwig --- fs/namespace.c | 28 ++++++++++++++-------------- fs/open.c | 12 ++++-------- include/linux/fs_struct.h | 4 ++-- 3 files changed, 20 insertions(+), 24 deletions(-) Index: b/fs/namespace.c =================================================================== --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2040,15 +2040,14 @@ out1: * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. * It can block. Requires the big lock held. */ -void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt, - struct dentry *dentry) +void set_fs_root(struct fs_struct *fs, struct path *path) { struct path old_root; write_lock(&fs->lock); old_root = fs->root; - fs->root.mnt = mntget(mnt); - fs->root.dentry = dget(dentry); + fs->root = *path; + path_get(path); write_unlock(&fs->lock); if (old_root.dentry) path_put(&old_root); @@ -2058,15 +2057,14 @@ void set_fs_root(struct fs_struct *fs, s * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. * It can block. Requires the big lock held. */ -void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, - struct dentry *dentry) +void set_fs_pwd(struct fs_struct *fs, struct path *path) { struct path old_pwd; write_lock(&fs->lock); old_pwd = fs->pwd; - fs->pwd.mnt = mntget(mnt); - fs->pwd.dentry = dget(dentry); + fs->pwd = *path; + path_get(path); write_unlock(&fs->lock); if (old_pwd.dentry) @@ -2087,12 +2085,10 @@ static void chroot_fs_refs(struct nameid task_unlock(p); if (fs->root.dentry == old_nd->path.dentry && fs->root.mnt == old_nd->path.mnt) - set_fs_root(fs, new_nd->path.mnt, - new_nd->path.dentry); + set_fs_root(fs, &new_nd->path); if (fs->pwd.dentry == old_nd->path.dentry && fs->pwd.mnt == old_nd->path.mnt) - set_fs_pwd(fs, new_nd->path.mnt, - new_nd->path.dentry); + set_fs_pwd(fs, &new_nd->path); put_fs_struct(fs); } else task_unlock(p); @@ -2235,6 +2231,7 @@ static void __init init_mount_tree(void) { struct vfsmount *mnt; struct mnt_namespace *ns; + struct path root; mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); if (IS_ERR(mnt)) @@ -2253,8 +2250,11 @@ static void __init init_mount_tree(void) init_task.nsproxy->mnt_ns = ns; get_mnt_ns(ns); - set_fs_pwd(current->fs, ns->root, ns->root->mnt_root); - set_fs_root(current->fs, ns->root, ns->root->mnt_root); + root.mnt = ns->root; + root.dentry = ns->root->mnt_root; + + set_fs_pwd(current->fs, &root); + set_fs_root(current->fs, &root); } void __init mnt_init(void) Index: b/fs/open.c =================================================================== --- a/fs/open.c +++ b/fs/open.c @@ -501,7 +501,7 @@ asmlinkage long sys_chdir(const char __u if (error) goto dput_and_out; - set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry); + set_fs_pwd(current->fs, &nd.path); dput_and_out: path_put(&nd.path); @@ -512,9 +512,7 @@ out: asmlinkage long sys_fchdir(unsigned int fd) { struct file *file; - struct dentry *dentry; struct inode *inode; - struct vfsmount *mnt; int error; error = -EBADF; @@ -522,9 +520,7 @@ asmlinkage long sys_fchdir(unsigned int if (!file) goto out; - dentry = file->f_path.dentry; - mnt = file->f_path.mnt; - inode = dentry->d_inode; + inode = file->f_path.dentry->d_inode; error = -ENOTDIR; if (!S_ISDIR(inode->i_mode)) @@ -532,7 +528,7 @@ asmlinkage long sys_fchdir(unsigned int error = file_permission(file, MAY_EXEC); if (!error) - set_fs_pwd(current->fs, mnt, dentry); + set_fs_pwd(current->fs, &file->f_path); out_putf: fput(file); out: @@ -556,7 +552,7 @@ asmlinkage long sys_chroot(const char __ if (!capable(CAP_SYS_CHROOT)) goto dput_and_out; - set_fs_root(current->fs, nd.path.mnt, nd.path.dentry); + set_fs_root(current->fs, &nd.path); set_fs_altroot(); error = 0; dput_and_out: Index: b/include/linux/fs_struct.h =================================================================== --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h @@ -20,8 +20,8 @@ extern struct kmem_cache *fs_cachep; extern void exit_fs(struct task_struct *); extern void set_fs_altroot(void); -extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *); -extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *); +extern void set_fs_root(struct fs_struct *, struct path *); +extern void set_fs_pwd(struct fs_struct *, struct path *); extern struct fs_struct *copy_fs_struct(struct fs_struct *); extern void put_fs_struct(struct fs_struct *); -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/