On 15.06.2011 20:20, Eir Nym wrote:
>  > The fundamental question we need to answer is this:
>  > Is the serial number a well-defined field in the MBR that is
>  > independent and unrelated to the bootcode, or not?
>  
>  Yes, this field is defined in several documentation sources.
>  It has 6 bytes and used Windows OS as disk identifier in registry to
>  specify mount point.

As i found this field is 4 bytes only. Next 2 bytes are used by our
boot0 boot manager to keep ticks count. Can you test attached patch,
does it fix your problem?

-- 
WBR, Andrey V. Elsukov
Index: head/sys/geom/part/g_part_mbr.c
===================================================================
--- head/sys/geom/part/g_part_mbr.c     (revision 223150)
+++ head/sys/geom/part/g_part_mbr.c     (working copy)
@@ -237,14 +237,16 @@ static int
 g_part_mbr_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp)
 {
        struct g_part_mbr_table *table;
-       size_t codesz;
+       const u_char *codeptr;
 
-       codesz = DOSPARTOFF;
+       if (gpp->gpp_codesize != MBRSIZE)
+               return (ENODEV);
+
        table = (struct g_part_mbr_table *)basetable;
-       bzero(table->mbr, codesz);
-       codesz = MIN(codesz,  gpp->gpp_codesize);
-       if (codesz > 0)
-               bcopy(gpp->gpp_codeptr, table->mbr, codesz);
+       codeptr = gpp->gpp_codeptr;
+       bcopy(codeptr, table->mbr, DOSDSNOFF);
+       table->mbr[DOSDSNOFF + 4] = codeptr[DOSDSNOFF + 4];
+       table->mbr[DOSDSNOFF + 5] = codeptr[DOSDSNOFF + 5];
        return (0);
 }
 
Index: head/sys/sys/diskmbr.h
===================================================================
--- head/sys/sys/diskmbr.h      (revision 223150)
+++ head/sys/sys/diskmbr.h      (working copy)
@@ -36,6 +36,7 @@
 #include <sys/ioccom.h>
 
 #define        DOSBBSECTOR     0       /* DOS boot block relative sector 
number */
+#define        DOSDSNOFF       440     /* WinNT/2K/XP Drive Serial Number 
offset */
 #define        DOSPARTOFF      446
 #define        DOSPARTSIZE     16
 #define        NDOSPART        4

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to