[lxc-devel] [RFC] Fix for parsing various mount options

Guido Trotter ultrotter at google.com
Fri Apr 3 08:49:15 UTC 2009


On Fri, Apr 3, 2009 at 4:25 AM, Ryousei Takano
<takano-ryousei at aist.go.jp> wrote:
> Hi Daniel and all,
>
> I am trying a fast container cloning using aufs (advanced multi layered
> unification filesystem). That means a container rootfs is overlaid on top of
> the template rootfs in a copy-on-write manner.
>
> lxc-start setups the rootfs according to $LXCPATH/test/fstab:
>
>        none /opt/lxc.root/rootfs.test aufs br=/opt/lxc.root/cowfs.test:/opt/lxc.root/rootfs.debian.tmpl=ro 0 0
>
>        /opt/lxc.root/rootfs.test /usr/local/var/lib/lxc/test/rootfs none rbind 0 0
>
> To do that, we need to pass the aufs specific mount option to mount(2).
> But setup_mount() ignores this option.
>
> This patch fixes setup_mount() for parsing these kind of options.
> As far as I know hasmntopt(3) cannot parse non literal options, so it adds
> a new function called parse_mntopts() instead of using hasmntopt(3).
>
> Any comments and suggestions will be appreciated.
>
> Signed-off-by: Ryousei Takano <takano-ryousei at aist.go.jp>
> ---
>  src/lxc/conf.c |   93 ++++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 files changed, 81 insertions(+), 12 deletions(-)
>
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index 6c3476a..5da9660 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -1026,13 +1026,82 @@ static int setup_cgroup(const char *name)
>                                      line, MAXPATHLEN, (void *)name);
>  }
>
> +static int parse_mntopts(struct mntent *mntent, unsigned long *mntflags,
> +                        char **mntopts)
> +{
> +#if 1

I think the

#if 1 ...
# else

makes it less readable, by adding dead code...
If you really want the other code, why not putting it in a comment,
together with an explanation of why it wouldn't work?

Thanks,

Guido




More information about the lxc-devel mailing list