2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

mount: add mntinfo_add_list_before helper for adding to mntinfo list

Use this helper everywhere instead of manually adding mounts to the head
of the list, this way it is much easier to track all places where we do
add to mntinfo list.

Signed-off-by: Alexander Mikhalitsyn (Virtuozzo) <alexander@mihalicyn.com>

Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/7bca9397b

Changes: skip hunk adding root_yard_mp to the list because root yard has
not fully initialized mountinfo structure (can break code which uses
mntinfo fallback in lookup_nsid_by_mnt_id), let's only have real mounts
in mntinfo list. Also skip cr_time mount from mntinfo list for the same
reason.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Alexander Mikhalitsyn
2020-04-12 20:53:54 +03:00
committed by Andrei Vagin
parent 9649356e3a
commit eda1e5fdbd
3 changed files with 12 additions and 8 deletions

View File

@@ -90,6 +90,9 @@ struct mount_info {
};
extern struct mount_info *mntinfo;
extern void mntinfo_add_list_before(struct mount_info **head, struct mount_info *new);
extern struct ns_desc mnt_ns_desc;
#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
extern int collect_binfmt_misc(void);

View File

@@ -127,6 +127,12 @@ static void mntinfo_add_list(struct mount_info *new)
}
}
void mntinfo_add_list_before(struct mount_info **head, struct mount_info *new)
{
new->next = *head;
*head = new;
}
static struct mount_info *__lookup_overlayfs(struct mount_info *list, char *rpath, unsigned int st_dev,
unsigned int st_ino, unsigned int mnt_id)
{
@@ -1527,8 +1533,6 @@ static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsnam
mi->nsid = parent->nsid;
mi->parent = parent;
mi->parent_mnt_id = parent->mnt_id;
mi->next = parent->next;
parent->next = mi;
list_add(&mi->siblings, &parent->children);
pr_info("Add cr-time mountpoint %s with parent %s(%u)\n", mi->mountpoint, parent->mountpoint, parent->mnt_id);
return 0;
@@ -3015,8 +3019,7 @@ static int collect_mnt_from_image(struct mount_info **head, struct mount_info **
goto err;
pm->nsid = nsid;
pm->next = *head;
*head = pm;
mntinfo_add_list_before(head, pm);
if (!*tail)
*tail = pm;

View File

@@ -1651,10 +1651,8 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
if (fsname)
free(fsname);
if (new) {
new->next = list;
list = new;
}
if (new)
mntinfo_add_list_before(&list, new);
if (ret)
goto err;