From: Serge E. Hallyn Date: Tue, 9 Aug 2011 14:51:01 +0000 (+0200) Subject: make lxc-netstat work when /etc/mtab is not /proc/mounts X-Git-Tag: lxc-0.7.5~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a1259d99f5ed53ff268b5f4ff0607129562ae96;p=thirdparty%2Flxc.git make lxc-netstat work when /etc/mtab is not /proc/mounts 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 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/819319 Forwarded: no Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in index 9f3e9f3cf..d7c68d758 100644 --- a/src/lxc/lxc-netstat.in +++ b/src/lxc/lxc-netstat.in @@ -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