[CRIU] [PATCH 1/3] util: Add flags to cr_system

Pavel Emelyanov xemul at parallels.com
Thu Nov 12 01:14:26 PST 2015


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 include/util.h | 4 ++--
 mount.c        | 4 ++--
 net.c          | 4 ++--
 netfilter.c    | 2 +-
 util.c         | 6 +++---
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/util.h b/include/util.h
index ee5e8e8..3f7718a 100644
--- a/include/util.h
+++ b/include/util.h
@@ -172,9 +172,9 @@ extern int is_anon_link_type(char *link, char *type);
 extern void *shmalloc(size_t bytes);
 extern void shfree_last(void *ptr);
 
-extern int cr_system(int in, int out, int err, char *cmd, char *const argv[]);
+extern int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags);
 extern int cr_system_userns(int in, int out, int err, char *cmd,
-				char *const argv[], int userns_pid);
+				char *const argv[], unsigned flags, int userns_pid);
 extern int cr_daemon(int nochdir, int noclose, int *keep_fd, int close_fd);
 extern int is_root_user(void);
 
diff --git a/mount.c b/mount.c
index 1016b97..3a15597 100644
--- a/mount.c
+++ b/mount.c
@@ -1203,7 +1203,7 @@ static int tmpfs_dump(struct mount_info *pm)
 			"--preserve-permissions",
 			"--sparse",
 			"--numeric-owner",
-			"--directory", tmpfs_path, ".", NULL }, userns_pid);
+			"--directory", tmpfs_path, ".", NULL }, 0, userns_pid);
 
 	if (ret)
 		pr_err("Can't dump tmpfs content\n");
@@ -1256,7 +1256,7 @@ static int tmpfs_restore(struct mount_info *pm)
 	ret = cr_system(img_raw_fd(img), -1, -1, "tar",
 			(char *[]) {"tar", "--extract", "--gzip",
 				"--no-unquote", "--no-wildcards",
-				"--directory", pm->mountpoint, NULL});
+				"--directory", pm->mountpoint, NULL}, 0);
 	close_image(img);
 
 	if (ret) {
diff --git a/net.c b/net.c
index 148d6b2..6531071 100644
--- a/net.c
+++ b/net.c
@@ -600,7 +600,7 @@ static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout)
 		ip_tool_cmd = "ip";
 
 	ret = cr_system(fdin, fdout, -1, ip_tool_cmd,
-				(char *[]) { "ip", arg1, arg2, arg3, NULL });
+				(char *[]) { "ip", arg1, arg2, arg3, NULL }, 0);
 	if (ret) {
 		pr_err("IP tool failed on %s %s\n", arg1, arg2);
 		return -1;
@@ -618,7 +618,7 @@ static int run_iptables_tool(char *def_cmd, int fdin, int fdout)
 	if (!cmd)
 		cmd = def_cmd;
 	pr_debug("\tRunning %s for %s\n", cmd, def_cmd);
-	ret = cr_system(fdin, fdout, -1, "sh", (char *[]) { "sh", "-c", cmd, NULL });
+	ret = cr_system(fdin, fdout, -1, "sh", (char *[]) { "sh", "-c", cmd, NULL }, 0);
 	if (ret)
 		pr_err("%s failed\n", def_cmd);
 
diff --git a/netfilter.c b/netfilter.c
index e6a2a42..95e18aa 100644
--- a/netfilter.c
+++ b/netfilter.c
@@ -64,7 +64,7 @@ static int nf_connection_switch_raw(int family, u32 *src_addr, u16 src_port,
 	 * cr_system is used here, because it blocks SIGCHLD before waiting
 	 * a child and the child can't be waited from SIGCHLD handler.
 	 */
-	ret = cr_system(-1, -1, -1, "sh", argv);
+	ret = cr_system(-1, -1, -1, "sh", argv, 0);
 	if (ret < 0 || !WIFEXITED(ret) || WEXITSTATUS(ret)) {
 		pr_perror("Iptables configuration failed");
 		return -1;
diff --git a/util.c b/util.c
index 7a22656..69b3102 100644
--- a/util.c
+++ b/util.c
@@ -509,13 +509,13 @@ void shfree_last(void *ptr)
  * If "in" is negative, stdin will be closed.
  * If "out" or "err" are negative, a log file descriptor will be used.
  */
-int cr_system(int in, int out, int err, char *cmd, char *const argv[])
+int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags)
 {
-	return cr_system_userns(in, out, err, cmd, argv, -1);
+	return cr_system_userns(in, out, err, cmd, argv, flags, -1);
 }
 
 int cr_system_userns(int in, int out, int err, char *cmd,
-			char *const argv[], int userns_pid)
+			char *const argv[], unsigned flags, int userns_pid)
 {
 	sigset_t blockmask, oldmask;
 	int ret = -1, status;
-- 
1.9.3



More information about the CRIU mailing list