]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
legacy/lxc-ls: improve finding fs mountpoint of hierarchy
authorNatanael Copa <ncopa@alpinelinux.org>
Wed, 26 Dec 2012 09:07:04 +0000 (10:07 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 2 Jan 2013 17:48:13 +0000 (12:48 -0500)
We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/legacy/lxc-ls.in

index 6757f27bf85ce64afe36877b2d62ff1d2fe4d7b0..7a298c62d7b8dd467354e820434d114ada339766 100644 (file)
@@ -54,7 +54,8 @@ get_parent_cgroup()
                init_cgroup=${fields#*:}
 
                # Get the filesystem mountpoint of the hierarchy
-               mountpoint=$(grep -E "^[^ ]+ [^ ]+ cgroup ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
+               mountpoint=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
+                       '$3 == "cgroup" && $4 ~ subsysregex {print $2}' /proc/self/mounts)
                if [ -z "$mountpoint" ]; then continue; fi
 
                # Return the absolute path to the containers' parent cgroup