Commit dd43b3c5 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mnt: Helper for adding new set of mountpoints into global list

Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1009985e
...@@ -34,6 +34,20 @@ ...@@ -34,6 +34,20 @@
*/ */
struct mount_info *mntinfo; struct mount_info *mntinfo;
static void mntinfo_add_list(struct mount_info *new)
{
if (!mntinfo)
mntinfo = new;
else {
struct mount_info *pm;
/* Add to the tail. (FIXME -- make O(1) ) */
for (pm = mntinfo; pm->next != NULL; pm = pm->next)
;
pm->next = new;
}
}
static int open_mountpoint(struct mount_info *pm); static int open_mountpoint(struct mount_info *pm);
static struct mount_info *mnt_build_tree(struct mount_info *list); static struct mount_info *mnt_build_tree(struct mount_info *list);
...@@ -852,13 +866,7 @@ int dump_mnt_ns(struct ns_id *ns) ...@@ -852,13 +866,7 @@ int dump_mnt_ns(struct ns_id *ns)
if (dump_one_mountpoint(pm, img_fd)) if (dump_one_mountpoint(pm, img_fd))
goto err; goto err;
if (mntinfo == NULL) mntinfo_add_list(pms);
mntinfo = pms;
else {
for (pm = mntinfo; pm->next != NULL; pm = pm->next);
pm->next = pms;
}
ret = 0; ret = 0;
err: err:
close(img_fd); close(img_fd);
...@@ -1862,7 +1870,7 @@ struct ns_id *lookup_nsid_by_mnt_id(int mnt_id) ...@@ -1862,7 +1870,7 @@ struct ns_id *lookup_nsid_by_mnt_id(int mnt_id)
int collect_mnt_namespaces(void) int collect_mnt_namespaces(void)
{ {
struct mount_info *pm, *pms; struct mount_info *pms;
struct ns_id *ns; struct ns_id *ns;
int ret = -1; int ret = -1;
...@@ -1886,13 +1894,7 @@ int collect_mnt_namespaces(void) ...@@ -1886,13 +1894,7 @@ int collect_mnt_namespaces(void)
if (pms == NULL) if (pms == NULL)
goto err; goto err;
if (mntinfo == NULL) mntinfo_add_list(pms);
mntinfo = pms;
else {
for (pm = mntinfo; pm->next != NULL; pm = pm->next);
pm->next = pms;
}
} }
ret = 0; ret = 0;
err: err:
......
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