Add safety belt for boot1.efi file size
Reviewed by: smh Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4833
This commit is contained in:
parent
048738b546
commit
8f2318bdcc
@ -79,8 +79,15 @@ boot1.o: ${.CURDIR}/../../common/ufsread.c
|
||||
# created by generate-fat.sh
|
||||
|
||||
.include "${.CURDIR}/Makefile.fat"
|
||||
BOOT1_MAXSIZE?= 131072
|
||||
|
||||
boot1.efifat: boot1.efi
|
||||
@set -- `ls -l boot1.efi`; \
|
||||
x=$$(($$5-${BOOT1_MAXSIZE})); \
|
||||
if [ $$x -ge 0 ]; then \
|
||||
echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
|
||||
exit 1; \
|
||||
fi
|
||||
echo ${.OBJDIR}
|
||||
uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu
|
||||
mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2
|
||||
|
@ -55,9 +55,20 @@ BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ')
|
||||
# Convert to number of blocks
|
||||
BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}')
|
||||
|
||||
# Record maximum boot1 size in bytes
|
||||
case $BOOT1_SIZE in
|
||||
*k)
|
||||
BOOT1_MAXSIZE=$(expr ${BOOT1_SIZE%k} '*' 1024)
|
||||
;;
|
||||
*)
|
||||
BOOT1_MAXSIZE=$BOOT1_SIZE
|
||||
;;
|
||||
esac
|
||||
|
||||
echo '# This file autogenerated by generate-fat.sh - DO NOT EDIT' > Makefile.fat
|
||||
echo '# $FreeBSD$' >> Makefile.fat
|
||||
echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.fat
|
||||
echo "BOOT1_MAXSIZE=$BOOT1_MAXSIZE" >> Makefile.fat
|
||||
|
||||
bzip2 $OUTPUT_FILE
|
||||
echo 'FAT template boot filesystem created by generate-fat.sh' > $OUTPUT_FILE.bz2.uu
|
||||
|
Loading…
x
Reference in New Issue
Block a user