[CRIU] [PATCH 2/2] mkdir -p any dirs necessary for files
Andrew Vagin
avagin at parallels.com
Mon Jun 23 11:20:18 PDT 2014
On Mon, Jun 23, 2014 at 03:54:23PM +0000, Tycho Andersen wrote:
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
> files-reg.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/files-reg.c b/files-reg.c
> index 1f23f71..4647aa0 100644
> --- a/files-reg.c
> +++ b/files-reg.c
> @@ -7,6 +7,7 @@
> #include <sys/stat.h>
> #include <sys/vfs.h>
> #include <ctype.h>
> +#include <libgen.h>
>
> /* Stolen from kernel/fs/nfs/unlink.c */
> #define SILLYNAME_PREF ".nfs"
> @@ -709,8 +710,11 @@ static int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, v
> {
> u32 flags = *(u32 *)arg;
> int fd;
> + char *dir;
>
> fd = openat(ns_root_fd, rfi->path, flags);
> + dir = dirname(rfi->path);
> + mkdirpat(ns_root_fd, dir);
I don't understand how it should work.
You open file and then create a directory. If this directory doesn't
exist, the file can't be opened. You should fail on the next line,
should not you?
> if (fd < 0) {
> pr_perror("Can't open file %s on restore", rfi->path);
> return fd;
> --
> 1.9.1
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list