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_VMG8623-T50B/vmg8623_t50b_default_release/scripts_qca/imgAlignment.sh

32 lines
553 B
Bash
Executable File

#!/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