svn commit: r234562 - stable/9/sys/boot/pc98/boot2

Takahashi Yoshihiro nyan at FreeBSD.org
Sun Apr 22 03:53:12 UTC 2012


Author: nyan
Date: Sun Apr 22 03:53:11 2012
New Revision: 234562
URL: http://svn.freebsd.org/changeset/base/234562

Log:
  MFC: revision 232784
  
    MFi386: revisions 232570 and 232754
  
    Fix boot2 to handle boot config files that only contain a custom path to
    a loader or kernel.

Modified:
  stable/9/sys/boot/pc98/boot2/boot2.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/boot/   (props changed)

Modified: stable/9/sys/boot/pc98/boot2/boot2.c
==============================================================================
--- stable/9/sys/boot/pc98/boot2/boot2.c	Sun Apr 22 00:58:04 2012	(r234561)
+++ stable/9/sys/boot/pc98/boot2/boot2.c	Sun Apr 22 03:53:11 2012	(r234562)
@@ -130,9 +130,9 @@ static struct dsk {
     unsigned part;
     unsigned start;
 } dsk;
-static char cmd[512], cmddup[512];
+static char cmd[512], cmddup[512], knamebuf[1024];
 static const char *kname = NULL;
-static uint32_t opts;
+static uint32_t opts = 0;
 static int comspeed = SIOSPD;
 static struct bootinfo bootinfo;
 static uint8_t ioctrl = IO_KEYBOARD;
@@ -352,6 +352,7 @@ main(void)
 #endif
     uint8_t autoboot;
     ino_t ino;
+    size_t nbyte;
 
     dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
     v86.ctl = V86_FLAGS;
@@ -378,8 +379,10 @@ main(void)
     autoboot = 1;
 
     if ((ino = lookup(PATH_CONFIG)) ||
-        (ino = lookup(PATH_DOTCONFIG)))
-	fsread(ino, cmd, sizeof(cmd));
+        (ino = lookup(PATH_DOTCONFIG))) {
+	nbyte = fsread(ino, cmd, sizeof(cmd) - 1);
+	cmd[nbyte] = '\0';
+    }
 
     if (*cmd) {
 	memcpy(cmddup, cmd, sizeof(cmd));
@@ -396,9 +399,9 @@ main(void)
      * or in case of failure, try to load a kernel directly instead.
      */
 
-    if (autoboot && !kname) {
+    if (!kname) {
 	kname = PATH_BOOT3;
-	if (!keyhit(3*SECOND)) {
+	if (autoboot && !keyhit(3*SECOND)) {
 	    load();
 	    kname = PATH_KERNEL;
 	}
@@ -595,7 +598,12 @@ parse()
 		dsk.daua = dsk.disk | dsk.unit;
 		dsk_meta = 0;
 	    }
-            kname = arg;
+	    if ((i = ep - arg)) {
+		if ((size_t)i >= sizeof(knamebuf))
+		    return -1;
+		memcpy(knamebuf, arg, i + 1);
+		kname = knamebuf;
+	    }
 	}
 	arg = p;
     }


More information about the svn-src-stable-9 mailing list