diff --git a/criu/include/mount.h b/criu/include/mount.h index b959d131c..f180fe58d 100644 --- a/criu/include/mount.h +++ b/criu/include/mount.h @@ -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); diff --git a/criu/mount.c b/criu/mount.c index c301aaeeb..7035d992a 100644 --- a/criu/mount.c +++ b/criu/mount.c @@ -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; diff --git a/criu/proc_parse.c b/criu/proc_parse.c index f7abd4d52..7955d50a6 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -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;