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

Pavel Emelyanov xemul at parallels.com
Fri Nov 15 11:22:39 PST 2013


On 11/16/2013 02:33 AM, Ruslan Kuprieiev wrote:
> 
> 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);

open_image_at(AT_FDCWD, ...) and you don't have to open(".");

>  	if (fd >= 0) {
>  		pb_write_one(fd, &stats, PB_STATS);
>  		close(fd);
>  	}
> +
> +	close(dfd);
>  }
>  
>  int init_stats(int what)
> 




More information about the CRIU mailing list