From 1f29596d6b4f9f9ca96904222a4d235a8816472f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 20 May 1997 05:41:31 +0000 Subject: Add -s -e cd9660 hacks for making bootable alpha cd's. --- sys/arch/alpha/stand/installboot.c | 53 +++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/alpha/stand/installboot.c b/sys/arch/alpha/stand/installboot.c index c01835023a6..31fe74c8cb7 100644 --- a/sys/arch/alpha/stand/installboot.c +++ b/sys/arch/alpha/stand/installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: installboot.c,v 1.7 1997/05/05 06:01:48 millert Exp $ */ +/* $OpenBSD: installboot.c,v 1.8 1997/05/20 05:41:30 millert Exp $ */ /* $NetBSD: installboot.c,v 1.2 1997/04/06 08:41:12 cgd Exp $ */ /* @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -53,6 +54,10 @@ #include "bbinfo.h" +#ifndef ISO_DEFAULT_BLOCK_SIZE +#define ISO_DEFAULT_BLOCK_SIZE 2048 +#endif + int verbose, nowrite, hflag; char *boot, *proto, *dev; @@ -67,12 +72,15 @@ static void devread __P((int, void *, daddr_t, size_t, char *)); static void usage __P((void)); int main __P((int, char *[])); +int isofsblk = 0; +int isofseblk = 0; static void usage() { (void)fprintf(stderr, - "usage: installboot [-n] [-v] \n"); + "usage: installboot [-n] [-v] [-s isofsblk -e isofseblk]" + " \n"); exit(1); } @@ -85,13 +93,11 @@ main(argc, argv) int devfd; char *protostore; long protosize; - int mib[2]; - size_t size; struct stat disksb, bootsb; struct disklabel dl; unsigned long partoffset; - while ((c = getopt(argc, argv, "vn")) != EOF) { + while ((c = getopt(argc, argv, "vns:e:")) != -1) { switch (c) { case 'n': /* Do not actually write the bootblock to disk */ @@ -101,14 +107,19 @@ main(argc, argv) /* Chat */ verbose = 1; break; + case 's': + isofsblk = atoi(optarg); + break; + case 'e': + isofseblk = atoi(optarg); + break; default: usage(); } } - if (argc - optind < 3) { + if (argc - optind < 3) usage(); - } boot = argv[optind]; proto = argv[optind + 1]; @@ -234,8 +245,6 @@ loadprotoblocks(fname, size) int fd, sz; char *bp; struct stat statbuf; - struct exec *hp; - long off; u_int64_t *matchp; /* @@ -344,6 +353,32 @@ loadblocknums(boot, devfd, partoffset) if (fstatfs(fd, &statfsbuf) != 0) err(1, "statfs: %s", boot); + if (isofsblk) { + bbinfop->bsize = ISO_DEFAULT_BLOCK_SIZE; + bbinfop->nblocks = isofseblk - isofsblk + 1; + if (bbinfop->nblocks > max_block_count) + errx(1, "%s: Too many blocks", boot); + if (verbose) + (void)printf("%s: starting block %d (%d total):\n\t", + boot, isofsblk, bbinfop->nblocks); + for (i = 0; i < bbinfop->nblocks; i++) { + blk = (isofsblk + i) * (bbinfop->bsize / DEV_BSIZE); + bbinfop->blocks[i] = blk; + if (verbose) + (void)printf("%d ", blk); + } + if (verbose) + (void)printf("\n"); + + cksum = 0; + for (i = 0; i < bbinfop->nblocks + + (sizeof(*bbinfop) / sizeof(bbinfop->blocks[0])) - 1; i++) + cksum += ((int32_t *)bbinfop)[i]; + bbinfop->cksum = -cksum; + + return 0; + } + if (strncmp(statfsbuf.f_fstypename, MOUNT_FFS, MFSNAMELEN)) errx(1, "%s: must be on a FFS filesystem", boot); -- cgit v1.2.3