[lxc-devel] [PATCH] busybox: for all lib dirs create mounts only if directories exist

Stéphane Graber stgraber at ubuntu.com
Wed Sep 12 18:47:55 UTC 2012


On 12-09-12 02:15 PM, Stuart Yoder wrote:
> From: Stuart Yoder <stuart.yoder at freescale.com>
> 
> Signed-off-by: Stuart Yoder <stuart.yoder at freescale.com>
> ---
> 
> -in our embedded ppc distro we have the other lib
>  dirs but no /usr/lib (for a 64-bit rootfs).  This
>  template currently breaks because of that.
> 
>  templates/lxc-busybox.in |   29 +++++++++++------------------
>  1 file changed, 11 insertions(+), 18 deletions(-)
> 
> diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
> index ef356db..a94eaa3 100644
> --- a/templates/lxc-busybox.in
> +++ b/templates/lxc-busybox.in
> @@ -235,24 +235,17 @@ lxc.pts = 1
>  lxc.rootfs = $rootfs
>  EOF
>  
> -if [ -d "$rootfs/lib" ]; then
> -cat <<EOF >> $path/config
> -lxc.mount.entry=/lib $rootfs/lib none ro,bind 0 0
> -lxc.mount.entry=/usr/lib $rootfs/usr/lib none ro,bind 0 0
> -EOF
> -fi
> -
> -if [ -d "/lib64" ] && [ -d "$rootfs/lib64" ]; then
> -cat <<EOF >> $path/config
> -lxc.mount.entry=/lib64 $rootfs/lib64 none ro,bind 0 0
> -EOF
> -fi
> -
> -if [ -d "/usr/lib64" ] && [ -d "$rootfs/usr/lib64" ]; then
> -cat <<EOF >> $path/config
> -lxc.mount.entry=/usr/lib64 $rootfs/usr/lib64 none ro,bind 0 0
> -EOF
> -fi
> +    libdirs="\
> +        /lib \
> +        /usr/lib \
> +        /lib64 \
> +        /usr/lib64"
> +
> +    for dir in $libdirs; do
> +        if [ -d $dir ] && [ -d "$rootfs$dir" ]; then
> +            echo "lxc.mount.entry=$dir $rootfs$dir none ro,bind 0 0" >> $path/config
> +        fi
> +    done
>  }
>  
>  usage()

Thanks for the patch, I'll apply it to the staging tree in a minute with
a minor change.
The current implementation seems to use absolute paths as the target
(/var/lib/lxc/<name>/rootfs/<path>) which isn't recommended as it's
making cloning a container much harder.

Instead, lxc now supports relative mounts, for example:
lxc.mount.entry=/usr/lib usr/lib none ro,bind 0 0

Thanks for your contribution

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 897 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20120912/20a1fefe/attachment.pgp>


More information about the lxc-devel mailing list