[lxc-devel] [PATCH] Fix parsing /proc/self/mounts in lxc-{ls, netstat, ps}

Ryota Ozaki ozaki.ryota at gmail.com
Thu May 31 12:15:16 UTC 2012


The original code assumes that 1st column is mount type,
however, 3rd column is really mount type. Fix it.

Signed-off-by: Ryota Ozaki <ozaki.ryota at gmail.com>
---
 src/lxc/lxc-ls.in      |    2 +-
 src/lxc/lxc-netstat.in |    2 +-
 src/lxc/lxc-ps.in      |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in
index 11a3b45..1c5f8c5 100644
--- a/src/lxc/lxc-ls.in
+++ b/src/lxc/lxc-ls.in
@@ -57,7 +57,7 @@ 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=$(grep -E "^[^ ]+ [^ ]+ cgroup ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
 		if [ -z "$mountpoint" ]; then continue; fi
 
 		# Return the absolute path to the containers' parent cgroup
diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in
index 113c0da..0663d56 100644
--- a/src/lxc/lxc-netstat.in
+++ b/src/lxc/lxc-netstat.in
@@ -53,7 +53,7 @@ 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=$(grep -E "^[^ ]+ [^ ]+ cgroup ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
 		if [ -z "$mountpoint" ]; then continue; fi
 
 		# Return the absolute path to the containers' parent cgroup
diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in
index a9923f0..c665bc6 100644
--- a/src/lxc/lxc-ps.in
+++ b/src/lxc/lxc-ps.in
@@ -56,7 +56,7 @@ 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=$(grep -E "^[^ ]+ [^ ]+ cgroup ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
 		if [ -z "$mountpoint" ]; then continue; fi
 
 		# Return the absolute path to the containers' parent cgroup
-- 
1.7.9.5





More information about the lxc-devel mailing list