[CRIU] [PATCH 2/N] image: add imgs_dir parameter to open_images_dir()

Ruslan Kuprieiev kupruser at gmail.com
Thu Nov 14 17:33:50 PST 2013


We need this to use open_images_dir() without chdir-ing to dir.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 cr-service.c    | 2 +-
 crtools.c       | 2 +-
 image.c         | 6 +++---
 include/image.h | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cr-service.c b/cr-service.c
index 92ccd66..d2724e5 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -121,7 +121,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 		return -1;
 	}
 
-	if (open_image_dir() < 0)
+	if (open_image_dir(".") < 0)
 		return -1;
 
 	log_closedir();
diff --git a/crtools.c b/crtools.c
index 32f3f3b..d8de2ef 100644
--- a/crtools.c
+++ b/crtools.c
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
 	if (opts.img_parent)
 		pr_info("Will do snapshot from %s\n", opts.img_parent);
 
-	ret = open_image_dir();
+	ret = open_image_dir(".");
 	if (ret < 0) {
 		pr_perror("Can't open current directory");
 		return -1;
diff --git a/image.c b/image.c
index 649df88..1d8e97c 100644
--- a/image.c
+++ b/image.c
@@ -229,13 +229,13 @@ err:
 	return -1;
 }
 
-int open_image_dir(void)
+int open_image_dir(char *dir)
 {
 	int fd, ret;
 
-	fd = open(".", O_RDONLY);
+	fd = open(dir, O_RDONLY);
 	if (fd < 0) {
-		pr_perror("Can't open cwd");
+		pr_perror("Can't open dir %s", dir);
 		return -1;
 	}
 
diff --git a/include/image.h b/include/image.h
index 00d2e45..33dfbe4 100644
--- a/include/image.h
+++ b/include/image.h
@@ -68,7 +68,7 @@ extern bool ns_per_id;
 #define O_SHOW	(O_RDONLY)
 #define O_RSTR	(O_RDONLY)
 
-extern int open_image_dir(void);
+extern int open_image_dir(char *dir);
 extern void close_image_dir(void);
 
 int open_image_at(int dfd, int type, unsigned long flags, ...);
-- 
1.8.1.2



More information about the CRIU mailing list