summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-06-14 10:00:42 +0000
committerbde <bde@FreeBSD.org>1997-06-14 10:00:42 +0000
commita47fc068b9e2cf273659b264baac4f40e2ec33ef (patch)
tree41cd12bc864a3a56ab1c7833a6400a7772d8097a
parent71e14838040aca2f17943f3d2bd02500750874bc (diff)
downloadFreeBSD-src-a47fc068b9e2cf273659b264baac4f40e2ec33ef.zip
FreeBSD-src-a47fc068b9e2cf273659b264baac4f40e2ec33ef.tar.gz
Load the kernel config file where userconfig (with option USERCONFIG_BOOT)
will see it. The name of the file is obtained by appending ".config" to the name of the kernel file. If the file doesn't exist, then an annoying message is printed. Reduced the command line buffer size yet again from 4096 to 1024. It is oversized to defend against overrun in gets(), but data space is starting to run out so the buffer size can't be as grossly oversized as before.
-rw-r--r--sys/i386/boot/biosboot/boot.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/sys/i386/boot/biosboot/boot.c b/sys/i386/boot/biosboot/boot.c
index bcf070c..0257d8e 100644
--- a/sys/i386/boot/biosboot/boot.c
+++ b/sys/i386/boot/biosboot/boot.c
@@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, [92/04/03 16:51:14 rvb]
- * $Id: boot.c,v 1.65 1997/05/27 16:26:38 bde Exp $
+ * $Id: boot.c,v 1.66 1997/06/09 05:10:55 bde Exp $
*/
@@ -60,8 +60,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define ouraddr (BOOTSEG << 4) /* XXX */
#define BOOT_CONFIG_SIZE 512
-#define BOOT_HELP_SIZE (2 * 1024)
-#define NAMEBUF_LEN (4 * 1024)
+#define BOOT_HELP_SIZE 2048
+#define KERNEL_CONFIG_SIZE 512
+#define NAMEBUF_LEN 1024 /* oversized to defend against gets() */
static char boot_config[BOOT_CONFIG_SIZE];
static char boot_help[BOOT_HELP_SIZE];
@@ -69,6 +70,8 @@ static char boot_help[BOOT_HELP_SIZE];
char *dflt_name;
#endif
char *name;
+static char kernel_config[KERNEL_CONFIG_SIZE];
+static char kernel_config_namebuf[NAMEBUF_LEN + sizeof "config"];
static char linebuf[NAMEBUF_LEN];
static char namebuf[NAMEBUF_LEN];
static struct bootinfo bootinfo;
@@ -196,6 +199,7 @@ loadprog(void)
long int bootdev;
int i;
unsigned pad;
+ char *s, *t;
read((void *)&head, sizeof(head));
if ( N_BADMAG(head)) {
@@ -311,6 +315,28 @@ loadprog(void)
bootinfo.bi_kernelname = name + ouraddr;
bootinfo.bi_nfs_diskless = NULL;
bootinfo.bi_size = sizeof(bootinfo);
+
+ /*
+ * Load the kernel config file (if any). Its name is given by
+ * appending ".config" to the kernel name. Build the name inline
+ * because no str*() functions are available. The file has to be
+ * copied to &disklabel for userconfig. It can't be loaded there
+ * directly because the label is used late in readfile() in some
+ * unusual cases, e.g., for bad144 handling.
+ */
+ s = name;
+ t = kernel_config_namebuf;
+ do
+ ;
+ while ((*t++ = *s++) != '\0');
+ s = ".config";
+ --t;
+ do
+ ;
+ while ((*t++ = *s++) != '\0');
+ readfile(kernel_config_namebuf, kernel_config, KERNEL_CONFIG_SIZE);
+ pcpy(kernel_config, (char *)&disklabel + ouraddr, KERNEL_CONFIG_SIZE);
+
printf("total=0x%x entry point=0x%x\n", (int)addr, (int)startaddr);
startprog((int)startaddr, loadflags | RB_BOOTINFO, bootdev,
(int)&bootinfo + ouraddr);
@@ -332,9 +358,6 @@ readfile(char *path, char *buf, size_t nbytes)
read(buf, nbytes);
}
buf[nbytes - 1] = '\0';
-#if 0
- pcpy(buf, (void *)0x800, nbytes);
-#endif
}
static void
OpenPOWER on IntegriCloud