Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/installboot - Add code from Matt Fredette <fredette...



details:   https://anonhg.NetBSD.org/src/rev/210e882e95c2
branches:  trunk
changeset: 525879:210e882e95c2
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Apr 19 07:08:51 2002 +0000

description:
- Add code from Matt Fredette <fredette%theory.lcs.mit.edu@localhost> to implement
  fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"

diffstat:

 usr.sbin/installboot/Makefile       |    8 +-
 usr.sbin/installboot/arch/alpha.c   |   31 +-
 usr.sbin/installboot/arch/pmax.c    |   30 +-
 usr.sbin/installboot/arch/sparc64.c |   10 +-
 usr.sbin/installboot/arch/vax.c     |   32 +-
 usr.sbin/installboot/ffs.c          |  350 ++++++++++++++++++++++++++++++++++++
 usr.sbin/installboot/fstypes.c      |   45 ++++
 usr.sbin/installboot/installboot.8  |   11 +-
 usr.sbin/installboot/installboot.c  |   59 +++++-
 usr.sbin/installboot/installboot.h  |   42 +++-
 usr.sbin/installboot/machines.c     |   14 +-
 usr.sbin/installboot/sum.c          |   12 +-
 12 files changed, 548 insertions(+), 96 deletions(-)

diffs (truncated from 1070 to 300 lines):

diff -r 86688ecc682d -r 210e882e95c2 usr.sbin/installboot/Makefile
--- a/usr.sbin/installboot/Makefile     Fri Apr 19 05:27:04 2002 +0000
+++ b/usr.sbin/installboot/Makefile     Fri Apr 19 07:08:51 2002 +0000
@@ -1,15 +1,17 @@
-#      $NetBSD: Makefile,v 1.10 2002/04/11 07:56:13 lukem Exp $
+#      $NetBSD: Makefile,v 1.11 2002/04/19 07:08:51 lukem Exp $
 #
 
 PROG=  installboot
-SRCS=  installboot.c sum.c machines.c \
+SRCS=  installboot.c sum.c machines.c fstypes.c \
+       ffs.c ffs_bswap.c \
        alpha.c pmax.c sparc64.c vax.c
 MAN=   installboot.8
 
 WARNS?=        3
 
+UFSSRC=                ${_SRC_TOP_}/sys/ufs
 CPPFLAGS+=     -I${.CURDIR}
-.PATH:         ${.CURDIR}/arch
+.PATH:         ${.CURDIR}/arch ${UFSSRC}/ffs
 
 .ifndef HOSTPROG
 # list of MACHINEs to enable the compat symlink /usr/mdec/installboot
diff -r 86688ecc682d -r 210e882e95c2 usr.sbin/installboot/arch/alpha.c
--- a/usr.sbin/installboot/arch/alpha.c Fri Apr 19 05:27:04 2002 +0000
+++ b/usr.sbin/installboot/arch/alpha.c Fri Apr 19 07:08:51 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alpha.c,v 1.5 2002/04/12 06:50:41 lukem Exp $  */
+/*     $NetBSD: alpha.c,v 1.6 2002/04/19 07:08:54 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.5 2002/04/12 06:50:41 lukem Exp $");
+__RCSID("$NetBSD: alpha.c,v 1.6 2002/04/19 07:08:54 lukem Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -118,11 +118,8 @@
 
 #define        SUN_DKMAGIC     55998           /* XXX: from <dev/sun/disklabel.h> */
 
-int            alpha_parseopt(ib_params *, const char *);
-int            alpha_setboot(ib_params *);
-int            alpha_clearboot(ib_params *);
 static void    resum(ib_params *, struct alpha_boot_block * const bb,
-                       u_int16_t *bb16);
+                       uint16_t *bb16);
 static void    sun_bootstrap(ib_params *, struct alpha_boot_block * const);
 static void    check_sparc(const struct alpha_boot_block * const,
                            const char *);
