Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/installboot user visible stuff:



details:   https://anonhg.NetBSD.org/src/rev/7b5ac15f77ce
branches:  trunk
changeset: 526928:7b5ac15f77ce
user:      lukem <lukem%NetBSD.org@localhost>
date:      Tue May 14 06:18:50 2002 +0000

description:
user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
  intended for use on platforms where the blocks of the stage2 bootstrap
  are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
  at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
  provided secondary bootstrap (as an actual file, not as part of the
  `filesystem' argument) to provide a sequential list of blocks from s2bno,
  each block being the appropriate file system size (from
  params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
  (8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
  support for ffs_findstage2()
- improve some comments, add some prototypes, ...

diffstat:

 usr.sbin/installboot/arch/alpha.c   |  23 +++++++++---
 usr.sbin/installboot/arch/pmax.c    |  23 +++++++++---
 usr.sbin/installboot/arch/sparc.c   |  67 +++++++++++++++++++++++-------------
 usr.sbin/installboot/arch/sparc64.c |  38 +++++++++++---------
 usr.sbin/installboot/arch/sun68k.c  |  47 +++++++++++++++----------
 usr.sbin/installboot/arch/vax.c     |  23 +++++++++---
 usr.sbin/installboot/ffs.c          |  63 +++++++++++++++++++--------------
 usr.sbin/installboot/fstypes.c      |  67 ++++++++++++++++++++++++++++++++++--
 usr.sbin/installboot/installboot.8  |  48 ++++++++++++++++++++------
 usr.sbin/installboot/installboot.c  |  23 +++++++++---
 usr.sbin/installboot/installboot.h  |  29 +++++++++------
 11 files changed, 313 insertions(+), 138 deletions(-)

diffs (truncated from 1081 to 300 lines):

diff -r f23770371a08 -r 7b5ac15f77ce usr.sbin/installboot/arch/alpha.c
--- a/usr.sbin/installboot/arch/alpha.c Tue May 14 05:31:11 2002 +0000
+++ b/usr.sbin/installboot/arch/alpha.c Tue May 14 06:18:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alpha.c,v 1.8 2002/04/30 14:24:33 lukem Exp $  */
+/*     $NetBSD: alpha.c,v 1.9 2002/05/14 06:18:52 lukem Exp $  */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: alpha.c,v 1.8 2002/04/30 14:24:33 lukem Exp $");
+__RCSID("$NetBSD: alpha.c,v 1.9 2002/05/14 06:18:52 lukem Exp $");
 #endif /* !__lint */
 
 #if HAVE_CONFIG_H
@@ -157,10 +157,16 @@
        assert(params->filesystem != NULL);
        assert(sizeof(struct alpha_boot_block) == ALPHA_BOOT_BLOCK_BLOCKSIZE);
 
-       if (params->flags & (IB_STARTBLOCK | IB_APPEND)) {
+       if (params->flags & (IB_STAGE1START | IB_APPEND)) {
                warnx("Can't use `-b bno' or `-o append' with `-c'");
                return (0);
        }
+       if (params->flags & IB_STAGE2START) {
+               warnx("`-B bno' is not supported for %s",
+                   params->machine->name);
+               return (0);
+       }
+
        rv = pread(params->fsfd, &bb, sizeof(bb), ALPHA_BOOT_BLOCK_OFFSET);
        if (rv == -1) {
                warn("Reading `%s'", params->filesystem);
@@ -240,11 +246,16 @@
        retval = 0;
        bootstrapbuf = NULL;
 
-       if ((params->flags & IB_STARTBLOCK) &&
+       if ((params->flags & IB_STAGE1START) &&
            (params->flags & IB_APPEND)) {
                warnx("Can't use `-b bno' with `-o append'");
                goto done;
        }
+       if (params->flags & IB_STAGE2START) {
+               warnx("`-B bno' is not supported for %s",
+                   params->machine->name);
+               goto done;
+       }
 
        if (fstat(params->s1fd, &bootstrapsb) == -1) {
                warn("Examining `%s'", params->stage1);
@@ -307,8 +318,8 @@
                }
                startblock = howmany(filesyssb.st_size,
                    ALPHA_BOOT_BLOCK_BLOCKSIZE);
-       } else if (params->flags & IB_STARTBLOCK) {
-               startblock = params->startblock;
+       } else if (params->flags & IB_STAGE1START) {
+               startblock = params->s1start;
        } else {
                startblock = ALPHA_BOOT_BLOCK_OFFSET /
                    ALPHA_BOOT_BLOCK_BLOCKSIZE + 1;
diff -r f23770371a08 -r 7b5ac15f77ce usr.sbin/installboot/arch/pmax.c
--- a/usr.sbin/installboot/arch/pmax.c  Tue May 14 05:31:11 2002 +0000
+++ b/usr.sbin/installboot/arch/pmax.c  Tue May 14 06:18:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmax.c,v 1.6 2002/04/30 14:24:33 lukem Exp $   */
+/*     $NetBSD: pmax.c,v 1.7 2002/05/14 06:18:52 lukem Exp $   */
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: pmax.c,v 1.6 2002/04/30 14:24:33 lukem Exp $");
+__RCSID("$NetBSD: pmax.c,v 1.7 2002/05/14 06:18:52 lukem Exp $");
 #endif /* !__lint */
 
 #if HAVE_CONFIG_H
@@ -154,10 +154,16 @@
        assert(params->filesystem != NULL);
        assert(sizeof(struct pmax_boot_block) == PMAX_BOOT_BLOCK_BLOCKSIZE);
 
-       if (params->flags & (IB_STARTBLOCK | IB_APPEND)) {
+       if (params->flags & (IB_STAGE1START | IB_APPEND)) {
                warnx("Can't use `-b bno' or `-o append' with `-c'");
                return (0);
        }
+       if (params->flags & IB_STAGE2START) {
+               warnx("`-B bno' is not supported for %s",
+                   params->machine->name);
+               return (0);
+       }
+
        rv = pread(params->fsfd, &bb, sizeof(bb), PMAX_BOOT_BLOCK_OFFSET);
        if (rv == -1) {
                warn("Reading `%s'", params->filesystem);
@@ -224,11 +230,16 @@
        retval = 0;
        bootstrapbuf = NULL;
 
-       if ((params->flags & IB_STARTBLOCK) &&
+       if ((params->flags & IB_STAGE1START) &&
            (params->flags & IB_APPEND)) {
                warnx("Can't use `-b bno' with `-o append'");
                goto done;
        }
+       if (params->flags & IB_STAGE2START) {
+               warnx("`-B bno' is not supported for %s",
+                   params->machine->name);
+               goto done;
+       }
 
        if (fstat(params->s1fd, &bootstrapsb) == -1) {
                warn("Examining `%s'", params->stage1);
@@ -267,8 +278,8 @@
                }
                startblock = howmany(filesyssb.st_size,
                    PMAX_BOOT_BLOCK_BLOCKSIZE);
-       } else if (params->flags & IB_STARTBLOCK) {
-               startblock = params->startblock;
+       } else if (params->flags & IB_STAGE1START) {
+               startblock = params->s1start;
        } else {
                startblock = PMAX_BOOT_BLOCK_OFFSET / PMAX_BOOT_BLOCK_BLOCKSIZE
                    + 1;
diff -r f23770371a08 -r 7b5ac15f77ce usr.sbin/installboot/arch/sparc.c
--- a/usr.sbin/installboot/arch/sparc.c Tue May 14 05:31:11 2002 +0000
+++ b/usr.sbin/installboot/arch/sparc.c Tue May 14 06:18:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sparc.c,v 1.1 2002/05/06 16:24:46 pk Exp $ */
+/*     $NetBSD: sparc.c,v 1.2 2002/05/14 06:18:52 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: sparc.c,v 1.1 2002/05/06 16:24:46 pk Exp $");
+__RCSID("$NetBSD: sparc.c,v 1.2 2002/05/14 06:18:52 lukem Exp $");
 #endif /* !__lint */
 
 #if HAVE_CONFIG_H
@@ -74,8 +74,13 @@
        assert(params->fsfd != -1);
        assert(params->filesystem != NULL);
 
-       if (params->flags & IB_STARTBLOCK) {
-               warnx("Can't use `-b bno' with `-c'");
+       if (params->flags & IB_STAGE2START) {
+               warnx("Can't use `-B bno' with `-c'");
+               return (0);
+       }
+       if (params->flags & IB_STAGE1START) {
+               warnx("`-b bno' is not supported for %s",
+                   params->machine->name);
                return (0);
        }
 
@@ -113,15 +118,14 @@
 int
 sparc_setboot(ib_params *params)
 {
-       struct stat     bootstrapsb;
+       struct stat     filesystemsb, bootstrapsb;
        char            bb[SPARC_BOOT_BLOCK_MAX_SIZE];
-       uint32_t        startblock;
        int             retval;
        ssize_t         rv;
        size_t          bbi;
        struct sparc_bbinfo     *bbinfop;       /* bbinfo in prototype image */
        uint32_t        maxblk, nblk, blk_i;
-       ib_block        *blocks = NULL;
+       ib_block        *blocks;
 
        assert(params != NULL);
        assert(params->fsfd != -1);
@@ -131,13 +135,25 @@
        assert(params->stage1 != NULL);
        assert(SPARC_BBINFO_MAGICSIZE == 32);
 
+#define        SPARC_AOUT_OFFSET       32
+
+       retval = 0;
+       blocks = NULL;
+
        if (params->stage2 == NULL) {
                warnx("You must provide the name of the secondary bootstrap");
-               return (0);
+               goto done;
+       }
+       if (params->flags & IB_STAGE1START) {
+               warnx("`-b bno' is not supported for %s",
+                   params->machine->name);
+               goto done;
        }
 
-       retval = 0;
-
+       if (fstat(params->fsfd, &filesystemsb) == -1) {
+               warn("Examining `%s'", params->filesystem);
+               goto done;
+       }
        if (fstat(params->s1fd, &bootstrapsb) == -1) {
                warn("Examining `%s'", params->stage1);
                goto done;
@@ -157,7 +173,8 @@
         * Leave room for a 32-byte a.out header.
         */
        memset(&bb, 0, sizeof(bb));
-       rv = read(params->s1fd, bb + 32, sizeof(bb) - 32);
+       rv = read(params->s1fd, bb + SPARC_AOUT_OFFSET,
+           sizeof(bb) - SPARC_AOUT_OFFSET);
        if (rv == -1) {
                warn("Reading `%s'", params->stage1);
                goto done;
@@ -167,7 +184,7 @@
         * Quick sanity check that the bootstrap given
         * is *not* an ELF executable.
         */
-       if (memcmp(bb + 32 + 1, "ELF", strlen("ELF")) == 0) {
+       if (memcmp(bb + SPARC_AOUT_OFFSET + 1, "ELF", strlen("ELF")) == 0) {
                warnx("`%s' is an ELF executable; need raw binary", 
                    params->stage1);
                goto done;
@@ -200,8 +217,14 @@
                goto done;
        }
 
-       /* Make sure the (probably new) secondary bootstrap is on disk. */
-       sync(); sleep(1); sync();
+       if (S_ISREG(filesystemsb.st_mode)) {
+               if (fsync(params->fsfd) == -1)
+                       warn("Synchronising file system `%s'",
+                           params->filesystem);
+       } else {
+               /* Ensure the secondary bootstrap is on disk. */
+               sync();
+       }
 
        /* Collect the blocks for the secondary bootstrap. */
        nblk = maxblk;
@@ -243,17 +266,12 @@
        *((uint32_t *)bb) = htobe32(SUN_MAGIC);
        *((uint32_t *)bb + 1) = htobe32(SUN4_BASTART);
 
-       if (params->flags & IB_STARTBLOCK)
-               startblock = params->startblock;
-       else
-               startblock =
-                       SPARC_BOOT_BLOCK_OFFSET / SPARC_BOOT_BLOCK_BLOCKSIZE;
-
        if (params->flags & IB_VERBOSE) {
-               printf("Bootstrap start sector: %u\n", startblock);
+               printf("Bootstrap start sector: %u\n",
+                   SPARC_BOOT_BLOCK_OFFSET / SPARC_BOOT_BLOCK_BLOCKSIZE);
                printf("Bootstrap byte count:   %u\n", (unsigned)rv);
-               printf("Bootstrap block table:  %u entries avail, %u used:",
-                   maxblk, nblk);
+               printf("Bootstrap block table:  %u entries of %u bytes available, %u used:",
+                   maxblk, blocks[0].blocksize, nblk);
                for (blk_i = 0; blk_i < nblk; blk_i++)
                        printf(" %u", blocks[blk_i].block);
                printf("\n%sriting bootstrap\n",
@@ -264,8 +282,7 @@
                goto done;
        }
 
-       rv = pwrite(params->fsfd, &bb, sizeof(bb),
-                   startblock * SPARC_BOOT_BLOCK_BLOCKSIZE);
+       rv = pwrite(params->fsfd, &bb, sizeof(bb), SPARC_BOOT_BLOCK_OFFSET);
        if (rv == -1) {
                warn("Writing `%s'", params->filesystem);
                goto done;
diff -r f23770371a08 -r 7b5ac15f77ce usr.sbin/installboot/arch/sparc64.c
--- a/usr.sbin/installboot/arch/sparc64.c       Tue May 14 05:31:11 2002 +0000
+++ b/usr.sbin/installboot/arch/sparc64.c       Tue May 14 06:18:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sparc64.c,v 1.10 2002/04/30 14:24:33 lukem Exp $       */
+/*     $NetBSD: sparc64.c,v 1.11 2002/05/14 06:18:52 lukem Exp $       */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: sparc64.c,v 1.10 2002/04/30 14:24:33 lukem Exp $");
+__RCSID("$NetBSD: sparc64.c,v 1.11 2002/05/14 06:18:52 lukem Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -80,11 +80,13 @@
 #include <string.h>
 #include <unistd.h>



Home | Main Index | Thread Index | Old Index