]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
make lxc-netstat work when /etc/mtab is not /proc/mounts
authorSerge E. Hallyn <serge.hallyn@canonical.com>
Tue, 9 Aug 2011 14:51:01 +0000 (16:51 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 9 Aug 2011 14:51:01 +0000 (16:51 +0200)
like lxc-ps and lxc-ls, lxc-netstat breaks if there is not an 'lxc' cgroup
mount and /etc/mtab is not a link to /proc/mounts.
Author: Serge Hallyn <serge.hallyn@canonical.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/819319
Forwarded: no

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc-netstat.in

index 9f3e9f3cfd91bea7d3af4f534e33a9e435846c41..d7c68d7581a12f0c05249cb76ac6f6aa41038aa1 100644 (file)
@@ -59,6 +59,16 @@ for i in "$cgroups"; do
 
 done
 
+if [ -z "$cgroup_path" ]; then
+       cgroups=`grep -m1 -E '^[^ \t]+[ \t]+[^ \t]+[ \t]+cgroup' /proc/self/mounts`
+       for i in "$cgroups"; do
+           cgroup_path=$(echo $i | awk ' { print $2 } ')
+           if [ -n $cgroup_path ]; then
+               break;
+           fi
+       done
+fi
+
 if [ -z "$cgroup_path" ]; then
     echo "no cgroup mount point found"
     exit 1