[CRIU] [PATCH] log: open pidfile at work dir

Andrew Vagin avagin at parallels.com
Sun Nov 10 20:43:16 PST 2013


On Mon, Nov 11, 2013 at 06:22:53AM +0400, Ruslan Kuprieiev wrote:
> Lets open pidfile at work dir.
> 
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
>  log.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/log.c b/log.c
> index c06d1c2..a486299 100644
> --- a/log.c
> +++ b/log.c
> @@ -195,9 +195,15 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
>  
>  int write_pidfile(char *pfname, int pid)
>  {
> -	int fd;
> +	int fd, dfd;
>  
> -	fd = open(pfname, O_WRONLY | O_TRUNC | O_CREAT, 0600);

                case 'D':
                        if (chdir(optarg)) {
                                pr_perror("Can't change directory to %s",
                                                optarg);
                                return -1;
                        }
                        break;

The current dir is work dir, isn't it?

> +	dfd = get_service_fd(WORK_DIR_FD_OFF);
> +	if (dfd < 0) {
> +		pr_perror("Work directory isn't initialized");
> +		return -1;
> +	}
> +
> +	fd = openat(dfd, pfname, O_WRONLY | O_TRUNC | O_CREAT, 0600);
>  	if (fd == -1) {
>  		pr_perror("Can't open %s", pfname);
>  		return -1;
> -- 
> 1.8.1.2
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list