Index: TODO =================================================================== RCS file: /home/cvsroot/scsidev/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TODO 2000/02/14 22:54:03 1.2 +++ TODO 2000/07/14 23:59:35 1.3 @@ -1,12 +1,15 @@ -TODO ($Id: TODO,v 1.2 2000/02/14 22:54:03 garloff Exp $) +TODO ($Id: TODO,v 1.3 2000/07/14 23:59:35 garloff Exp $) ==== -* Update manpage (-r option, sparse cfg) * Update README file. * Scan differently ... - First all sgs => number of disks, tapes, cdroms - Tapes: Those are safe! + - ... but not the OnStream variants (osst) - Then the other devs until all have been found (stop after a while, if there are only removeables left ...) - Set up relations - +* A completely different approach would use /proc/scsi/scsi. + This should be even more safe. + Probably this could be done in a little perl or bash script. + Index: VERSION =================================================================== RCS file: /home/cvsroot/scsidev/VERSION,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- VERSION 2000/02/14 22:58:32 1.5 +++ VERSION 2000/07/14 23:46:44 1.6 @@ -1 +1 @@ -2.10 +2.20 Index: boot.diff =================================================================== RCS file: /home/cvsroot/scsidev/boot.diff,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- boot.diff 2000/02/14 22:54:03 1.3 +++ boot.diff 2000/07/15 00:05:10 1.4 @@ -1,8 +1,6 @@ --- /sbin/init.d/boot.orig Thu Jan 20 11:20:25 2000 +++ /sbin/init.d/boot Mon Feb 14 23:44:26 2000 -@@ -33,6 +33,25 @@ - echo -e "$ECHO_RETURN" - fi +@@ -33,2 +33,21 @@ +# +# Load SCSI driver @@ -24,11 +22,7 @@ +fi + # - # maybe we use "Multiple devices". So initialize MD. - # -@@ -222,6 +241,27 @@ - fi - fi +@@ -222,4 +241,25 @@ +# If scsidev created a ramdisk for /dev/scsi, it's now time to +# remove it: / is writeable now. @@ -54,10 +48,7 @@ # # Mount local filesystems in '/etc/fstab' (and create an entry # for / and /proc). -@@ -301,6 +341,13 @@ - { echo ; echo -e "ldconfig $rc_failed" ; } ; } & - echo -e "$ECHO_RETURN" - } +@@ -301,2 +341,9 @@ + +# Now finally remove the scsidev ramdisk to free some memory +if test ! -z "$HAVE_DEVSCSI_RAM3"; then @@ -67,4 +58,3 @@ +fi # - # Let zic set timezone - if present. Index: scsi.alias =================================================================== RCS file: /home/cvsroot/scsidev/scsi.alias,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- scsi.alias 2000/01/16 23:28:49 1.3 +++ scsi.alias 2000/07/15 00:05:10 1.4 @@ -1,8 +1,9 @@ # -# $Id: scsi.alias,v 1.3 2000/01/16 23:28:49 garloff Exp $ +# $Id: scsi.alias,v 1.4 2000/07/15 00:05:10 garloff Exp $ # serial_number="DX908FK", devtype=disk, alias=fourgig manufacturer=WANGTEK, devtype=tape, alias=qictape id=2, devtype=generic, alias=cdwriter hostname="ncr53c8xx", manufacturer="IBM", devtype=disk, alias=IBM_OLD -hostname="Tekram DC390", rev="W6A6", serial="F36J5322", alias=IBM_DCAS +hostname="Tekram DC390", rev="W6A6", serial="F36J5322", devtype=disk, alias=IBM_DCAS +hostname="Tekram DC395", devtype=osst, alias=ONSTREAM Index: scsidev.8 =================================================================== RCS file: /home/cvsroot/scsidev/scsidev.8,v retrieving revision 1.9 retrieving revision 1.11 diff -u -r1.9 -r1.11 --- scsidev.8 2000/02/14 22:54:03 1.9 +++ scsidev.8 2000/07/14 23:59:35 1.11 @@ -1,8 +1,8 @@ # -# $Id: scsidev.8,v 1.9 2000/02/14 22:54:03 garloff Exp $ +# $Id: scsidev.8,v 1.11 2000/07/14 23:59:35 garloff Exp $ # .\" -*- nroff -*- -.TH SCSIDEV 25 "January 2000" "Version 2.10" +.TH SCSIDEV 8 "July 2000" "Version 2.20" .SH NAME scsidev \- populate /dev/scsi with device names that are independent of reconfiguration. .SH SYNOPSIS @@ -142,7 +142,7 @@ .I \-r .B scsidev does first probe the generic and then -- if appropriate -- the other -highlevel devices (st, sd, sr). For removable block devices (sd, sr), +highlevel devices (st, sd, sr). For removable devices (sd, sr, osst), this will fail, if no medium is inserted, so .B scsidev can not ensure, that the device actually corresponds to the one reported by @@ -186,7 +186,7 @@ .fi The minimum requirements are that each line have a alias and a devtype field. The alias will be used to build the pathnames, and the devtype -must be one of disk, tape, cdrom or generic. +must be one of disk, tape, osst, cdrom or generic. .P The additional qualifiers are optional, and you must specify a sufficient number of them such that the alias will match only one Index: scsidev.c =================================================================== RCS file: /home/cvsroot/scsidev/scsidev.c,v retrieving revision 1.24 retrieving revision 1.26 diff -u -r1.24 -r1.26 --- scsidev.c 2000/01/28 00:15:30 1.24 +++ scsidev.c 2000/07/14 23:59:35 1.26 @@ -51,6 +51,12 @@ * - struct regnames (sname) now has generic pointer to allow * relationships between devs. name is the full name, now. * + * * 2000/07/15: Kurt Garloff + * - Open device nodes (but sg) with O_NONBLOCK; unfortunately this is not + * honoured by most of Linux' SCSI high-level drivers :-( + * - Add support for OnStream tapes (osst) + * -> Version 2.20 + * */ #include @@ -67,7 +73,7 @@ #include -static char rcsid[] ="$Id: scsidev.c,v 1.24 2000/01/28 00:15:30 garloff Exp $"; +static char rcsid[] ="$Id: scsidev.c,v 1.26 2000/07/14 23:59:35 garloff Exp $"; static char *versid = "scsidev " VERSION " 2000/01/17"; static char *copyright = "Copyright: GNU GPL (see file COPYING)\n" \ " (w) 1994--1997 Eric Youngdale \n"\ @@ -156,7 +162,17 @@ void build_special(); int inquiry (int, sname *); +#ifndef OSST_MAJOR +# define OSST_MAJOR 206 +#endif + +#define OSST_SUPPORTS(spnt) (! ( memcmp (spnt->manufacturer, "OnStream", 8) || \ + ( memcmp (spnt->model, "SC-", 3) && \ + memcmp (spnt->model, "DI-", 3) && \ + memcmp (spnt->model, "DP-", 3) && \ + memcmp (spnt->model, "USB", 3) ) ) ) + /* * Used to maintain a list of the nodes that we have seen * which we know to be OK and active. @@ -348,6 +364,10 @@ case SCSI_TAPE_MAJOR: if (spnt->minor & 0x80) strcat (nm, "n"); devchar = 't'; break; + case OSST_MAJOR: + if (spnt->minor & 0x80) strcat (nm, "nos"); + else strcat (nm, "os"); + devchar = 't'; break; default: if (!(SCSI_DISK_MAJOR (spnt->major))) { @@ -386,6 +406,12 @@ else sprintf (genpart, "st%d", spnt->minor & 0x7f); break; + case OSST_MAJOR: + if (spnt->minor & 0x80) + sprintf (genpart, "nosst%d", spnt->minor & 0x7f); + else + sprintf (genpart, "osst%d", spnt->minor & 0x7f); + break; default: if (!(SCSI_DISK_MAJOR (spnt->major))) { @@ -394,7 +420,7 @@ abort (); } - /* SCSI_DISK1 -- SCSI_DISK7 are contiguousin Linux-2.2+ */ + /* SCSI_DISK1 -- SCSI_DISK7 are contiguous in Linux-2.2+ */ if (spnt->major == SCSI_DISK0_MAJOR) diskno = spnt->minor >> 4; else @@ -602,12 +628,12 @@ create_dev (spnt1); spnt->related = spnt1; /* Check if device is there (i.e. medium inside) */ - fd = open (spnt1->name, O_RDONLY); + fd = open (spnt1->name, O_RDONLY | O_NONBLOCK); /* No access to medium / part. table */ if (fd < 0) { spnt1->unsafe = 1; /* If it is a removable device, we can't do much more than - * trusting it or not support it at all*/ + * trusting it or not support it at all */ if (spnt1->rmvbl && supp_rmvbl) return 0; fprintf (stderr, "Can't access %sremovable %s, which should " "be equal to %s!\n", (spnt1->rmvbl? "": "NON-"), @@ -645,7 +671,7 @@ status = mknod ( TESTDEV, 0600 | S_IFBLK, makedev (spnt1->major, minor) ); - fd = open (TESTDEV, O_RDONLY); + fd = open (TESTDEV, O_RDONLY | O_NONBLOCK); unlink (TESTDEV); if (fd < 0) continue; // TO DO: Add sanity checks here ?? @@ -670,7 +696,7 @@ spnt1->next = reglist; reglist = spnt1; create_dev (spnt1); /* Check if device is there (i.e. medium inside) */ - fd = open (spnt1->name, O_RDONLY); + fd = open (spnt1->name, O_RDONLY | O_NONBLOCK); if (fd < 0) { /* Tapes are always accessible, as they are char devices */ fprintf (stderr, "Can't access tape %s, which should " @@ -706,6 +732,56 @@ return 0; } +int build_os_tape (sname * spnt, int no) +{ + int fd; int status; + sname * spnt1 = sname_dup (spnt); + spnt1->major = OSST_MAJOR; + spnt1->minor = no; + scsiname (spnt1); + spnt1->next = reglist; reglist = spnt1; + create_dev (spnt1); + /* Check if device is there (i.e. medium inside) */ + fd = open (spnt1->name, O_RDONLY | O_NONBLOCK); + if (fd < 0) { + /* OnStream tapes are NOT always accessible, as they have a heavy open() function */ + spnt1->unsafe = 1; + if (!quiet || !supp_rmvbl) + fprintf (stderr, "Can't access tape %s, which should " + "be equal to %s!\n", strrchr (spnt1->name, '/') + 1, + strrchr (spnt->name, '/') + 1); + if (supp_rmvbl) goto osst_force_success; + /* We don't unlink spnt1->name! Let sanitize take care of it ... */ + reglist = spnt1->next; free (spnt1->name); + spnt->related = 0; free (spnt1); + return 1; + } + /* Do a sanity check here */ + status = getscsiinfo (fd, spnt1); + close (fd); + if (status) fprintf (stderr, "scsidev: Strange: Could not get info from %s\n", + strrchr (spnt1->name, '/') + 1); + if (sname_cmp (spnt, spnt1)) + { + fprintf (stderr, "scsidev: What's going on? Dev %s is different from %s\n", + strrchr (spnt1->name, '/') + 1, strrchr (spnt->name, '/') + 1); + spnt -> related = 0; spnt1 -> related = 0; + /* And now ? */ + reglist = spnt1->next; free (spnt1->name); + spnt->related = 0; free (spnt1); + return 1; + } +osst_force_success: + /* And create the no-rewind alias */ + spnt1 = sname_dup (spnt1); + spnt1->minor |= 0x80; + scsiname (spnt1); + spnt1->next = reglist; reglist = spnt1; + create_dev (spnt1); + + return 0; +} + int build_cdrom (sname * spnt, int no) { int fd; int status; @@ -715,7 +791,7 @@ scsiname (spnt1); spnt1->next = reglist; reglist = spnt1; create_dev (spnt1); - fd = open (spnt1->name, O_RDONLY); + fd = open (spnt1->name, O_RDONLY | O_NONBLOCK); /* No access to medium / part. table */ if (fd < 0) { spnt1->unsafe = 1; @@ -814,9 +890,17 @@ if (!build_disk (spnt, disks)) disks++; else if (!build_disk (spnt, disks+1)) disks += 2; break; - case TYPE_TAPE: - if (!build_tape (spnt, tapes)) tapes++; - else if (!build_tape (spnt, tapes+1)) tapes += 2; + case TYPE_TAPE: + if (OSST_SUPPORTS(spnt)) + { + if (!build_os_tape (spnt, tapes)) tapes++; + else if (!build_os_tape (spnt, tapes+1)) tapes += 2; + } + else + { + if (!build_tape (spnt, tapes)) tapes++; + else if (!build_tape (spnt, tapes+1)) tapes += 2; + } break; case TYPE_ROM: case TYPE_WORM: @@ -1046,7 +1130,7 @@ * SERIAL_NUMBER="string" (for those devices that support this). * REV="string" * NAME="string" (alias) - * DEVTYPE="disk", "tape", "generic", or "cdrom". + * DEVTYPE="disk", "tape", "osst", "generic", or "cdrom". */ void build_special () @@ -1196,6 +1280,8 @@ devtype_i = SCSI_CDROM_MAJOR; else if( strcmp(devtype, "tape") == 0) devtype_i = SCSI_TAPE_MAJOR; + else if( strcmp(devtype, "osst") == 0) + devtype_i = OSST_MAJOR; else if(strcmp(devtype, "generic") == 0 ) devtype_i = SCSI_GENERIC_MAJOR; else @@ -1226,7 +1312,7 @@ (devtype_i != SCSI_DISK0_MAJOR || ! SCSI_DISK_MAJOR(spnt->major)) ) continue; if( part != spnt->partition ) continue; - if( spnt->major == SCSI_TAPE_MAJOR + if( (spnt->major == SCSI_TAPE_MAJOR || spnt->major == OSST_MAJOR) && (spnt->minor & 0x80) != 0) continue; /* @@ -1315,7 +1401,7 @@ update_device (scsidev, type, match->major, match->minor); - if( devtype_i == SCSI_TAPE_MAJOR ) + if( devtype_i == SCSI_TAPE_MAJOR || devtype_i == OSST_MAJOR ) { sprintf (scsidev, DEVSCSI "/n%s", name); register_dev (scsidev, match->major, match->minor | 0x80,