Source-Changes-HG archive

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

[src/trunk]: src/distrib/utils/mksunbootcd Don't blindly write block 0 -- try...



details:   https://anonhg.NetBSD.org/src/rev/845089a2b57d
branches:  trunk
changeset: 499801:845089a2b57d
user:      tv <tv%NetBSD.org@localhost>
date:      Wed Nov 29 19:47:31 2000 +0000

description:
Don't blindly write block 0 -- try reading it in, zero only the Sun label
section, and then write it back.  This allows other boot installers to work
*before* running mksunbootcd (saving space from rounding in some cases).

diffstat:

 distrib/utils/mksunbootcd/mksunbootcd.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r 5dc36f539af9 -r 845089a2b57d distrib/utils/mksunbootcd/mksunbootcd.c
--- a/distrib/utils/mksunbootcd/mksunbootcd.c   Wed Nov 29 18:22:17 2000 +0000
+++ b/distrib/utils/mksunbootcd/mksunbootcd.c   Wed Nov 29 19:47:31 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mksunbootcd.c,v 1.5 1999/05/13 12:55:37 ross Exp $     */
+/*     $NetBSD: mksunbootcd.c,v 1.6 2000/11/29 19:47:31 tv Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -49,10 +49,11 @@
 
 #include <err.h>
 #include <fcntl.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
-#include <string.h>
 
 /*
  * How we work:
@@ -170,6 +171,14 @@
 
        /* initialize label template */
        (void)memset(&sdl, 0, sizeof(sdl));
+
+       if (read(pfd[0], &sdl, sizeof(sdl)) < 0)
+               err(2, "reading block 0 of CD image");
+
+       /* clear sun boot info segment */
+       (void)memset(((char *)&sdl) + offsetof(struct sun_disklabel, sl_rpm),
+                    0, sizeof(sdl) - offsetof(struct sun_disklabel, sl_rpm));
+
        sdl.sl_magic = htons(SUN_DKMAGIC);
        sdl.sl_rpm = htons(300);
        sdl.sl_nsectors = htons(cylsz);



Home | Main Index | Thread Index | Old Index