Re: [PATCH] kbuild: Use ls(1) instead of stat(1) to obtain file size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2018-01-28, Michael Forney <mforney@xxxxxxxxxxx> wrote:
> From: Michael Forney <forney@xxxxxxxxxx>
>
> 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.

Forgot to add

Signed-off-by: Michael Forney <forney@xxxxxxxxxx>

> ---
>  scripts/Makefile.lib    | 3 ++-
>  scripts/link-vmlinux.sh | 6 ++++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 7dee1da83e2a..24566d1c10d2 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -319,7 +319,8 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
>  size_append = printf $(shell						\
>  dec_size=0;								\
>  for F in $1; do								\
> -	fsize=$$(stat -c "%s" $$F);					\
> +	set -- $$(ls -dn $$F);						\
> +	fsize=$$5;							\
>  	dec_size=$$(expr $$dec_size + $$fsize);				\
>  done;									\
>  printf "%08x\n" $$dec_size |						\
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index c0d129d7f430..4a5737647a79 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -296,8 +296,10 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
>  	kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
>
>  	# step 3
> -	size1=$(stat -c "%s" .tmp_kallsyms1.o)
> -	size2=$(stat -c "%s" .tmp_kallsyms2.o)
> +	set -- $(ls -dn .tmp_kallsyms1.o)
> +	size1=$5
> +	set -- $(ls -dn .tmp_kallsyms2.o)
> +	size2=$5
>
>  	if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
>  		kallsymso=.tmp_kallsyms3.o
> --
> 2.15.1
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux