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.
diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in
index 6d78be7..004030d 100755
--- a/devlib/bin/scripts/shutils.in
+++ b/devlib/bin/scripts/shutils.in
@@ -196,6 +196,22 @@
}
################################################################################
+# 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 @@
ftrace_get_function_stats)
ftrace_get_function_stats
;;
+read_tree_values)
+ read_tree_values $*
+ ;;
*)
echo "Command [$CMD] not supported"
exit -1