[CRIU] [PATCH] mount: Create target of bind mount if it doesn't exist

Tycho Andersen tycho.andersen at canonical.com
Thu Aug 28 08:50:37 PDT 2014


Hi Saied,

On Thu, Aug 28, 2014 at 08:43:06AM -0700, Saied Kazemi wrote:
> I have seen a similar case where /dev/null is missing (Docker using
> UnionFS).  While this patch fixes the issue, I am wondering why the target

So I have a similar issue with a missing /dev/null that I'm looking
into right now, mine is:

Error (files-reg.c:805): Can't open file dev/null: No such file or directory

is that what you're referring to? This patch only addresses targets of
bind mounts, not the above.

Tycho

> file should be missing to start with and whether *always* recreating
> missing target files could be masking more serious issues.  Any thoughts?
> 
> --Saied
> 
> 
> 
> On Thu, Aug 28, 2014 at 8:27 AM, Tycho Andersen <
> tycho.andersen at canonical.com> wrote:
> 
> > If the target of a bind mount doesn't exist, create it. In particular, this
> > happens with /dev/ptmx across hosts under LXC. We could also mkdir -p any
> > path
> > to the target, although I'm not sure if that is a case that occurrs in the
> > wild.
> >
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  mount.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/mount.c b/mount.c
> > index 9bb8a17..2108907 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -1346,6 +1346,24 @@ static int do_bind_mount(struct mount_info *mi)
> >                 root = rpath;
> >  do_bind:
> >                 pr_info("\tBind %s to %s\n", root, mi->mountpoint);
> > +
> > +               if (access(mi->mountpoint, F_OK)) {
> > +                       if (errno == ENOENT) {
> > +                               FILE *f;
> > +
> > +                               f = fopen(mi->mountpoint, "w");
> > +                               if (!f) {
> > +                                       pr_perror("couldn't write 0 length
> > %s", mi->mountpoint);
> > +                                       return -1;
> > +                               }
> > +
> > +                               fclose(f);
> > +                       } else {
> > +                               pr_perror("Couldn't access %s",
> > mi->mountpoint);
> > +                               return -1;
> > +                       }
> > +               }
> > +
> >                 if (mount(root, mi->mountpoint, NULL,
> >                                         MS_BIND, NULL) < 0) {
> >                         pr_perror("Can't mount at %s", mi->mountpoint);
> > --
> > 1.9.1
> >
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
> >


More information about the CRIU mailing list