Commit f358385a by Natanael Copa Committed by Stéphane Graber

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: 's avatarNatanael Copa <ncopa@alpinelinux.org> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent f3849d01
...@@ -51,7 +51,8 @@ get_parent_cgroup() ...@@ -51,7 +51,8 @@ get_parent_cgroup()
init_cgroup=${fields#*:} init_cgroup=${fields#*:}
# Get the filesystem mountpoint of the hierarchy # 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 if [ -z "$mountpoint" ]; then continue; fi
# Return the absolute path to the containers' parent cgroup # Return the absolute path to the containers' parent cgroup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment