Commit e9ca7932 authored by Andrei Vagin's avatar Andrei Vagin Committed by Pavel Emelyanov

mnt: add a function to check whether a mount overmounts something

This function is going to be used more than once.

v2: don't change logic in this patch
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 4a6b286c
...@@ -655,6 +655,23 @@ static struct mount_info *find_fsroot_mount_for(struct mount_info *bm) ...@@ -655,6 +655,23 @@ static struct mount_info *find_fsroot_mount_for(struct mount_info *bm)
return NULL; return NULL;
} }
static bool does_mnt_overmount(struct mount_info *m)
{
struct mount_info *t;
if (!m->parent)
return false;
list_for_each_entry(t, &m->parent->children, siblings) {
if (m == t)
continue;
if (issubpath(t->mountpoint, m->mountpoint))
return true;
}
return false;
}
static int validate_mounts(struct mount_info *info, bool for_dump) static int validate_mounts(struct mount_info *info, bool for_dump)
{ {
struct mount_info *m, *t; struct mount_info *m, *t;
...@@ -719,13 +736,9 @@ static int validate_mounts(struct mount_info *info, bool for_dump) ...@@ -719,13 +736,9 @@ static int validate_mounts(struct mount_info *info, bool for_dump)
} }
} }
skip_fstype: skip_fstype:
list_for_each_entry(t, &m->parent->children, siblings) { if (does_mnt_overmount(m)) {
if (m == t) pr_err("Unable to handle mounts under %d:%s\n",
continue; m->mnt_id, m->mountpoint);
if (!issubpath(m->mountpoint, t->mountpoint))
continue;
pr_err("%d:%s is overmounted\n", m->mnt_id, m->mountpoint);
return -1; return -1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment