Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst/arch MBR magic exists at the beginning...



details:   https://anonhg.NetBSD.org/src/rev/c17f83e33111
branches:  trunk
changeset: 765938:c17f83e33111
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Sat Jun 11 11:43:23 2011 +0000

description:
MBR magic exists at the beginning of 'a' partition, BPB is cleared.
Avoid to detect msdosfs incorrectly at boot time.

diffstat:

 distrib/utils/sysinst/arch/hpcarm/md.c |  34 +++++++++++++++++++++++++++++++++-
 distrib/utils/sysinst/arch/zaurus/md.c |  34 +++++++++++++++++++++++++++++++++-
 2 files changed, 66 insertions(+), 2 deletions(-)

diffs (96 lines):

diff -r 619600bf2d16 -r c17f83e33111 distrib/utils/sysinst/arch/hpcarm/md.c
--- a/distrib/utils/sysinst/arch/hpcarm/md.c    Sat Jun 11 03:00:19 2011 +0000
+++ b/distrib/utils/sysinst/arch/hpcarm/md.c    Sat Jun 11 11:43:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.10 2011/04/04 08:30:29 mbalmer Exp $ */
+/*     $NetBSD: md.c,v 1.11 2011/06/11 11:43:23 nonaka Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -148,6 +148,38 @@
 int
 md_post_newfs(void)
 {
+       struct mbr_sector pbr;
+       char adevname[STRSIZE];
+       ssize_t sz;
+       int fd = -1;
+
+       snprintf(adevname, sizeof(adevname), "/dev/r%sa", diskdev);
+       fd = open(adevname, O_RDWR);
+       if (fd < 0)
+               goto out;
+
+       /* Read partition boot record */
+       sz = pread(fd, &pbr, sizeof(pbr), 0);
+       if (sz != sizeof(pbr))
+               goto out;
+
+       /* Check magic number */
+       if (pbr.mbr_magic != le16toh(MBR_MAGIC))
+               goto out;
+
+#define        OSNAME  "NetBSD60"
+       /* Update oemname */
+       memcpy(&pbr.mbr_oemname, OSNAME, sizeof(OSNAME) - 1);
+
+       /* Clear BPB */
+       memset(&pbr.mbr_bpb, 0, sizeof(pbr.mbr_bpb));
+
+       /* write-backed new patition boot record */
+       (void)pwrite(fd, &pbr, sizeof(pbr), 0);
+
+out:
+       if (fd >= 0)
+               close(fd);
        return 0;
 }
 
diff -r 619600bf2d16 -r c17f83e33111 distrib/utils/sysinst/arch/zaurus/md.c
--- a/distrib/utils/sysinst/arch/zaurus/md.c    Sat Jun 11 03:00:19 2011 +0000
+++ b/distrib/utils/sysinst/arch/zaurus/md.c    Sat Jun 11 11:43:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.7 2011/04/04 08:30:46 mbalmer Exp $   */
+/*     $NetBSD: md.c,v 1.8 2011/06/11 11:43:23 nonaka Exp $    */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -111,6 +111,38 @@
 int
 md_post_newfs(void)
 {
+       struct mbr_sector pbr;
+       char adevname[STRSIZE];
+       ssize_t sz;
+       int fd = -1;
+
+       snprintf(adevname, sizeof(adevname), "/dev/r%sa", diskdev);
+       fd = open(adevname, O_RDWR);
+       if (fd < 0)
+               goto out;
+
+       /* Read partition boot record */
+       sz = pread(fd, &pbr, sizeof(pbr), 0);
+       if (sz != sizeof(pbr))
+               goto out;
+
+       /* Check magic number */
+       if (pbr.mbr_magic != le16toh(MBR_MAGIC))
+               goto out;
+
+#define        OSNAME  "NetBSD60"
+       /* Update oemname */
+       memcpy(&pbr.mbr_oemname, OSNAME, sizeof(OSNAME) - 1);
+
+       /* Clear BPB */
+       memset(&pbr.mbr_bpb, 0, sizeof(pbr.mbr_bpb));
+
+       /* write-backed new patition boot record */
+       (void)pwrite(fd, &pbr, sizeof(pbr), 0);
+
+out:
+       if (fd >= 0)
+               close(fd);
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index