[CRIU] [PATCH 2/5] crtools: make pid parameter optional for open_image_ro()

Kinsbursky Stanislav skinsbursky at openvz.org
Fri Mar 23 10:41:54 EDT 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 include/crtools.h |    2 +-
 util.c            |   10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
-------------- next part --------------
diff --git a/include/crtools.h b/include/crtools.h
index 60cea96..84ad4b8 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -103,7 +103,7 @@ extern void close_image_dir(void);
 
 int open_image(int type, unsigned long flags, ...);
 #define open_image_ro(type, ...)	open_image(type, O_RDONLY, ##__VA_ARGS__)
-extern int open_image_ro_nocheck(const char *fmt, int pid);
+extern int open_image_ro_nocheck(const char *fmt, ...);
 
 #define LAST_PID_PATH		"/proc/sys/kernel/ns_last_pid"
 #define LAST_PID_PERM		0666
diff --git a/util.c b/util.c
index 44526f5..2da09dc 100644
--- a/util.c
+++ b/util.c
@@ -129,15 +129,19 @@ int move_img_fd(int *img_fd, int want_fd)
 	return 0;
 }
 
-int open_image_ro_nocheck(const char *fmt, int pid)
+int open_image_ro_nocheck(const char *fmt, ...)
 {
 	char path[PATH_MAX];
+	va_list args;
 	int tmp;
 
-	sprintf(path, fmt, pid);
+	va_start(args, fmt);
+	vsprintf(path, fmt, args);
+	va_end(args);
+
 	tmp = openat(image_dir_fd, path, O_RDONLY);
 	if (tmp < 0)
-		pr_warn("Can't open image %s for %d: %m\n", fmt, pid);
+		pr_warn("Can't open image %s: %m\n", path);
 
 	return tmp;
 }


More information about the CRIU mailing list