From 58c82e4fb72e2476c725d8a61617afc437dc5663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 30 Sep 2013 04:38:50 +0200 Subject: [PATCH] Make sure the boot driver tgz doesn't overflow the boot floppy At least on 68k it does. Seems to be ok on x86, for now... --- build/jam/ImageRules | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/jam/ImageRules b/build/jam/ImageRules index 9589468d71..28c5f7f6fc 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -1506,17 +1506,26 @@ rule BuildFloppyBootImage image : haikuLoader : archive actions BuildFloppyBootImage1 { haiku_loader_size=`stat -c %s "$(>[1])"` + drivers_tgz_size=`stat -c %s "$(>[2])"` if [ $? -ne 0 ] ; then # FreeBSD's stat command don't support -c/--format option # and use %z specifier for file size haiku_loader_size=`stat -f %z "$(>[1])"` + drivers_tgz_size=`stat -f %z "$(>[2])"` fi archive_image_offset=`echo "$(ARCHIVE_IMAGE_OFFSET) * 1024" | bc` + floppy_tgz_size=\ + `echo "($(FLOPPY_IMAGE_SIZE) - $(ARCHIVE_IMAGE_OFFSET)) * 1024" | bc` if [ $haiku_loader_size -gt $archive_image_offset ] ; then echo "Error: $(>[1]) is too big ($haiku_loader_size) to fit " echo " before the boot archive starting at $archive_image_offset!" exit 1 fi + if [ $drivers_tgz_size -gt $floppy_tgz_size ] ; then + echo "Error: $(>[2]) is too big ($drivers_tgz_size) to fit " + echo " in the boot floppy ($floppy_tgz_size)!" + exit 1 + fi $(RM) $(<) # make an empty image dd if=/dev/zero of=$(<) bs=1k count=$(FLOPPY_IMAGE_SIZE)