1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-19 18:31:53 +01:00

Target: add read_tree_values and read_tree_values_flat

Add two new methods to target that allow querying values of all sysfs
nodes in a sub-directory structure all at once. The difference is that
read_tree_values_flat returns a flat dict of path->value mappings;
read_tree_values returns a nested dict structure that mimics the
scanned sub-directories tree.
This commit is contained in:
Sergei Trofimov
2017-10-03 16:28:09 +01:00
parent 92fb54d57b
commit 181bc180c4
3 changed files with 88 additions and 0 deletions

View File

@@ -195,6 +195,22 @@ cgroups_freezer_set_state() {
exit 1
}
################################################################################
# Misc
################################################################################
read_tree_values() {
PATH=$1
MAXDEPTH=$2
PATHS=$($BUSYBOX find $PATH -follow -maxdepth $MAXDEPTH)
if [ ${#PATHS[@]} -eq 0 ]; then
echo "ERROR: '$1' does not exist"
else
$BUSYBOX grep -s '' $PATHS
fi
}
################################################################################
# Main Function Dispatcher
################################################################################
@@ -236,6 +252,9 @@ cgroups_freezer_set_state)
ftrace_get_function_stats)
ftrace_get_function_stats
;;
read_tree_values)
read_tree_values $*
;;
*)
echo "Command [$CMD] not supported"
exit -1