diff options
author | Oliver O'Halloran <oohall@gmail.com> | 2019-07-30 17:46:11 +1000 |
---|---|---|
committer | Adriana Kobylak <anoo@linux.ibm.com> | 2019-08-19 17:28:13 +0000 |
commit | d23b5b74cfadea0618e5984e8d3565d2696d26b8 (patch) | |
tree | f6770e7044b6d58bfb9c70f895ca062eed776456 | |
parent | 4d3d91262bcaf1afc2eee54145052106644410be (diff) | |
download | openpower-pnor-code-mgmt-d23b5b74cfadea0618e5984e8d3565d2696d26b8.tar.gz openpower-pnor-code-mgmt-d23b5b74cfadea0618e5984e8d3565d2696d26b8.zip |
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 <oohall@gmail.com>
Change-Id: I1baf96b4c5304a27ddedf3384cf23d2c346134d8
-rwxr-xr-x | generate-tar | 4 |
1 files 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 |