diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-28 20:47:57 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-24 23:34:58 -0400 |
commit | 9559f68915024ece8be3781003f25aef3677e574 (patch) | |
tree | 4f888596e61b480a7327c08c029a2849625e11a4 | |
parent | f6b742d8697ae0aeacb025e6e0ab3c61a6918846 (diff) |
fold dup_mnt_ns() into its only surviving caller
should've been done 6 years ago...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/namespace.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index e45503d62fed..c8d214ce30c6 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -2397,20 +2397,25 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns) | |||
2397 | return new_ns; | 2397 | return new_ns; |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | /* | 2400 | struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, |
2401 | * Allocate a new namespace structure and populate it with contents | 2401 | struct user_namespace *user_ns, struct fs_struct *new_fs) |
2402 | * copied from the namespace of the passed in task structure. | ||
2403 | */ | ||
2404 | static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | ||
2405 | struct user_namespace *user_ns, struct fs_struct *fs) | ||
2406 | { | 2402 | { |
2407 | struct mnt_namespace *new_ns; | 2403 | struct mnt_namespace *new_ns; |
2408 | struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; | 2404 | struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; |
2409 | struct mount *p, *q; | 2405 | struct mount *p, *q; |
2410 | struct mount *old = mnt_ns->root; | 2406 | struct mount *old; |
2411 | struct mount *new; | 2407 | struct mount *new; |
2412 | int copy_flags; | 2408 | int copy_flags; |
2413 | 2409 | ||
2410 | BUG_ON(!ns); | ||
2411 | |||
2412 | if (likely(!(flags & CLONE_NEWNS))) { | ||
2413 | get_mnt_ns(ns); | ||
2414 | return ns; | ||
2415 | } | ||
2416 | |||
2417 | old = ns->root; | ||
2418 | |||
2414 | new_ns = alloc_mnt_ns(user_ns); | 2419 | new_ns = alloc_mnt_ns(user_ns); |
2415 | if (IS_ERR(new_ns)) | 2420 | if (IS_ERR(new_ns)) |
2416 | return new_ns; | 2421 | return new_ns; |
@@ -2418,7 +2423,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
2418 | namespace_lock(); | 2423 | namespace_lock(); |
2419 | /* First pass: copy the tree topology */ | 2424 | /* First pass: copy the tree topology */ |
2420 | copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE; | 2425 | copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE; |
2421 | if (user_ns != mnt_ns->user_ns) | 2426 | if (user_ns != ns->user_ns) |
2422 | copy_flags |= CL_SHARED_TO_SLAVE | CL_UNPRIVILEGED; | 2427 | copy_flags |= CL_SHARED_TO_SLAVE | CL_UNPRIVILEGED; |
2423 | new = copy_tree(old, old->mnt.mnt_root, copy_flags); | 2428 | new = copy_tree(old, old->mnt.mnt_root, copy_flags); |
2424 | if (IS_ERR(new)) { | 2429 | if (IS_ERR(new)) { |
@@ -2438,13 +2443,13 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
2438 | q = new; | 2443 | q = new; |
2439 | while (p) { | 2444 | while (p) { |
2440 | q->mnt_ns = new_ns; | 2445 | q->mnt_ns = new_ns; |
2441 | if (fs) { | 2446 | if (new_fs) { |
2442 | if (&p->mnt == fs->root.mnt) { | 2447 | if (&p->mnt == new_fs->root.mnt) { |
2443 | fs->root.mnt = mntget(&q->mnt); | 2448 | new_fs->root.mnt = mntget(&q->mnt); |
2444 | rootmnt = &p->mnt; | 2449 | rootmnt = &p->mnt; |
2445 | } | 2450 | } |
2446 | if (&p->mnt == fs->pwd.mnt) { | 2451 | if (&p->mnt == new_fs->pwd.mnt) { |
2447 | fs->pwd.mnt = mntget(&q->mnt); | 2452 | new_fs->pwd.mnt = mntget(&q->mnt); |
2448 | pwdmnt = &p->mnt; | 2453 | pwdmnt = &p->mnt; |
2449 | } | 2454 | } |
2450 | } | 2455 | } |
@@ -2465,23 +2470,6 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
2465 | return new_ns; | 2470 | return new_ns; |
2466 | } | 2471 | } |
2467 | 2472 | ||
2468 | struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, | ||
2469 | struct user_namespace *user_ns, struct fs_struct *new_fs) | ||
2470 | { | ||
2471 | struct mnt_namespace *new_ns; | ||
2472 | |||
2473 | BUG_ON(!ns); | ||
2474 | get_mnt_ns(ns); | ||
2475 | |||
2476 | if (!(flags & CLONE_NEWNS)) | ||
2477 | return ns; | ||
2478 | |||
2479 | new_ns = dup_mnt_ns(ns, user_ns, new_fs); | ||
2480 | |||
2481 | put_mnt_ns(ns); | ||
2482 | return new_ns; | ||
2483 | } | ||
2484 | |||
2485 | /** | 2473 | /** |
2486 | * create_mnt_ns - creates a private namespace and adds a root filesystem | 2474 | * create_mnt_ns - creates a private namespace and adds a root filesystem |
2487 | * @mnt: pointer to the new root filesystem mountpoint | 2475 | * @mnt: pointer to the new root filesystem mountpoint |