From a670b0b4aed129dc11b465c1c330bfe9202023e5 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 18 Mar 2018 17:54:02 -0700 Subject: kbuild: Use ls(1) instead of stat(1) to obtain file size stat(1) is not standardized and different implementations have their own (conflicting) flags for querying the size of a file. ls(1) provides the same information (value of st.st_size) in the 5th column, except when the file is a character or block device. This output is standardized[0]. The -n option turns on -l, which writes lines formatted like "%s %u %s %s %u %s %s\n", , , , , , , but instead of writing the and , it writes the numeric owner and group IDs (this avoids /etc/passwd and /etc/group lookups as well as potential field splitting issues). The field is specified as "the value that would be returned for the file in the st_size field of struct stat". To avoid duplicating logic in several locations in the tree, create scripts/file-size.sh and update callers to use that instead of stat(1). [0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html#tag_20_73_10 Signed-off-by: Michael Forney Signed-off-by: Masahiro Yamada --- arch/arm/boot/deflate_xip_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm/boot/deflate_xip_data.sh') diff --git a/arch/arm/boot/deflate_xip_data.sh b/arch/arm/boot/deflate_xip_data.sh index 1189598a25eb..07adfc734fa3 100755 --- a/arch/arm/boot/deflate_xip_data.sh +++ b/arch/arm/boot/deflate_xip_data.sh @@ -45,7 +45,7 @@ data_start=$(($__data_loc - $base_offset)) data_end=$(($_edata_loc - $base_offset)) # Make sure data occupies the last part of the file. -file_end=$(stat -c "%s" "$XIPIMAGE") +file_end=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$XIPIMAGE") if [ "$file_end" != "$data_end" ]; then printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \ $(($file_end + $base_offset)) $_edata_loc 2>&1 -- cgit