1
0
This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
ZyXEL_PMG5617GA/scripts/imgAlignment.sh
2022-11-27 10:16:14 +00:00

32 lines
553 B
Bash

#!/bin/sh
help()
{
echo "Usage imgAlignment <file> <align>"
}
if [ $# -lt 2 ]; then
help
exit -1
fi
if [ ! -e $1 ]; then
echo "\"$1\" not found!\n"
exit -2
fi
OrigFileSize=`stat -c %s $1`
if [ $(($OrigFileSize & ($2 - 1))) == 0 ]; then
ExpectSize=$OrigFileSize
else
ExpectSize=$((($OrigFileSize | ($2 - 1)) + 1))
fi
PaddingSize=$(($ExpectSize - $OrigFileSize))
echo "OrigFileSize=$OrigFileSize ExpectSize=$ExpectSize PadSize=$PaddingSize"
if [ $PaddingSize -gt 0 ]; then
dd if=/dev/zero bs=$PaddingSize count=1 | tr '\000' '\377' >>$1
fi