<div dir="ltr">You are correct, don't know why I didn't use just open to start with. A new version is on the way.<div class="gmail_extra"><br><div class="gmail_quote">2017-03-16 1:45 GMT+00:00 Andrei Vagin <span dir="ltr"><<a href="mailto:avagin@virtuozzo.com" target="_blank">avagin@virtuozzo.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Tue, Mar 14, 2017 at 11:18:30PM +0000, rodrigo-bruno wrote:<br>
> ---<br>
> criu/image.c | 15 ++++++++++-----<br>
> criu/util.c | 5 +++++<br>
> 2 files changed, 15 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/criu/image.c b/criu/image.c<br>
> index 57d3c7b..e1bcea5 100644<br>
> --- a/criu/image.c<br>
> +++ b/criu/image.c<br>
> @@ -332,9 +332,14 @@ int do_open_remote_image(int dfd, char *path, int flags)<br>
> /* When using namespaces, the current dir is changed so we need to<br>
> * change to previous working dir and back to correctly open the image<br>
> * proxy and cache sockets. */<br>
> - int save = dirfd(opendir("."));<br>
> + DIR *save = opendir(".");<br>
<br>
</span>you use only a file descriptor, so I think you can use open()<br>
<br>
int old_cwd;<br>
<br>
old_cwd = open(".", O_PATH);<br>
if (old_cwd < ) {<br>
...<br>
<div><div class="m_-4706333337570932392h5"><br>
<br>
> + if (save == NULL) {<br>
> + pr_perror("unable to open current working directory");<br>
> + return -1;<br>
> + }<br>
> +<br>
> if (fchdir(get_service_fd(IMG_FD_<wbr>OFF)) < 0) {<br>
> - pr_debug("fchdir to dfd failed!\n");<br>
> + pr_perror("fchdir to dfd failed!\n");<br>
> return -1;<br>
> }<br>
><br>
> @@ -352,11 +357,11 @@ int do_open_remote_image(int dfd, char *path, int flags)<br>
> ret = write_remote_image_connection(<wbr>snapshot_id, path, O_WRONLY);<br>
> }<br>
><br>
> - if (fchdir(save) < 0) {<br>
> - pr_debug("fchdir to save failed!\n");<br>
> + if (fchdir(dirfd(save)) < 0) {<br>
> + pr_perror("fchdir to save failed");<br>
> return -1;<br>
> }<br>
> - close(save);<br>
> + closedir(save);<br>
><br>
> return ret;<br>
> }<br>
> diff --git a/criu/util.c b/criu/util.c<br>
> index 9fd8ba2..4156bf2 100644<br>
> --- a/criu/util.c<br>
> +++ b/criu/util.c<br>
> @@ -522,6 +522,11 @@ int copy_file(int fd_in, int fd_out, size_t bytes)<br>
> char *buffer = (char*) malloc(chunk);<br>
> ssize_t ret;<br>
><br>
> + if (buffer == NULL) {<br>
> + pr_perror("failed to allocate buffer to copy file");<br>
> + return -1;<br>
> + }<br>
> +<br>
> while (1) {<br>
> if (opts.remote) {<br>
> ret = read(fd_in, buffer, chunk);<br>
> --<br>
> 2.1.4<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> CRIU mailing list<br>
> <a href="mailto:CRIU@openvz.org" target="_blank">CRIU@openvz.org</a><br>
> <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/mailm<wbr>an/listinfo/criu</a><br>
</blockquote></div><br></div></div>