[lxc-devel] [PATCH 2/2] legacy/lxc-ls: improve finding fs mountpoint of hierarchy

Stéphane Graber stgraber at ubuntu.com
Wed Jan 2 17:47:59 UTC 2013


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 <ncopa at alpinelinux.org>

Same as 1/1, so all good.

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

Pushed to staging. Thanks.

> ---
>  src/lxc/legacy/lxc-ls.in | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/legacy/lxc-ls.in b/src/lxc/legacy/lxc-ls.in
> index fbb1385..7a90166 100644
> --- a/src/lxc/legacy/lxc-ls.in
> +++ b/src/lxc/legacy/lxc-ls.in
> @@ -54,7 +54,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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130102/9263423e/attachment.pgp>


More information about the lxc-devel mailing list