mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-22 20:01:53 +01:00
target: Robustify read_tree_values()
target.read_tree_values() has several weaknesses. It doesn't support files with ':' in their name, and it fails when reading binary files. In essence, these limitations are cause by its fragile implementation based on grep in shutils. In order to robustify read_tree_values(), use tar and base64 to send the content of a tree to the host, which can then process it from there. In the process, read_tree_values() gains two new arguments: - decode_unicode: must be set to work text/utf-8 content; - strip_null_chars: must be set to remove '\00' chars from text files. Both are set to true by default to keep backward compatibility with the existing code. Suggested-by: Douglas Raillard <douglas.raillard@arm.com> Signed-off-by: Quentin Perret <quentin.perret@arm.com>
This commit is contained in:
committed by
Marc Bonnici
parent
911a9f2ef4
commit
7e79eeb9cb
@@ -255,26 +255,32 @@ sched_get_kernel_attributes() {
|
||||
# Misc
|
||||
################################################################################
|
||||
|
||||
read_tree_values() {
|
||||
read_tree_tgz_b64() {
|
||||
BASEPATH=$1
|
||||
MAXDEPTH=$2
|
||||
TMPBASE=$3
|
||||
|
||||
if [ ! -e $BASEPATH ]; then
|
||||
echo "ERROR: $BASEPATH does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PATHS=$($BUSYBOX find $BASEPATH -follow -maxdepth $MAXDEPTH)
|
||||
i=0
|
||||
for path in $PATHS; do
|
||||
i=$(expr $i + 1)
|
||||
if [ $i -gt 1 ]; then
|
||||
break;
|
||||
fi
|
||||
cd $TMPBASE
|
||||
TMP_FOLDER=$($BUSYBOX realpath $($BUSYBOX mktemp -d XXXXXX))
|
||||
|
||||
# 'tar' doesn't work as expected on debugfs, so copy the tree first to
|
||||
# workaround the issue
|
||||
cd $BASEPATH
|
||||
for CUR_FILE in $($BUSYBOX find . -follow -type f -maxdepth $MAXDEPTH); do
|
||||
$BUSYBOX cp --parents $CUR_FILE $TMP_FOLDER/ 2> /dev/null
|
||||
done
|
||||
if [ $i -gt 1 ]; then
|
||||
$BUSYBOX grep -s '' $PATHS
|
||||
fi
|
||||
|
||||
cd $TMP_FOLDER
|
||||
$BUSYBOX tar cz * | $BUSYBOX base64
|
||||
|
||||
# Clean-up the tmp folder since we won't need it any more
|
||||
cd $TMPBASE
|
||||
rm -rf $TMP_FOLDER
|
||||
}
|
||||
|
||||
get_linux_system_id() {
|
||||
@@ -347,8 +353,8 @@ ftrace_get_function_stats)
|
||||
hotplug_online_all)
|
||||
hotplug_online_all
|
||||
;;
|
||||
read_tree_values)
|
||||
read_tree_values $*
|
||||
read_tree_tgz_b64)
|
||||
read_tree_tgz_b64 $*
|
||||
;;
|
||||
get_linux_system_id)
|
||||
get_linux_system_id $*
|
||||
|
Reference in New Issue
Block a user