[CRIU] [PATCH 2/2] mkdir -p any dirs necessary for files

Andrew Vagin avagin at parallels.com
Tue Jun 24 01:28:14 PDT 2014


On Tue, Jun 24, 2014 at 10:51:27AM +0400, Pavel Emelyanov wrote:
> On 06/24/2014 06:57 AM, Tycho Andersen wrote:
> > On Mon, Jun 23, 2014 at 10:20:18PM +0400, Andrew Vagin wrote:
> >> 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?
> > 
> > Hmm. You are correct, except that this fixes an issue for me. Without
> > it, I get:
> > 
> > (00.320920)    364: Error (files-reg.c:721): Can't open file /dev/lxc/tty3 on restore: No such file or directory
> > (00.320940)    364: Error (files-reg.c:686): Can't open file /dev/lxc/tty3: No such file or directory
> 
> This /dev/lxc/tty3 file -- what is it? Is it a tmpfs/devtmpfs filesystem? They
> should not be just regular files on regular FS, why do they disappear after dump?

1480 1470 0:12 /8 /dev/lxc/tty4 rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000

Looks like an external bind-mount.

> 
> > but with it things "work" just fine (i.e. it gets past this point in
> > the restore process). Is it possible that the errors here are ignored,
> > so the directory is made but the file is never restored, but criu is
> > ignoring errors?
> > 
> > I will investigate more tomorrow, although if anyone has any thoughts
> > they would be much appreciated.
> > 
> > Tycho
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
> > 
> 


More information about the CRIU mailing list