[lxc-devel] [PATCH 1/2] lxc-start: ensure overlayfs workdir exists

Serge Hallyn serge.hallyn at ubuntu.com
Mon May 4 13:39:29 UTC 2015


Quoting Marcin Bachry (hegel666 at gmail.com):
> New versions of overlayfs require "workdir" mount option. LXC silently
> infers workdir path from upper directory provided by user in the
> config, but makes no effort to ensure the directory actually
> exists.
> 
> Signed-off-by: Marcin Bachry <hegel666 at gmail.com>

Oh, sorry, I'd sent a patch last week to fix this.  Note that you'd need to
free the mntdata before returning.

> ---
>  src/lxc/bdev.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
> index cf7c043..abc75f8 100644
> --- a/src/lxc/bdev.c
> +++ b/src/lxc/bdev.c
> @@ -2204,6 +2204,10 @@ static int overlayfs_mount(struct bdev *bdev)
>  	work = alloca(lastslashidx + 7);
>  	strncpy(work, upper, lastslashidx+7);
>  	strcpy(work+lastslashidx, "olwork");
> +	if ((mkdir(work, 0755) < 0) && errno != EEXIST) {
> +		SYSERROR("error: mkdir %s", work);
> +		return -22;
> +	}
>  
>  	if (parse_mntopts(bdev->mntopts, &mntflags, &mntdata) < 0) {
>  		free(mntdata);
> -- 
> 2.1.4
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list