[CRIU] [PATCH 2/5] crtools: chdir to images dir after processing all command line options

Pavel Emelyanov xemul at parallels.com
Tue Nov 12 11:20:57 PST 2013


On 11/13/2013 01:42 AM, Ruslan Kuprieiev wrote:

That's not natural. I'd expect that we chdir() to workdir ;)
This will be a) natural and b) save one service fd.

> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
>  crtools.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/crtools.c b/crtools.c
> index 4a0017f..b9313b1 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -78,6 +78,7 @@ int main(int argc, char *argv[])
>  	int ret = -1;
>  	int opt, idx;
>  	int log_level = 0;
> +	char *imgs_dir = ".";
>  
>  	BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
>  
> @@ -163,11 +164,7 @@ int main(int argc, char *argv[])
>  			opts.restore_detach = true;
>  			break;
>  		case 'D':
> -			if (chdir(optarg)) {
> -				pr_perror("Can't change directory to %s",
> -						optarg);
> -				return -1;
> -			}
> +			imgs_dir = optarg;
>  			break;
>  		case 'W':
>  			break;
> @@ -283,6 +280,11 @@ int main(int argc, char *argv[])
>  		}
>  	}
>  
> +	if (chdir(imgs_dir)) {
> +		pr_perror("Can't change directory to %s", optarg);
> +		return -1;
> +	}
> +
>  	log_set_loglevel(log_level);
>  
>  	if (log_init(opts.output))
> 




More information about the CRIU mailing list