]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
legacy ls: only output appropriate directories/containers
authorDwight Engen <dwight.engen@oracle.com>
Tue, 12 Feb 2013 20:54:47 +0000 (15:54 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 18 Feb 2013 21:01:02 +0000 (16:01 -0500)
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@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/legacy/lxc-ls.in

index ec73c8f38b0619702a45b6fa3de989a1df847cf7..c0147c73d9482521841a736a68f3f6abd1671aea 100644 (file)
@@ -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"