diff options
author | ru <ru@FreeBSD.org> | 2002-03-28 08:23:33 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2002-03-28 08:23:33 +0000 |
commit | 702cd9122652ce1a20fc0828569cb4e292f2cd82 (patch) | |
tree | 37dfe5a542157dd602514b7ed19e6b40a81b7b23 /usr.sbin/sade | |
parent | 5a1b52129d198a637050da36428c829df8b774d0 (diff) | |
download | FreeBSD-src-702cd9122652ce1a20fc0828569cb4e292f2cd82.zip FreeBSD-src-702cd9122652ce1a20fc0828569cb4e292f2cd82.tar.gz |
Teach sysinstall(8) how to read boot managers out of /boot
instead of hardcoding them into the binary. This replaces
the work-around in usr.sbin/sysinstall/Makefile,v 1.121.
Suggested by: jhb
MFC in: 1 week
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r-- | usr.sbin/sade/Makefile | 40 | ||||
-rw-r--r-- | usr.sbin/sade/disks.c | 27 |
2 files changed, 17 insertions, 50 deletions
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile index 658c3e7..298dddc 100644 --- a/usr.sbin/sade/Makefile +++ b/usr.sbin/sade/Makefile @@ -54,46 +54,6 @@ makedevs.c: Makefile rtermcap file2c 'const char termcap_xterm[] = {' ',0};' \ >> makedevs.c -.if ${MACHINE_ARCH} == i386 -# XXX boot images aren't yet ready when "make depend" is run -.if !make(depend) -SRCS+= makeboot.c -.endif -CLEANFILES+= makeboot.c -.if exists(${.OBJDIR}/../../sys/boot/${MACHINE}/boot0/boot0) -BOOT0= ${.OBJDIR}/../../sys/boot/${MACHINE}/boot0/boot0 -.else -BOOT0= /boot/boot0 -.endif -makeboot.c: ${BOOT0} -.if ${MACHINE} == "i386" -.if exists(${.OBJDIR}/../../sys/boot/i386/mbr/mbr) -MBR= ${.OBJDIR}/../../sys/boot/i386/mbr/mbr -.else -MBR= /boot/mbr -.endif -makeboot.c: ${MBR} -.elif ${MACHINE} == "pc98" -.if exists(${.OBJDIR}/../../sys/boot/pc98/boot0.5/boot0.5) -BOOT05= ${.OBJDIR}/../../sys/boot/pc98/boot0.5/boot0.5 -.else -BOOT05= /boot/boot0.5 -.endif -makeboot.c: ${BOOT05} -.endif -makeboot.c: Makefile - echo '#include <sys/types.h>' > makeboot.c - file2c 'u_char boot0[] = {' '};' < ${BOOT0} >> makeboot.c - echo "size_t boot0_size = sizeof(boot0);" >> makeboot.c -.if ${MACHINE} == i386 - file2c 'u_char mbr[] = {' '};' < ${MBR} >> makeboot.c - echo "size_t mbr_size = sizeof(mbr);" >> makeboot.c -.elif ${MACHINE} == "pc98" - file2c 'u_char boot05[] = {' '};' < ${BOOT05} >> makeboot.c - echo "size_t boot05_size = sizeof(boot05);" >> makeboot.c -.endif -.endif - build-tools: rtermcap rtermcap: rtermcap.c diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c index 8659962..495338b 100644 --- a/usr.sbin/sade/disks.c +++ b/usr.sbin/sade/disks.c @@ -58,6 +58,7 @@ static struct chunk *chunk_info[16]; static int current_chunk; static void diskPartitionNonInteractive(Device *dev); +static u_char * bootalloc(char *name, size_t *size); static void record_chunks(Disk *d) @@ -168,10 +169,10 @@ static void getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size, u_char **bootmenu, size_t *bootmenu_size) { - extern u_char boot0[]; - extern size_t boot0_size; - extern u_char boot05[]; - extern size_t boot05_size; + static u_char *boot0; + static size_t boot0_size; + static u_char *boot05; + static size_t boot05_size; char str[80]; char *cp; @@ -192,8 +193,10 @@ getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size, if (cp || i) { switch (BootMgr) { case 0: + if (!boot0) boot0 = bootalloc("boot0", &boot0_size); *bootipl = boot0; *bootipl_size = boot0_size; + if (!boot05) boot05 = bootalloc("boot0.5", &boot05_size); *bootmenu = boot05; *bootmenu_size = boot05_size; return; @@ -212,8 +215,8 @@ static void getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize) { #ifndef __alpha__ /* only meaningful on x86 */ - extern u_char mbr[], boot0[]; - extern size_t mbr_size, boot0_size; + static u_char *mbr, *boot0; + static size_t mbr_size, boot0_size; char str[80]; char *cp; int i = 0; @@ -236,10 +239,12 @@ getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize) if (cp || i) { switch (BootMgr) { case 0: + if (!boot0) boot0 = bootalloc("boot0", &boot0_size); *bootCode = boot0; *bootCodeSize = boot0_size; return; case 1: + if (!mbr) mbr = bootalloc("mbr", &mbr_size); *bootCode = mbr; *bootCodeSize = mbr_size; return; @@ -671,7 +676,7 @@ diskPartition(Device *dev) } static u_char * -bootalloc(char *name) +bootalloc(char *name, size_t *size) { char buf[FILENAME_MAX]; struct stat sb; @@ -692,6 +697,8 @@ bootalloc(char *name) return NULL; } close(fd); + if (size != NULL) + *size = sb.st_size; return cp; } msgDebug("bootalloc: couldn't open %s\n", buf); @@ -815,11 +822,11 @@ diskPartitionWrite(dialogMenuItem *self) continue; #ifdef __alpha__ - if (!boot1) boot1 = bootalloc("boot1"); + if (!boot1) boot1 = bootalloc("boot1", NULL); Set_Boot_Blocks(d, boot1, NULL); #else - if (!boot1) boot1 = bootalloc("boot1"); - if (!boot2) boot2 = bootalloc("boot2"); + if (!boot1) boot1 = bootalloc("boot1", NULL); + if (!boot2) boot2 = bootalloc("boot2", NULL); Set_Boot_Blocks(d, boot1, boot2); #endif |