diff options
author | Michael Forney <forney@google.com> | 2018-03-19 01:54:02 +0100 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-03-25 19:01:24 +0200 |
commit | a670b0b4aed129dc11b465c1c330bfe9202023e5 (patch) | |
tree | b92c66454350b3be0f8197877022122c81bc8f20 /arch/powerpc/boot | |
parent | kbuild: link vmlinux only once for CONFIG_TRIM_UNUSED_KSYMS (diff) | |
download | linux-a670b0b4aed129dc11b465c1c330bfe9202023e5.tar.xz linux-a670b0b4aed129dc11b465c1c330bfe9202023e5.zip |
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", <file mode>, <number of links>,
<owner name>, <group name>, <size>, <date and time>,
<pathname>
but instead of writing the <owner name> and <group name>, it writes the
numeric owner and group IDs (this avoids /etc/passwd and /etc/group
lookups as well as potential field splitting issues).
The <size> 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 <forney@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'arch/powerpc/boot')
-rwxr-xr-x | arch/powerpc/boot/wrapper | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 76fe3ccfd381..f9141eaec6ff 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -355,7 +355,7 @@ vmz="$tmpdir/`basename \"$kernel\"`.$ext" # Calculate the vmlinux.strip size ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" -strip_size=$(stat -c %s $vmz.$$) +strip_size=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$vmz.$$") if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then # recompress the image if we need to |