Skip to content

Commit 86b1da9

Browse files
author
Al Viro
committed
attach_recursive_mnt(): get rid of flags entirely
move vs. attach is trivially detected as mnt_has_parent(source_mnt)... Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 18959bf commit 86b1da9

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

fs/namespace.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,17 +2562,15 @@ int count_mounts(struct mnt_namespace *ns, struct mount *mnt)
25622562
}
25632563

25642564
enum mnt_tree_flags_t {
2565-
MNT_TREE_MOVE = BIT(0),
2566-
MNT_TREE_BENEATH = BIT(1),
2567-
MNT_TREE_PROPAGATION = BIT(2),
2565+
MNT_TREE_BENEATH = BIT(0),
2566+
MNT_TREE_PROPAGATION = BIT(1),
25682567
};
25692568

25702569
/**
25712570
* attach_recursive_mnt - attach a source mount tree
25722571
* @source_mnt: mount tree to be attached
25732572
* @dest_mnt: mount that @source_mnt will be mounted on
25742573
* @dest_mp: the mountpoint @source_mnt will be mounted at
2575-
* @flags: modify how @source_mnt is supposed to be attached
25762574
*
25772575
* NOTE: in the table below explains the semantics when a source mount
25782576
* of a given type is attached to a destination mount of a given type.
@@ -2636,8 +2634,7 @@ enum mnt_tree_flags_t {
26362634
*/
26372635
static int attach_recursive_mnt(struct mount *source_mnt,
26382636
struct mount *dest_mnt,
2639-
struct mountpoint *dest_mp,
2640-
enum mnt_tree_flags_t flags)
2637+
struct mountpoint *dest_mp)
26412638
{
26422639
struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;
26432640
HLIST_HEAD(tree_list);
@@ -2648,7 +2645,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
26482645
struct mount *top;
26492646
struct hlist_node *n;
26502647
int err = 0;
2651-
bool moving = flags & MNT_TREE_MOVE;
2648+
bool moving = mnt_has_parent(source_mnt);
26522649

26532650
/*
26542651
* Preallocate a mountpoint in case the new mounts need to be
@@ -2871,7 +2868,7 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
28712868
d_is_dir(mnt->mnt.mnt_root))
28722869
return -ENOTDIR;
28732870

2874-
return attach_recursive_mnt(mnt, p, mp, 0);
2871+
return attach_recursive_mnt(mnt, p, mp);
28752872
}
28762873

28772874
/*
@@ -3613,8 +3610,6 @@ static int do_move_mount(struct path *old_path,
36133610
p = real_mount(new_path->mnt);
36143611
parent = old->mnt_parent;
36153612
attached = mnt_has_parent(old);
3616-
if (attached)
3617-
flags |= MNT_TREE_MOVE;
36183613
old_mp = old->mnt_mp;
36193614
ns = old->mnt_ns;
36203615

@@ -3668,7 +3663,6 @@ static int do_move_mount(struct path *old_path,
36683663

36693664
err = -EINVAL;
36703665
p = p->mnt_parent;
3671-
flags |= MNT_TREE_BENEATH;
36723666
}
36733667

36743668
/*
@@ -3683,7 +3677,7 @@ static int do_move_mount(struct path *old_path,
36833677
if (mount_is_ancestor(old, p))
36843678
goto out;
36853679

3686-
err = attach_recursive_mnt(old, p, mp, flags);
3680+
err = attach_recursive_mnt(old, p, mp);
36873681
if (err)
36883682
goto out;
36893683

0 commit comments

Comments
 (0)