[CRIU] [PATCH] image: img_parent symlinkat and openat images dir
Andrew Vagin
avagin at parallels.com
Sat Nov 16 10:30:39 PST 2013
On Sat, Nov 16, 2013 at 06:55:17PM +0400, Ruslan Kuprieiev wrote:
> This patch will fix zdtm test failure.
>
Tested-by: Andrew Vagin <avagin at parallels.com>
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
> image.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/image.c b/image.c
> index 1d8e97c..d696bdb 100644
> --- a/image.c
> +++ b/image.c
> @@ -231,36 +231,36 @@ err:
>
> int open_image_dir(char *dir)
> {
> - int fd, ret;
> + int fd1, fd2, ret;
Pls use more descriptive names for variables.
>
> - fd = open(dir, O_RDONLY);
> - if (fd < 0) {
> + fd1 = open(dir, O_RDONLY);
> + if (fd1 < 0) {
> pr_perror("Can't open dir %s", dir);
> return -1;
> }
>
> - ret = install_service_fd(IMG_FD_OFF, fd);
> -
> - close(fd);
> + ret = install_service_fd(IMG_FD_OFF, fd1);
Could you add error handling?
>
> if (opts.img_parent) {
> - ret = symlink(opts.img_parent, CR_PARENT_LINK);
> + ret = symlinkat(opts.img_parent, fd1, CR_PARENT_LINK);
> if (ret < 0) {
> pr_perror("Can't link parent snapshot.");
> goto err;
> }
>
> - fd = open(CR_PARENT_LINK, O_RDONLY);
> - if (fd < 0) {
> + fd2 = openat(fd1, CR_PARENT_LINK, O_RDONLY);
> + if (fd2 < 0) {
> pr_perror("Can't open parent snapshot.");
> goto err;
> }
>
> - ret = install_service_fd(PARENT_FD_OFF, fd);
> + ret = install_service_fd(PARENT_FD_OFF, fd2);
>
> - close(fd);
> + close(fd2);
> }
>
> + close(fd1);
> +
> return ret;
>
> err:
> --
> 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