Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha/stand/installboot Moved to sys/arch/alpha/sta...
details: https://anonhg.NetBSD.org/src/rev/68aafde5d70d
branches: trunk
changeset: 471567:68aafde5d70d
user: cgd <cgd%NetBSD.org@localhost>
date: Mon Apr 05 03:02:07 1999 +0000
description:
Moved to sys/arch/alpha/stand/installboot.old/installboot.c,v
diffstat:
sys/arch/alpha/stand/installboot/installboot.c | 635 -------------------------
1 files changed, 0 insertions(+), 635 deletions(-)
diffs (truncated from 639 to 300 lines):
diff -r f82b209b58ee -r 68aafde5d70d sys/arch/alpha/stand/installboot/installboot.c
--- a/sys/arch/alpha/stand/installboot/installboot.c Mon Apr 05 03:02:06 1999 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,635 +0,0 @@
-/* $NetBSD: installboot.c,v 1.12 1999/04/02 07:34:49 cgd Exp $ */
-
-/*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Paul Kranenburg and Jason R. Thorpe of the Numerical Aerospace
- * Simulation Facility, NASA Ames Research Center.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. <not applicable>
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-#include <isofs/cd9660/iso.h>
-#include <sys/disklabel.h>
-#include <sys/dkio.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <util.h>
-
-#include "extern.h"
-
-#include "stand/common/bbinfo.h"
-
-int verbose, nowrite, hflag, cd9660, conblockmode, conblockstart;
-char *boot, *proto, *dev;
-
-struct bbinfoloc *bbinfolocp;
-struct bbinfo *bbinfop;
-int max_block_count;
-
-
-void setup_contig_blks(u_long, u_long, int, int, char *);
-char *loadprotoblocks __P((char *, long *));
-int loadblocknums_ffs __P((char *, int, unsigned long));
-int loadblocknums_cd9660 __P((char *, int, unsigned long));
-int loadblocknums_passthru __P((char *, int, unsigned long));
-static void devread __P((int, void *, daddr_t, size_t, char *));
-static void usage __P((void));
-int main __P((int, char *[]));
-
-extern char *__progname;
-
-static void
-usage()
-{
- fprintf(stderr,
- "usage: %s [-n] [-v] <boot> <proto> <dev>\n", __progname);
- exit(1);
-}
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- int c;
- int devfd;
- char *protostore;
- long protosize;
- struct stat disksb, bootsb;
- struct statfs fssb;
- struct disklabel dl;
- unsigned long partoffset;
- int (*loadblocknums_func) __P((char *, int, unsigned long));
-
- while ((c = getopt(argc, argv, "nvb:")) != -1) {
- switch (c) {
- case 'b':
- /* generic override, supply starting block # */
- conblockmode = 1;
- conblockstart = atoi(optarg);
- break;
- case 'n':
- /* Do not actually write the bootblock to disk */
- nowrite = 1;
- break;
- case 'v':
- /* Chat */
- verbose = 1;
- break;
- default:
- usage();
- }
- }
-
- if (argc - optind < 3) {
- usage();
- }
-
- boot = argv[optind];
- proto = argv[optind + 1];
- dev = argv[optind + 2];
-
- if (verbose) {
- printf("boot: %s\n", boot);
- printf("proto: %s\n", proto);
- printf("device: %s\n", dev);
- }
-
- /* Load proto blocks into core */
- if ((protostore = loadprotoblocks(proto, &protosize)) == NULL)
- exit(1);
-
- /* Open and check the target device. */
- if ((devfd = open(dev, O_RDONLY, 0)) < 0)
- err(1, "open: %s", dev);
- if (fstat(devfd, &disksb) == -1)
- err(1, "fstat: %s", dev);
- if (!S_ISCHR(disksb.st_mode))
- errx(1, "%s must be a character device node", dev);
- if ((minor(disksb.st_rdev) % getmaxpartitions()) != getrawpartition())
- errx(1, "%s must be the raw partition", dev);
-
- /* Extract and load block numbers */
- if (stat(boot, &bootsb) == -1)
- err(1, "stat: %s", boot);
- /*
- * The error below doesn't matter in conblockmode, but leave it in
- * because it may catch misplaced arguments; this program doesn't
- * get run enough for people to be familiar with it.
- */
- if (!S_ISREG(bootsb.st_mode))
- errx(1, "%s must be a regular file", boot);
- if(!conblockmode) {
- if ((minor(disksb.st_rdev) / getmaxpartitions()) !=
- (minor(bootsb.st_dev) / getmaxpartitions()))
- errx(1, "%s must be somewhere on %s", boot, dev);
- /*
- * Determine the file system type of the file system on which
- * the boot program resides.
- */
- if (statfs(boot, &fssb) == -1)
- err(1, "statfs: %s", boot);
- if (strcmp(fssb.f_fstypename, MOUNT_CD9660) == 0) {
- /*
- * Installing a boot block on a CD-ROM image.
- */
- cd9660 = 1;
- } else if (strcmp(fssb.f_fstypename, MOUNT_FFS) != 0) {
- /*
- * Some other file system type, which is not FFS.
- * Can't handle these.
- */
- errx(1, "unsupported file system type: %s",
- fssb.f_fstypename);
- }
- if (verbose)
- printf("file system type: %s\n", fssb.f_fstypename);
- /*
- * Find the offset of the secondary boot block's partition
- * into the disk.
- */
- if (ioctl(devfd, DIOCGDINFO, &dl) == -1)
- err(1, "read disklabel: %s", dev);
- partoffset = dl.d_partitions[minor(bootsb.st_dev) %
- getmaxpartitions()].p_offset;
- if (verbose)
- printf("%s partition offset = 0x%lx\n",
- boot, partoffset);
- /*
- * sync filesystems (make sure boot's block numbers are stable)
- */
- sync();
- sleep(2);
- sync();
- sleep(2);
- }
- if (conblockmode)
- loadblocknums_func = loadblocknums_passthru;
- else if (cd9660)
- loadblocknums_func = loadblocknums_cd9660;
- else
- loadblocknums_func = loadblocknums_ffs;
-
- if ((*loadblocknums_func)(boot, devfd, partoffset) != 0)
- exit(1);
-
- (void)close(devfd);
-
- if (nowrite)
- return 0;
-
-#if 0
- /* Write patched proto bootblocks into the superblock */
- if (protosize > SBSIZE - DEV_BSIZE)
- errx(1, "proto bootblocks too big");
-#endif
-
- if ((devfd = open(dev, O_RDWR, 0)) < 0)
- err(1, "open: %s", dev);
-
- if (lseek(devfd, DEV_BSIZE, SEEK_SET) != DEV_BSIZE)
- err(1, "lseek bootstrap");
-
- if (write(devfd, protostore, protosize) != protosize)
- err(1, "write bootstrap");
-
- /*
- * Disks should already have a disklabel, but CD-ROM images
- * may not. Construct one as the SCSI CD driver would and
- * write it to the image.
- */
- if (cd9660) {
- char block[DEV_BSIZE];
- struct disklabel *lp;
- size_t imagesize;
- int rawpart = getrawpartition();
- off_t labeloff;
-
- labeloff = (LABELSECTOR * DEV_BSIZE) + LABELOFFSET;
- if (lseek(devfd, labeloff, SEEK_SET) != labeloff)
- err(1, "lseek to write fake label");
-
- if (read(devfd, block, sizeof(block)) != sizeof(block))
- err(1, "read fake label block");
-
- lp = (struct disklabel *)block;
-
- imagesize = howmany(dl.d_partitions[rawpart].p_size *
- dl.d_secsize, DEV_BSIZE);
-
- memset(lp, 0, sizeof(struct disklabel));
-
- lp->d_secsize = DEV_BSIZE;
- lp->d_ntracks = 1;
- lp->d_nsectors = 100;
- lp->d_ncylinders = (imagesize / 100) + 1;
- lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
Home |
Main Index |
Thread Index |
Old Index