[CRIU] [PATCH] Do not fail if /tmp does not exist

Saied Kazemi saied at google.com
Mon Apr 6 09:19:13 PDT 2015


On Mon, Apr 6, 2015 at 7:12 AM, Andrew Vagin <avagin at odin.com> wrote:

> On Fri, Apr 03, 2015 at 06:02:56PM -0700, Saied Kazemi wrote:
> > Currently if /tmp does not exist, CRIU fails because it will not be
> > able to create a temporary directory there.  But when checkpointing
> > and restoring containers, we cannot rely on the existence of /tmp.
> > For such containers, we should use root (/).  The temporary directory
> > will be removed after CRIU is done.
> >
> > Signed-off-by: Saied Kazemi <saied at google.com>
> > ---
> >  mount.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/mount.c b/mount.c
> > index 079430a..4ae1150 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -774,7 +774,9 @@ int open_mount(unsigned int s_dev)
> >  static int open_mountpoint(struct mount_info *pm)
> >  {
> >       int fd = -1, ns_old = -1;
> > -     char mnt_path[] = "/tmp/cr-tmpfs.XXXXXX";
> > +     char mnt_path_tmp[] = "/tmp2/cr-tmpfs.XXXXXX";
>
> s/tmp2/tmp ?
>

Oops.  I was trying different failure scenarios and forgot to revert back
to tmp.  Will send a new patch.



>
> > +     char mnt_path_root[] = "/cr-tmpfs.XXXXXX";
> > +     char *mnt_path = mnt_path_tmp;
> >       int cwd_fd;
> >
> >       /*
> > @@ -803,7 +805,10 @@ static int open_mountpoint(struct mount_info *pm)
> >       if (switch_ns(root_item->pid.real, &mnt_ns_desc, &ns_old) < 0)
> >               goto out;
> >
> > -     if (mkdtemp(mnt_path) == NULL) {
> > +     mnt_path = mkdtemp(mnt_path_tmp);
> > +     if (mnt_path == NULL && errno == ENOENT)
> > +             mnt_path = mkdtemp(mnt_path_root);
> > +     if (mnt_path == NULL) {
> >               pr_perror("Can't create a temporary directory");
> >               goto out;
> >       }
> > --
> > 1.9.1
>

--Saied
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20150406/dec18297/attachment.html>


More information about the CRIU mailing list