aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index e5e1c7d1839b..6d3a1963879b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2483,11 +2483,43 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
2483 __mnt_make_longterm(mnt); 2483 __mnt_make_longterm(mnt);
2484 new_ns->root = mnt; 2484 new_ns->root = mnt;
2485 list_add(&new_ns->list, &new_ns->root->mnt_list); 2485 list_add(&new_ns->list, &new_ns->root->mnt_list);
2486 } else {
2487 mntput(mnt);
2486 } 2488 }
2487 return new_ns; 2489 return new_ns;
2488} 2490}
2489EXPORT_SYMBOL(create_mnt_ns); 2491EXPORT_SYMBOL(create_mnt_ns);
2490 2492
2493struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
2494{
2495 struct mnt_namespace *ns;
2496 struct super_block *s;
2497 struct path path;
2498 int err;
2499
2500 ns = create_mnt_ns(mnt);
2501 if (IS_ERR(ns))
2502 return ERR_CAST(ns);
2503
2504 err = vfs_path_lookup(mnt->mnt_root, mnt,
2505 name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path);
2506
2507 put_mnt_ns(ns);
2508
2509 if (err)
2510 return ERR_PTR(err);
2511
2512 /* trade a vfsmount reference for active sb one */
2513 s = path.mnt->mnt_sb;
2514 atomic_inc(&s->s_active);
2515 mntput(path.mnt);
2516 /* lock the sucker */
2517 down_write(&s->s_umount);
2518 /* ... and return the root of (sub)tree on it */
2519 return path.dentry;
2520}
2521EXPORT_SYMBOL(mount_subtree);
2522
2491SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, 2523SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
2492 char __user *, type, unsigned long, flags, void __user *, data) 2524 char __user *, type, unsigned long, flags, void __user *, data)
2493{ 2525{