From 7d7a4ae1a7137b51785582937f5f071d21e5731a Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Fri, 1 Jul 2011 18:31:59 +0000 Subject: [PATCH] Fix r223695 to compile on architectures which don't use the MBR scheme; wrap the MBR support in the common part of the loader in #ifdef's and enable it only for userboot for now. --- sys/boot/common/disk.c | 21 ++++++++++++++++----- sys/boot/userboot/userboot/Makefile | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/boot/common/disk.c b/sys/boot/common/disk.c index 40dbc8abceea..e1de3821d02a 100644 --- a/sys/boot/common/disk.c +++ b/sys/boot/common/disk.c @@ -93,6 +93,8 @@ static uuid_t ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; #endif +#if defined(LOADER_GPT_SUPPORT) || defined(LOADER_MBR_SUPPORT) + /* Given a size in 512 byte sectors, convert it to a human-readable number. */ static char * display_size(uint64_t size) @@ -116,6 +118,10 @@ display_size(uint64_t size) return (buf); } +#endif + +#ifdef LOADER_MBR_SUPPORT + static void disk_checkextended(struct disk_devdesc *dev, struct dos_partition *slicetab, int slicenum, int *nslicesp) @@ -469,7 +475,7 @@ disk_printslice(struct disk_devdesc *dev, int slice, pager_output(line); } -int +static int disk_printmbr(struct disk_devdesc *dev, char *prefix, int verbose) { struct dos_partition *slicetab; @@ -488,6 +494,8 @@ disk_printmbr(struct disk_devdesc *dev, char *prefix, int verbose) return (0); } +#endif + #ifdef LOADER_GPT_SUPPORT static int @@ -630,7 +638,7 @@ disk_bestgpt(struct gpt_part *gpt, int ngpt) return (prefpart); } -int +static int disk_opengpt(struct disk_devdesc *dev) { struct gpt_part *gpt = NULL, *gp; @@ -759,6 +767,7 @@ disk_open(struct disk_devdesc *dev) { int rc; + rc = 0; /* * While we are reading disk metadata, make sure we do it relative * to the start of the disk @@ -769,7 +778,9 @@ disk_open(struct disk_devdesc *dev) rc = disk_opengpt(dev); if (rc) #endif +#ifdef LOADER_MBR_SUPPORT rc = disk_openmbr(dev); +#endif return (rc); } @@ -777,12 +788,12 @@ disk_open(struct disk_devdesc *dev) void disk_print(struct disk_devdesc *dev, char *prefix, int verbose) { - int rc; #ifdef LOADER_GPT_SUPPORT - rc = disk_printgpt(dev, prefix, verbose); - if (rc == 0) + if (disk_printgpt(dev, prefix, verbose) == 0) return; #endif +#ifdef LOADER_MBR_SUPPORT disk_printmbr(dev, prefix, verbose); +#endif } diff --git a/sys/boot/userboot/userboot/Makefile b/sys/boot/userboot/userboot/Makefile index 7271fa7e4726..28ddc129f99c 100644 --- a/sys/boot/userboot/userboot/Makefile +++ b/sys/boot/userboot/userboot/Makefile @@ -32,7 +32,7 @@ CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I${.CURDIR}/../../.. CFLAGS+= -I${.CURDIR}/../../../../lib/libstand CFLAGS+= -ffreestanding -I. -CFLAGS+= -DLOADER_GPT_SUPPORT +CFLAGS+= -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT LDFLAGS+= -nostdlib -Wl,-Bsymbolic