Annotation of 43BSDReno/sys/hpstand/installboot.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution is only permitted until one year after the first shipment
        !             6:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
        !             7:  * binary forms are permitted provided that: (1) source distributions retain
        !             8:  * this entire copyright notice and comment, and (2) distributions including
        !             9:  * binaries display the following acknowledgement:  This product includes
        !            10:  * software developed by the University of California, Berkeley and its
        !            11:  * contributors'' in the documentation or other materials provided with the
        !            12:  * distribution and in all advertising materials mentioning features or use
        !            13:  * of this software.  Neither the name of the University nor the names of
        !            14:  * its contributors may be used to endorse or promote products derived from
        !            15:  * this software without specific prior written permission.
        !            16:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            19:  *
        !            20:  *     @(#)installboot.c       7.1 (Berkeley) 5/8/90
        !            21:  */
        !            22: 
        !            23: #ifndef lint
        !            24: char copyright[] =
        !            25: "@(#) Copyright (c) 1980, 1986, 1990 The Regents of the University of California.\n\
        !            26:  All rights reserved.\n";
        !            27: #endif /* not lint */
        !            28: 
        !            29: #ifndef lint
        !            30: static char sccsid[] = "@(#)installboot.c      7.1 (Berkeley) 5/8/90";
        !            31: #endif /* not lint */
        !            32: 
        !            33: #include "../sys/param.h"
        !            34: #include "../ufs/fs.h"
        !            35: 
        !            36: char block[1024];
        !            37: int maxbootsize = 16 * 7 * 512;                /* XXX */
        !            38: 
        !            39: /*
        !            40:  * HPs are a kludge.
        !            41:  * The boot program won't fit in the boot area of a file system so we
        !            42:  * have to place it outside the file systems.  By convention, this means
        !            43:  * that if the 'a' partition is being used for '/', it is offset one
        !            44:  * cylinder into the disk and the boot program goes into that one cylinder.
        !            45:  * Also by convention, the 'c' partition is defined to be the entire disk
        !            46:  * including this boot cylinder.  If these conventions are not adhered to,
        !            47:  * the potential for disaster is enormous.
        !            48:  */
        !            49: main(argc, argv)
        !            50:        int argc;
        !            51:        char *argv[];
        !            52: {
        !            53:        int ifd, ofd, len;
        !            54:        char *dev, *standalonecode;
        !            55:        int bsize = 1024;
        !            56: 
        !            57:        if (argc != 3)
        !            58:                usage();
        !            59:        dev = argv[2];
        !            60:        len = strlen(dev);
        !            61:        if (dev[len-1] != 'c')
        !            62:                usage();
        !            63:        standalonecode = argv[1];
        !            64:        ifd = open(standalonecode, 0);
        !            65:        if (ifd < 0) {
        !            66:                perror(standalonecode);
        !            67:                exit(1);
        !            68:        }
        !            69:        ofd = open(dev, 1);
        !            70:        if (ofd < 0) {
        !            71:                perror(dev);
        !            72:                exit(1);
        !            73:        }
        !            74:        while ((len = read(ifd, block, bsize)) > 0) {
        !            75:                if ((maxbootsize -= bsize) < 0) {
        !            76:                        printf("%s: too big\n", standalonecode);
        !            77:                        exit(2);
        !            78:                }
        !            79:                if (len < bsize)
        !            80:                        bzero(&block[len], bsize-len);
        !            81:                if (write(ofd, block, bsize) != bsize) {
        !            82:                        perror(dev);
        !            83:                        exit(2);
        !            84:                }
        !            85:        }
        !            86:        if (len < 0) {
        !            87:                perror(standalonecode);
        !            88:                exit(2);
        !            89:        }
        !            90:        exit(0);
        !            91: }
        !            92: 
        !            93: usage()
        !            94: {
        !            95:        printf("Usage: installboot bootprog device\n");
        !            96:        printf("where:\n");
        !            97:        printf("\t\"bootprog\" is a LIF format file < %d bytes long\n",
        !            98:               maxbootsize);
        !            99:        printf("\t\"device\" must be the 'c' partition of a bootable disk\n");
        !           100:        printf("WARNING!!  If the 'c' partition contains a file system, %s\n",
        !           101:               "DON'T RUN THIS!!");
        !           102:        exit(1);
        !           103: }

unix.superglobalmegacorp.com

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