[CRIU] [PATCH] crtools: chdir to work dir before log_init

Ruslan Kuprieiev kupruser at gmail.com
Tue Nov 19 03:51:41 PST 2013


After set of patches which add --work-dir option we have an issue: logs are created relatively
to current dir and not relatively to images dir(which is work dir, when --work-dir is not given).
To solve this lets chdir to work dir, before log_init.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 crtools.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/crtools.c b/crtools.c
index b680236..0565c74 100644
--- a/crtools.c
+++ b/crtools.c
@@ -285,6 +285,11 @@ int main(int argc, char *argv[])
 	if (work_dir == NULL)
 		work_dir = imgs_dir;
 
+	if (chdir(work_dir)) {
+		pr_perror("Can't change directory to %s", work_dir);
+		return -1;
+	}
+
 	log_set_loglevel(log_level);
 
 	if (log_init(opts.output))
@@ -305,11 +310,6 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	if (chdir(work_dir)) {
-		pr_perror("Can't change directory to %s", work_dir);
-		return -1;
-	}
-
 	if (!strcmp(argv[optind], "dump")) {
 		if (!tree_id)
 			goto opt_pid_missing;
-- 
1.8.1.2



More information about the CRIU mailing list