From d23b5b74cfadea0618e5984e8d3565d2696d26b8 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Tue, 30 Jul 2019 17:46:11 +1000 Subject: Use wc to calculate file sizes Milton pointed out that for the du command the -b and -k options aren't really compatible. From the man page: -b, --bytes equivalent to '--apparent-size --block-size=1' -k like --block-size=1K As a result 'du -bk' will act as if the following args were used: --apparent-size --block-size=1K However, it's probably not safe to assume this. Fix this by replacing the use of du with "wc -c". POSIX requires that wc -c prints size of each input file in bytes so it should be safe (and portable). Fixes: adf91f58dac9 ("Fix generate-tar on ppc64 hosts") Signed-off-by: Oliver O'Halloran Change-Id: I1baf96b4c5304a27ddedf3384cf23d2c346134d8 --- generate-tar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate-tar b/generate-tar index 87046da50..feebe8967 100755 --- a/generate-tar +++ b/generate-tar @@ -152,12 +152,12 @@ mkdir ${pnor_dir} pflash --partition=part --read=${pnor_dir}/part -F ${pnorfile} pflash --partition=VERSION --read=${pnor_dir}/VERSION -F ${pnorfile} -version_size=$(du -bk ${pnor_dir}/VERSION | head -1 | cut -f 1) +version_size=$(wc -c ${pnor_dir}/VERSION | cut -d' ' -f 1) magic_number=$(xxd -p -l 4 ${pnor_dir}/VERSION) # Check if VERSION is signed. A signed version partition will have an extra # 4K header starting with the magic number 0x17082011, see: # https://github.com/open-power/skiboot/blob/master/libstb/container.h#L47 -if [ "$version_size" == "8" -a "$magic_number" == "17082011" ]; then +if [ "$version_size" == "8192" -a "$magic_number" == "17082011" ]; then # Advance past the STB header (4K, indexed from 1) cp ${pnor_dir}/VERSION ${pnor_dir}/VERSION_FULL tail --bytes=+4097 ${pnor_dir}/VERSION_FULL > ${pnor_dir}/VERSION -- cgit v1.2.1