[lxc-devel] [PATCH] legacy ls: only output appropriate directories/containers
Stéphane Graber
stgraber at ubuntu.com
Mon Feb 18 21:03:06 UTC 2013
On 02/12/2013 03:54 PM, Dwight Engen wrote:
> For lxc-ls without --active, only output a directory in lxc_path if it
> contains a file named config. This avoids extra directories that may
> exist in lxc_path, for example .snapshot if lxc_path is an nfs mount.
>
> For lxc-ls with --active, don't output . if there are no active
> containers.
>
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
Pushed to staging. Thanks
> ---
> src/lxc/legacy/lxc-ls.in | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/src/lxc/legacy/lxc-ls.in b/src/lxc/legacy/lxc-ls.in
> index ec73c8f..c0147c7 100644
> --- a/src/lxc/legacy/lxc-ls.in
> +++ b/src/lxc/legacy/lxc-ls.in
> @@ -85,7 +85,14 @@ done
>
> containers=""
> if [ ! -z "$directory" ]; then
> - containers=$(find $directory -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')
> + if [ x"$parent_cgroup" = x ]; then
> + containers=$(find $directory -mindepth 2 -maxdepth 2 -name config -type f |awk -F "/" '{print $(NF-1)}')
> + else
> + containers=$(find $directory -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')
> + fi
> + if [ x"$containers" = x ]; then
> + exit 0
> + fi
> fi
>
> cd "$directory"
>
--
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: 901 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130218/cd14bc99/attachment.pgp>
More information about the lxc-devel
mailing list