On 12/26/2012 04:07 AM, Natanael Copa wrote:
> 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: Natanael Copa <nc...@alpinelinux.org>

Acked-by: Stéphane Graber <stgra...@ubuntu.com>

Pushed to staging. Thanks.

> ---
>  src/lxc/lxc-netstat.in | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in
> index 87bd3eb..6d08ce3 100644
> --- a/src/lxc/lxc-netstat.in
> +++ b/src/lxc/lxc-netstat.in
> @@ -51,7 +51,8 @@ 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=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
> +            '$3 == "cgroup" && $4 ~ subsysregex {print $2}' 
> /proc/self/mounts)
>          if [ -z "$mountpoint" ]; then continue; fi
>  
>          # Return the absolute path to the containers' parent cgroup
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to