]> Pileus Git - ~andy/linux/blobdiff - fs/namespace.c
d_path: Make seq_path() use a struct path argument
[~andy/linux] / fs / namespace.c
index ac19212c9bc3c0bcaaa9fd0cbde0062e3dd7cb55..7953c96a20715a981032b4d7af18e428f39b3ca6 100644 (file)
@@ -408,10 +408,11 @@ static int show_vfsmnt(struct seq_file *m, void *v)
                { 0, NULL }
        };
        struct proc_fs_info *fs_infop;
+       struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
 
        mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
        seq_putc(m, ' ');
-       seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
+       seq_path(m, &mnt_path, " \t\n\\");
        seq_putc(m, ' ');
        mangle(m, mnt->mnt_sb->s_type->name);
        if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
@@ -443,6 +444,7 @@ struct seq_operations mounts_op = {
 static int show_vfsstat(struct seq_file *m, void *v)
 {
        struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
+       struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
        int err = 0;
 
        /* device */
@@ -454,7 +456,7 @@ static int show_vfsstat(struct seq_file *m, void *v)
 
        /* mount point */
        seq_puts(m, " mounted on ");
-       seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
+       seq_path(m, &mnt_path, " \t\n\\");
        seq_putc(m, ' ');
 
        /* file system type */
@@ -1650,15 +1652,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);
@@ -1668,15 +1669,14 @@ void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
  * 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)
@@ -1697,12 +1697,10 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
                        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);
@@ -1845,6 +1843,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))
@@ -1863,8 +1862,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)