Annotation of Examples/DriverKit/SCSITape/PreLoad.tproj/PreLoad.m, revision 1.1.1.1

1.1       root        1: /*
                      2:  *      Copyright (c) 1994 NeXT Computer, Inc.  All rights reserved. 
                      3:  *
                      4:  * PreLoad command for SCSI Tape.   Removes old SCSI Tape device nodes.
                      5:  *
                      6:  * HISTORY
                      7:  * 1-Apr-94    Phillip Dibner at NeXT
                      8:  *      Created. 
                      9:  */
                     10: 
                     11: #import <errno.h>
                     12: #import <libc.h>
                     13: #import "SCSITapeTypes.h"
                     14: 
                     15: #define PATH_NAME_SIZE 10
                     16: #define DEV_STRING "/dev/"
                     17: #define ST_PRELOAD_ERR_STRING "SCSI Tape PreLoad"
                     18: #define NTAPE_NAMES 4
                     19: #define NST 4 /* XXX This is redundant, but avoids compilation errors */
                     20: 
                     21: char path [PATH_NAME_SIZE];
                     22: char *scsiTapeNames[] = {"rst", "nrst", "rxt", "nrxt"};
                     23: int scsiTapeDevFlags[] = {0, 1, 2, 3}; /* bit 0 = no rewind, bit 1 = Exabyte */
                     24: 
                     25: int
                     26: main(int argc, char **argv)
                     27: {
                     28:     int                                iUnit, iRet = 0;
                     29:     int                                i;
                     30: 
                     31:     for (iUnit = 0; iUnit < NST; iUnit ++) {
                     32:        bzero (path, PATH_NAME_SIZE);
                     33:        sprintf (path, "%s%s%d", DEV_STRING, "st", iUnit);
                     34: 
                     35:        /*
                     36:         * Remove old devs and create new ones for this unit.
                     37:         */
                     38:        for (i = 0; i < NTAPE_NAMES; i++) {
                     39: 
                     40:            bzero (path, PATH_NAME_SIZE);
                     41:            sprintf (path, "%s%s%d", DEV_STRING, scsiTapeNames [i], iUnit);
                     42: 
                     43:            if (unlink (path)) {
                     44:                if (errno != ENOENT) {
                     45:                    printf ("%s: could not delete old %s.  Errno is %d\n",
                     46:                        ST_PRELOAD_ERR_STRING, path, errno);
                     47:                    iRet = -1; 
                     48:                }
                     49:            }
                     50:        }
                     51:     } /* for iUnit */
                     52:     return iRet;
                     53: }

unix.superglobalmegacorp.com

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