From: Natanael Copa Date: Wed, 26 Dec 2012 09:07:03 +0000 (+0100) Subject: lxc-netstat: improve finding fs mountpoint of hierarchy X-Git-Tag: lxc-0.9.0.alpha3~1^2~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f358385a7cf0ec74925d7f26b8a9dab1225dc2b6;p=thirdparty%2Flxc.git lxc-netstat: improve finding fs mountpoint of hierarchy 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 Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in index 87bd3ebb5..6d08ce379 100644 --- a/src/lxc/lxc-netstat.in +++ b/src/lxc/lxc-netstat.in @@ -51,7 +51,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