/* Hi Glen, I bought and installed a HP1533A last month for an Indigo running 5.2. Works fine. I have a special hack program called "dat" that tweaks the compression flag. This is necessary to make portable tapes. Here it is... You can post or hand this out as you wish. I would myself, but I don't have a net connection at the moment. */ /* * Tweak a HP1533A DAT drive compression mode on an SGI * * Author: Ken Chin-Purcell * Innovative Research, Inc. * Date: November 9, 1994 * * Public domain, no copyright, use as you wish. * * This has only been used for SGI IRIX 5.2 * * To make: cc -o dat dat.c -lds * * To use: * * Install the HP1533A tape drive: * Dip switches 3, 7, 8 OFF * All others ON * * Add to /var/sysgen/master.d/scsi, after "Python" entry: { DATTAPE, TPDAT, 2, 6, "HP", "C1533A", 0, 0, {0, 0, 0, 0}, MTCAN_BSF|MTCAN_BSR|MTCAN_APPEND|MTCAN_SETMK|MTCAN_PART|MTCAN_PREV| MTCAN_SYNC|MTCAN_SPEOD|MTCAN_CHKRDY|MTCAN_VAR|MTCAN_SETSZ| MTCAN_SILI|MTCAN_SEEK|MTCAN_CHTYPEANY, 40, 4*60, 4*60, 5*60, 512, 64*512 }, * * Then cd /, lboot -T, reboot * * Make this program, and either: * install it suid root, * or make the appropriate /dev/scsi/... entry writable (hmmmm), * or deny non-root users * * usage: dat [-t dev] [-d] [-q] [-c | -u] * Dat will try to find the first DAT drive * in the system inventory. The environment * variable DATDEVICE can also be used. * You must have write permission. * -t dev specify scsi device * -d verbose debug mode * -q quiet * -c compression ON * -u compression OFF * * Dat with no arguments returns the status of the drive. */ #include #include #include #include #include #include #include #define BUFLEN 32 /* Good enough */ ModeSelect(struct dsreq *dsp, caddr_t data, long datalen) { /* SGI's mode select doesn't set the SCSI-2 voodoo flag */ fillg0cmd(dsp, CMDBUF(dsp), G0_MSEL, 0x10, 0, 0, B1(datalen), 0); filldsreq(dsp, data, datalen, DSRQ_WRITE|DSRQ_SENSE); return(doscsireq(getfd(dsp), dsp)); } void DebugSep() { if (dsdebug) fputs("\n----------------------------------------\n", stderr); } char* LocateDat() { /* Return the first DAT drive found */ inventory_t* inv; static char devName[64]; while (inv = getinvent()) if (inv->inv_class == INV_TAPE && inv->inv_type == INV_SCSIQIC && inv->inv_state == TPDAT) { sprintf(devName, "/dev/scsi/sc%dd%dl0", inv->inv_controller, inv->inv_unit); return devName; } return 0; } int main(int argc, char* argv[]) { struct dsreq *dat; char mode[BUFLEN]; int i; int compress = 0; int uncompress = 0; int quiet = 0; char* datDevice = LocateDat(); dsdebug = 0; if (getenv("DATDEVICE")) datDevice = getenv("DATDEVICE"); while ((i = getopt(argc, argv, "cdhqut:")) != EOF) switch (i) { case 'c': compress = 1; uncompress = 0; break; case 'u': compress = 0; uncompress = 1; break; case 'd': dsdebug++; break; case 'q': quiet = 1; break; case 't': datDevice = optarg; break; case 'h': case '?': fprintf(stderr, "usage: dat [-t dev] [-d] [-q] [-c | -u]\n"); fprintf(stderr, " Dat will try to find the first DAT drive\n"); fprintf(stderr, " in the system inventory. The environment\n"); fprintf(stderr, " variable DATDEVICE can also be used.\n"); fprintf(stderr, " You must have write permission.\n"); fprintf(stderr, " -t dev specify scsi device\n"); fprintf(stderr, " -d verbose debug mode\n"); fprintf(stderr, " -q quiet\n"); fprintf(stderr, " -c compression ON\n"); fprintf(stderr, " -u compression OFF\n"); return 1; } if (!datDevice) { fprintf(stderr, "Cannot find DAT device\n"); return 1; } DebugSep(); dat = dsopen(datDevice, O_RDWR); if (!dat) { fprintf(stderr, "Cannot open scsi device %s\n", datDevice); fprintf(stderr, " Do you have permission?\n"); return 1; } if (testunitready00(dat) > 2) { fprintf(stderr, "Device %s not ready (hmmmmm...)\n", datDevice); return 1; } if (compress || uncompress) { memset(mode, 0, BUFLEN); mode[2] = 0x10; /* Buffered mode */ mode[4] = 0x0f; /* Mode page 15 */ mode[5] = 0x0e; /* 14 bytes to the page */ mode[6] = compress ? 0xc0 : 0x40; mode[7] = 0x80; /* enable decompression */ mode[11] = 0x20; /* LZ compression */ DebugSep(); ModeSelect(dat, mode, 20); } memset(mode, 0, BUFLEN); DebugSep(); modesense1a(dat, mode, 28, 0, 0xf, 0); if (!quiet) if (mode[14] == 0xc0) printf("DAT compression on\n"); else printf("DAT compression off\n"); return 0; }