Annotation of Net2/arch/hp300/stand/installboot.c, revision 1.1.1.2

1.1       root        1: /*
                      2:  * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
1.1.1.2 ! root       33:  *     from: @(#)installboot.c 7.2 (Berkeley) 12/16/90
        !            34:  *     installboot.c,v 1.2 1993/05/22 07:59:00 cgd Exp
1.1       root       35:  */
                     36: 
                     37: #ifndef lint
                     38: char copyright[] =
1.1.1.2 ! root       39: "Copyright (c) 1980, 1986, 1990 The Regents of the University of California.\n\
1.1       root       40:  All rights reserved.\n";
                     41: #endif /* not lint */
                     42: 
                     43: #ifndef lint
1.1.1.2 ! root       44: /* from: static char sccsid[] = "@(#)installboot.c     7.2 (Berkeley) 12/16/90"; */
        !            45: static char rcsid[] = "installboot.c,v 1.2 1993/05/22 07:59:00 cgd Exp";
1.1       root       46: #endif /* not lint */
                     47: 
                     48: #include "sys/param.h"
                     49: #include "ufs/fs.h"
                     50: 
                     51: char block[1024];
                     52: int maxbootsize = 16 * 7 * 512;                /* XXX */
                     53: 
                     54: /*
                     55:  * HPs are a kludge.
                     56:  * The boot program won't fit in the boot area of a file system so we
                     57:  * have to place it outside the file systems.  By convention, this means
                     58:  * that if the 'a' partition is being used for '/', it is offset one
                     59:  * cylinder into the disk and the boot program goes into that one cylinder.
                     60:  * Also by convention, the 'c' partition is defined to be the entire disk
                     61:  * including this boot cylinder.  If these conventions are not adhered to,
                     62:  * the potential for disaster is enormous.
                     63:  */
                     64: main(argc, argv)
                     65:        int argc;
                     66:        char *argv[];
                     67: {
                     68:        int ifd, ofd, len;
                     69:        char *dev, *standalonecode;
                     70:        int bsize = 1024;
                     71: 
                     72:        if (argc != 3)
                     73:                usage();
                     74:        dev = argv[2];
                     75:        len = strlen(dev);
                     76:        if (dev[len-1] != 'c')
                     77:                usage();
                     78:        standalonecode = argv[1];
                     79:        ifd = open(standalonecode, 0);
                     80:        if (ifd < 0) {
                     81:                perror(standalonecode);
                     82:                exit(1);
                     83:        }
                     84:        ofd = open(dev, 1);
                     85:        if (ofd < 0) {
                     86:                perror(dev);
                     87:                exit(1);
                     88:        }
                     89:        while ((len = read(ifd, block, bsize)) > 0) {
                     90:                if ((maxbootsize -= bsize) < 0) {
                     91:                        printf("%s: too big\n", standalonecode);
                     92:                        exit(2);
                     93:                }
                     94:                if (len < bsize)
                     95:                        bzero(&block[len], bsize-len);
                     96:                if (write(ofd, block, bsize) != bsize) {
                     97:                        perror(dev);
                     98:                        exit(2);
                     99:                }
                    100:        }
                    101:        if (len < 0) {
                    102:                perror(standalonecode);
                    103:                exit(2);
                    104:        }
                    105:        exit(0);
                    106: }
                    107: 
                    108: usage()
                    109: {
                    110:        printf("Usage: installboot bootprog device\n");
                    111:        printf("where:\n");
                    112:        printf("\t\"bootprog\" is a LIF format file < %d bytes long\n",
                    113:               maxbootsize);
                    114:        printf("\t\"device\" must be the 'c' partition of a bootable disk\n");
                    115:        printf("WARNING!!  If the 'c' partition contains a file system, %s\n",
                    116:               "DON'T RUN THIS!!");
                    117:        exit(1);
                    118: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.