1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
4# Copyright (c) 2018-2019 ARM Ltd. All Rights Reserved.
5
6. tst_test.sh
7
8# Find mountpoint to given subsystem
9# get_cgroup_mountpoint SUBSYSTEM
10# RETURN: 0 if mountpoint found, otherwise 1
11get_cgroup_mountpoint()
12{
13	local subsystem=$1
14	local mntpoint
15
16	[ $# -eq 0 ] && tst_brk TBROK "get_cgroup_mountpoint: subsystem not defined"
17
18	mntpoint=$(grep cgroup /proc/mounts | grep -w $subsystem | awk '{ print $2 }')
19	[ -z "$mntpoint" ] && return 1
20
21	echo $mntpoint
22	return 0
23}
24