[CRIU] [PATCH] stats: write stats at work directory

Ruslan Kuprieiev kupruser at gmail.com
Fri Nov 15 14:33:10 PST 2013


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

diff --git a/stats.c b/stats.c
index baf52af..f675c42 100644
--- a/stats.c
+++ b/stats.c
@@ -105,7 +105,7 @@ void write_stats(int what)
 	DumpStatsEntry ds_entry = DUMP_STATS_ENTRY__INIT;
 	RestoreStatsEntry rs_entry = RESTORE_STATS_ENTRY__INIT;
 	char *name;
-	int fd;
+	int fd, dfd;
 
 	pr_info("Writing stats\n");
 	if (what == DUMP_STATS) {
@@ -134,11 +134,19 @@ void write_stats(int what)
 	} else
 		return;
 
-	fd = open_image(CR_FD_STATS, O_DUMP, name);
+	dfd = open(".", O_RDONLY);
+	if (dfd < 0) {
+		pr_perror("Can't open cwd");
+		return;
+	}
+
+	fd = open_image_at(dfd, CR_FD_STATS, O_DUMP, name);
 	if (fd >= 0) {
 		pb_write_one(fd, &stats, PB_STATS);
 		close(fd);
 	}
+
+	close(dfd);
 }
 
 int init_stats(int what)
-- 
1.8.1.2



More information about the CRIU mailing list