[Lxc-users] [PATCH 2/3] make lxc-netstat work when /etc/mtab is not /proc/mounts

Serge E. Hallyn serge.hallyn at canonical.com
Wed Aug 3 14:57:23 UTC 2011


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 at canonical.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/819319
Forwarded: no

Index: lxc/src/lxc/lxc-netstat.in
===================================================================
--- lxc.orig/src/lxc/lxc-netstat.in	2011-08-01 10:17:02.909590412 -0500
+++ lxc/src/lxc/lxc-netstat.in	2011-08-01 11:22:11.509678274 -0500
@@ -60,6 +60,16 @@
 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
 fi




More information about the lxc-users mailing list