@@ -144,7 +141,7 @@
 alpha_clearboot(ib_params *params)
 {
        struct alpha_boot_block bb;
-       u_int64_t               cksum;
+       uint64_t                cksum;
        ssize_t                 rv;
 
        assert(params != NULL);
@@ -219,7 +216,7 @@
 {
        struct stat             bootstrapsb;
        struct alpha_boot_block bb;
-       u_int64_t               startblock;
+       uint64_t                startblock;
        int                     retval;
        char                    *bootstrapbuf;
        size_t                  bootstrapsize;
@@ -365,13 +362,13 @@
 /*
  * The Sun and alpha checksums overlay, and the Sun magic number also
  * overlays the alpha checksum. If you think you are smart: stop here
- * and do exercise one: figure out how to salt unimportant u_int16_t
+ * and do exercise one: figure out how to salt unimportant uint16_t
  * words in mid-sector so that the alpha and sparc checksums match,
  * and so the Sun magic number is embedded in the alpha checksum.
  *
- * The last u_int64_t in the sector is the alpha arithmetic checksum.
- * The last u_int16_t in the sector is the sun xor checksum.
- * The penultimate u_int16_t in the sector is the sun magic number.
+ * The last uint64_t in the sector is the alpha arithmetic checksum.
+ * The last uint16_t in the sector is the sun xor checksum.
+ * The penultimate uint16_t in the sector is the sun magic number.
  *
  *     A:   511     510     509     508     507     506     505     504
  *     S:   510     511     508     509     506     507     504     505
@@ -386,9 +383,9 @@
  */
 
 static void
-resum(ib_params *params, struct alpha_boot_block * const bb, u_int16_t *bb16)
+resum(ib_params *params, struct alpha_boot_block * const bb, uint16_t *bb16)
 {
-       static u_int64_t lastsum;
+       static uint64_t lastsum;
 
        if (bb16 != NULL)
                memcpy(bb, bb16, sizeof(*bb));
@@ -405,7 +402,7 @@
 {
 #      define BB_ADJUST_OFFSET 64
        static char our_int16s[] = "\2\3\6\7\12";
-       u_int16_t i, j, chkdelta, sunsum, bb16[256];
+       uint16_t i, j, chkdelta, sunsum, bb16[256];
 
        /*
         * Theory: the alpha checksum is adjusted so bits 47:32 add up
@@ -442,7 +439,7 @@
        bb16[BB_ADJUST_OFFSET + 3] = chkdelta >> 1;
        bb16[BB_ADJUST_OFFSET + 7] = chkdelta >> 1;
        /*
-        * By placing half the correction in two different u_int64_t words at
+        * By placing half the correction in two different uint64_t words at
         * positions 63:48, the sparc sum will not change but the alpha sum
         * will have the full correction, but only if the target adjustment
         * was even. If it was odd, reverse propagate the carry one place.
@@ -466,7 +463,7 @@
 static void
 check_sparc(const struct alpha_boot_block * const bb, const char *when)
 {
-       u_int16_t bb16[256];
+       uint16_t bb16[256];
        const char * const wmsg =
            "%s sparc %s 0x%04x invalid, expected 0x%04x";
 
diff -r 86688ecc682d -r 210e882e95c2 usr.sbin/installboot/arch/pmax.c
--- a/usr.sbin/installboot/arch/pmax.c  Fri Apr 19 05:27:04 2002 +0000
+++ b/usr.sbin/installboot/arch/pmax.c  Fri Apr 19 07:08:51 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmax.c,v 1.3 2002/04/12 06:50:41 lukem Exp $   */
+/*     $NetBSD: pmax.c,v 1.4 2002/04/19 07:08:54 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.3 2002/04/12 06:50:41 lukem Exp $");
+__RCSID("$NetBSD: pmax.c,v 1.4 2002/04/19 07:08:54 lukem Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -120,11 +120,8 @@
 
 #include "installboot.h"
 
-int            pmax_parseopt(ib_params *, const char *);
-int            pmax_setboot(ib_params *);
-int            pmax_clearboot(ib_params *);
 static int     load_bootstrap(ib_params *, char **,
-                               u_int32_t *, u_int32_t *, size_t *);
+                               uint32_t *, uint32_t *, size_t *);
 
 
 int
@@ -172,10 +169,10 @@
        bb.magic = htole32(PMAX_BOOT_MAGIC);
 
        if (params->flags & IB_SUNSUM) {
-               u_int16_t       sum;
+               uint16_t        sum;
 
-               sum = compute_sunsum((u_int16_t *)&bb);
-               if (! set_sunsum(params, (u_int16_t *)&bb, sum))
+               sum = compute_sunsum((uint16_t *)&bb);
+               if (! set_sunsum(params, (uint16_t *)&bb, sum))
                        return (0);
        }
 
@@ -202,10 +199,11 @@
 {
        struct stat             bootstrapsb;
        struct pmax_boot_block  bb;
-       int                     startblock, retval;
+       uint32_t                startblock;
+       int                     retval;
        char                    *bootstrapbuf;
        size_t                  bootstrapsize;
-       u_int32_t               bootstrapload, bootstrapexec;
+       uint32_t                bootstrapload, bootstrapexec;
        ssize_t                 rv;
 
        assert(params != NULL);
@@ -277,10 +275,10 @@
        bb.mode = htole32(PMAX_BOOTMODE_CONTIGUOUS);
 
        if (params->flags & IB_SUNSUM) {
-               u_int16_t       sum;
+               uint16_t        sum;
 
-               sum = compute_sunsum((u_int16_t *)&bb);
-               if (! set_sunsum(params, (u_int16_t *)&bb, sum))
+               sum = compute_sunsum((uint16_t *)&bb);
+               if (! set_sunsum(params, (uint16_t *)&bb, sum))
                        goto done;
        }
 
@@ -340,7 +338,7 @@
 
 static int
 load_bootstrap(ib_params *params, char **data,
-       u_int32_t *loadaddr, u_int32_t *execaddr, size_t *len)
+       uint32_t *loadaddr, uint32_t *execaddr, size_t *len)
 {
        int             i, nsegs;
        Elf32_Addr      lowaddr, highaddr;
@@ -359,7 +357,7 @@
        }
 
        nsegs = highaddr = 0;
-       lowaddr = (u_int32_t) ULONG_MAX;
+       lowaddr = (uint32_t) ULONG_MAX;
 
        for (i = 0; i < le16toh(ehdr.e_phnum); i++) {
                if (pread(params->s1fd, &phdr, sizeof(phdr),
diff -r 86688ecc682d -r 210e882e95c2 usr.sbin/installboot/arch/sparc64.c
--- a/usr.sbin/installboot/arch/sparc64.c       Fri Apr 19 05:27:04 2002 +0000
+++ b/usr.sbin/installboot/arch/sparc64.c       Fri Apr 19 07:08:51 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sparc64.c,v 1.7 2002/04/17 04:00:44 fredette Exp $     */
+/*     $NetBSD: sparc64.c,v 1.8 2002/04/19 07:08:54 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.7 2002/04/17 04:00:44 fredette Exp $");
+__RCSID("$NetBSD: sparc64.c,v 1.8 2002/04/19 07:08:54 lukem Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -82,9 +82,6 @@
 
 #include "installboot.h"
 
-int    sparc64_setboot(ib_params *);
-int    sparc64_clearboot(ib_params *);
-
 #define SPARC64_BOOT_BLOCK_OFFSET      DEV_BSIZE
 #define SPARC64_BOOT_BLOCK_BLOCKSIZE   DEV_BSIZE
 #define SPARC64_BOOT_BLOCK_MAX_SIZE    (DEV_BSIZE * 15)
@@ -139,7 +136,8 @@
 {
        struct stat     bootstrapsb;
        char            bb[SPARC64_BOOT_BLOCK_MAX_SIZE];
-       int             startblock, retval;
+       uint32_t        startblock;
+       int             retval;
        ssize_t         rv;
 
        assert(params != NULL);
diff -r 86688ecc682d -r 210e882e95c2 usr.sbin/installboot/arch/vax.c
--- a/usr.sbin/installboot/arch/vax.c   Fri Apr 19 05:27:04 2002 +0000
+++ b/usr.sbin/installboot/arch/vax.c   Fri Apr 19 07:08:51 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vax.c,v 1.2 2002/04/12 06:50:41 lukem Exp $    */
+/*     $NetBSD: vax.c,v 1.3 2002/04/19 07:08:54 lukem Exp $    */
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: vax.c,v 1.2 2002/04/12 06:50:41 lukem Exp $");
+__RCSID("$NetBSD: vax.c,v 1.3 2002/04/19 07:08:54 lukem Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -88,11 +88,8 @@
 
 #include "installboot.h"
 
-int            vax_parseopt(ib_params *, const char *);
-int            vax_setboot(ib_params *);
-int            vax_clearboot(ib_params *);
 static int     load_bootstrap(ib_params *, char **,
-                   u_int32_t *, u_int32_t *, size_t *);
+                   uint32_t *, uint32_t *, size_t *);
 
 
 int
@@ -143,10 +140,10 @@
        bb.bb_lbn_low = 0;
 
        if (params->flags & IB_SUNSUM) {
-               u_int16_t       sum;
+               uint16_t        sum;
 
-               sum = compute_sunsum((u_int16_t *)&bb);
-               if (! set_sunsum(params, (u_int16_t *)&bb, sum))
+               sum = compute_sunsum((uint16_t *)&bb);



Home | Main Index | Thread Index | Old Index