[CRIU] [PATCH 07/11] ghost: create ghost devices and directories in a specified ns

Andrey Vagin avagin at openvz.org
Sun Aug 3 11:31:21 PDT 2014


Here is a bug now. A path for devices and directories should be
generated with a specified root.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 files-reg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/files-reg.c b/files-reg.c
index d8875d6..00eef60 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -73,8 +73,9 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, char *root,
 	int gfd, ghost_flags, ret = -1;
 	char path[PATH_MAX];
 
+	snprintf(path, sizeof(path), "%s/%s", root, gf->remap.path);
 	if (S_ISFIFO(gfe->mode)) {
-		if (mknod(gf->remap.path, gfe->mode, 0)) {
+		if (mknod(path, gfe->mode, 0)) {
 			pr_perror("Can't create node for ghost file");
 			goto err;
 		}
@@ -85,13 +86,13 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, char *root,
 			goto err;
 		}
 
-		if (mknod(gf->remap.path, gfe->mode, gfe->rdev)) {
+		if (mknod(path, gfe->mode, gfe->rdev)) {
 			pr_perror("Can't create node for ghost dev");
 			goto err;
 		}
 		ghost_flags = O_WRONLY;
 	} else if (S_ISDIR(gfe->mode)) {
-		if (mkdir(gf->remap.path, gfe->mode)) {
+		if (mkdir(path, gfe->mode)) {
 			pr_perror("Can't make ghost dir");
 			goto err;
 		}
@@ -99,7 +100,6 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, char *root,
 	} else
 		ghost_flags = O_WRONLY | O_CREAT | O_EXCL;
 
-	snprintf(path, sizeof(path), "%s/%s", root, gf->remap.path);
 	gfd = open(path, ghost_flags, gfe->mode);
 	if (gfd < 0) {
 		pr_perror("Can't open ghost file %s", path);
-- 
1.8.5.3



More information about the CRIU mailing list