[CRIU] [PATCH 2/4] mounts: use relative paths for mountpoints (v2)
Andrey Vagin
avagin at openvz.org
Mon Feb 24 00:04:48 PST 2014
v2: don't use snprintf
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/mount.c b/mount.c
index a5436a6..795f947 100644
--- a/mount.c
+++ b/mount.c
@@ -45,9 +45,10 @@ static int close_mountpoint(DIR *dfd);
static struct mount_info *mnt_build_tree(struct mount_info *list);
static int validate_mounts(struct mount_info *info, bool call_plugins);
+/* Asolute paths are used on dump and relative paths are used on restore */
static inline int is_root(char *p)
{
- return p[0] == '/' && p[1] == '\0';
+ return (!strcmp(p, "/") || !strcmp(p, "./"));
}
/* True for the root mount (the topmost one) */
@@ -78,7 +79,7 @@ int open_mount(unsigned int s_dev)
if (mntns_root == -1) {
pr_debug("mpopen %s\n", i->mountpoint);
return open(i->mountpoint, O_RDONLY);
- } else if (i->mountpoint[1] == '\0') {
+ } else if (is_root_mount(i)) {
pr_debug("mpopen root\n");
return dup(mntns_root);
} else {
@@ -1359,6 +1360,7 @@ static struct mount_info *read_mnt_ns_img(int ns_pid)
while (1) {
struct mount_info *pm;
+ int len;
ret = pb_read_one_eof(img, &me, PB_MNT);
if (ret <= 0)
@@ -1387,10 +1389,13 @@ static struct mount_info *read_mnt_ns_img(int ns_pid)
if (!pm->root)
goto err;
- pr_debug("\t\tGetting mpt for %d\n", pm->mnt_id);
- pm->mountpoint = xstrdup(me->mountpoint);
+ pr_debug("\t\tGetting mpt for %d:%s\n", pm->mnt_id, me->mountpoint);
+ len = strlen(me->mountpoint) + 2;
+ pm->mountpoint = xmalloc(len);
if (!pm->mountpoint)
goto err;
+ pm->mountpoint[0] = '.';
+ strcpy(pm->mountpoint + 1, me->mountpoint);
pr_debug("\t\tGetting source for %d\n", pm->mnt_id);
pm->source = xstrdup(me->source);
--
1.8.5.3
More information about the CRIU
mailing list