Re: enhancing i386 mbr.S

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Giuseppe Magnotta
Date: Saturday, February 20, 2010 - 1:33 pm

Ted Unangst wrote:

Hi Ted.

In the (strange) case you have many bootable partition do you think is
safe to boot in the first active one?

If your answer is yes, please find attached a new patch that in case
there are many bootable partition then print on screen "Corrupted
partition table" and boots the first bootable partition it find
otherwise if there are no bootable partition will print the same error
and block (as original code did).

What do you think about this?

Regards,

Giuseppe
? diff
? mbr
Index: mbr.S
===================================================================
RCS file: /cvs/src/sys/arch/i386/stand/mbr/mbr.S,v
retrieving revision 1.21
diff -u -r1.21 mbr.S
--- mbr.S	25 Jun 2007 14:10:17 -0000	1.21
+++ mbr.S	20 Feb 2010 20:27:26 -0000
@@ -3,6 +3,7 @@
 /*
  * Copyright (c) 1997 Michael Shalayeff and Tobias Weingartner
  * Copyright (c) 2003 Tom Cosgrove <tom.cosgrove@arches-consulting.com>
+ * Copyright (c) 2010 Giuseppe Magnotta <giuseppe.magnotta@gmail.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -223,13 +224,25 @@
 	movb	$0x80, %dl
 
 drive_ok:
-	/* Find the first active partition.
-	 * Note: this should be the only active partition.  We currently
-	 * don't check for that.
-	 */
+	/* Find first and check for only active partition. */
 	movw	$pt, %si
 
 	movw	$NDOSPART, %cx
+	xorw	%ax, %ax
+	xorw	%bx, %bx
+
+test_pt:
+	movb	(%si), %al
+	addw	%ax, %bx
+	addw	$PARTSZ, %si
+	loop	test_pt
+
+	cmpw	$0x0, %bx
+	je	no_part
+
+	cmpw	$DOSACTIVE, %bx
+	jg	more_part
+
 find_active:
 	DBGMSG(CHAR_L)
 	movb	(%si), %al
@@ -253,6 +266,16 @@
 	/* Just to make sure */
 	jmp	stay_stopped
 
+more_part:
+	movw	$enoboot, %si
+
+	call	Lmessage
+
+	movw	$pt, %si
+	movw	$NDOSPART, %cx
+
+	jmp	find_active
+
 found:
 	/*
 	 * Found bootable partition
@@ -533,7 +556,7 @@
 efdmbr:	.asciz		"MBR on floppy or old BIOS\r\n"
 eread:	.asciz		"\r\nRead error\r\n"
 enoos:	.asciz		"No O/S\r\n"
-enoboot: .ascii		"No active partition"	/* runs into crlf... */
+enoboot: .ascii		"Corrupted partition table" /* runs into crlf... */
 crlf:	.asciz		"\r\n"
 
 endofcode:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
enhancing i386 mbr.S, Giuseppe Magnotta, (Sat Feb 20, 6:29 am)
Re: enhancing i386 mbr.S, Han Boetes, (Sat Feb 20, 7:54 am)
Re: enhancing i386 mbr.S, Giuseppe Magnotta, (Sat Feb 20, 8:42 am)
Re: enhancing i386 mbr.S , Tobias Weingartner, (Sat Feb 20, 12:00 pm)
Re: enhancing i386 mbr.S , Tobias Weingartner, (Sat Feb 20, 12:08 pm)
Re: enhancing i386 mbr.S, Giuseppe Magnotta, (Sat Feb 20, 12:25 pm)
Re: enhancing i386 mbr.S, Ted Unangst, (Sat Feb 20, 12:36 pm)
Re: enhancing i386 mbr.S , Tobias Weingartner, (Sat Feb 20, 1:03 pm)
Re: enhancing i386 mbr.S, Giuseppe Magnotta, (Sat Feb 20, 1:33 pm)
Re: enhancing i386 mbr.S, Miod Vallat, (Sat Feb 20, 1:41 pm)
Re: enhancing i386 mbr.S , Tobias Weingartner, (Sat Feb 20, 1:49 pm)
Re: enhancing i386 mbr.S, Kenneth R Westerback, (Sat Feb 20, 6:01 pm)
Re: enhancing i386 mbr.S , Tobias Weingartner, (Sat Feb 20, 6:44 pm)
Re: enhancing i386 mbr.S, Kenneth R Westerback, (Sat Feb 20, 7:04 pm)
Re: enhancing i386 mbr.S, Ted Unangst, (Sat Feb 20, 7:18 pm)
Re: enhancing i386 mbr.S, Giuseppe Magnotta, (Sun Feb 21, 4:57 am)
Re: enhancing i386 mbr.S, Denis Doroshenko, (Sun Feb 21, 4:46 pm)