Index: VERSION =================================================================== RCS file: /home/cvsroot/scsidev/VERSION,v retrieving revision 1.8.2.12 retrieving revision 1.8.2.13 diff -u -p -r1.8.2.12 -r1.8.2.13 --- VERSION 10 Feb 2004 20:10:23 -0000 1.8.2.12 +++ VERSION 31 Mar 2004 14:42:12 -0000 1.8.2.13 @@ -1 +1 @@ -2.33 +2.34 Index: boot.scsidev =================================================================== RCS file: /home/cvsroot/scsidev/Attic/boot.scsidev,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -p -r1.1.2.5 -r1.1.2.6 --- boot.scsidev 27 Feb 2004 20:03:36 -0000 1.1.2.5 +++ boot.scsidev 31 Mar 2004 14:44:47 -0000 1.1.2.6 @@ -7,7 +7,8 @@ # ### BEGIN INIT INFO # Provides: boot.scsidev -# Required-Start: boot.proc +# Required-Start: boot.rootfsck +# Should-Start: noot.udev # Required-Stop: # Default-Start: B # Default-Stop: Index: scsidev.c =================================================================== RCS file: /home/cvsroot/scsidev/scsidev.c,v retrieving revision 1.28.2.45 retrieving revision 1.28.2.51 diff -u -p -r1.28.2.45 -r1.28.2.51 --- scsidev.c 26 Feb 2004 17:00:16 -0000 1.28.2.45 +++ scsidev.c 31 Mar 2004 14:47:17 -0000 1.28.2.51 @@ -176,6 +176,18 @@ * - Increase max length of hostname from 64 to 160. (Wolfgang Celeda) * -> 2.33 * + * * 2004-03-08: Kurt Garloff : + * - + * + * + * * 2004-03-22: Kurt Garloff : + * - Allow to switch off sysfs for debugging (-y) + * * 2004-03-31: Kurt Garloff : + * - Make sure /dev/scsi/testdev is removed always. + * - Don't overwrite scsi device type when getting serial no. etc. in + * fill_in_proc() + * -> 2.34. + * * TODO: other char devices * */ @@ -198,7 +210,7 @@ #include #include -static char rcsid[] ="$Id: scsidev.c,v 1.28.2.45 2004/02/26 17:00:16 garloff Exp $"; +static char rcsid[] ="$Id: scsidev.c,v 1.28.2.51 2004/03/31 14:47:17 garloff Exp $"; static char *versid = "scsidev " VERSION " 2004-02-09"; static char *copyright = "Copyright: GNU GPL (see file COPYING)\n" \ " (w) 1994--1997 Eric Youngdale \n"\ @@ -232,6 +244,7 @@ int force = 0; int san_del = 0; int no_san = 0; int no_procscsi = 0; +int no_sysfs = 0; int nm_cbtu = 0; int supp_rmvbl = 0; int supp_multi = 0; @@ -1076,15 +1089,18 @@ void findscsidisk(sname * spnt, int no) printf("Findscsidisk: %d\n",no); /* only search up to 16 devices may be a bad assumption, but scanning * the whole list could take a long time */ + unlink (TESTDEV); for (i = no; i < no+16; ++i) { major = disknum_to_sd_major (i); minor = (i << 4) & ~0x0f; - unlink (TESTDEV); status = mknod (TESTDEV, 0600 | S_IFBLK, makedev (major, minor)); fd = open (TESTDEV, O_RDONLY); + unlink (TESTDEV); + if (fd < 0) + continue; res = ioctl (fd, SCSI_IOCTL_GET_IDLUN, id); if (res < 0) continue; @@ -1093,8 +1109,6 @@ void findscsidisk(sname * spnt, int no) channel = (id[0] >> 16) & 0xff; lun = (id[0] >> 8 ) & 0xff; scsi_id = id[0] & 0xff; - - unlink (TESTDEV); if (verbose >= 2) printf ("Scanning: %d==%d %d==%d %d==%d %d==%d \n", @@ -1110,7 +1124,7 @@ void findscsidisk(sname * spnt, int no) } } /* If we did not find a match, return a good guess.. */ - unlink (TESTDEV); + //unlink (TESTDEV); spnt->major = disknum_to_sd_major (no); spnt->minor = (no << 4) & ~0x0f; } @@ -1807,9 +1821,12 @@ void fill_in_proc (sname * spnt) spnt->hostname = strdup (spnt->shorthostname); if (!spnt->hostid) spnt->hostid = find_ioport (spnt->shorthostname); - - spnt->devtp = inq_devtp_to_devtp (spnt->inq_devtp, spnt); + /* Don't overwrite device type! It should have been filled correctly + * and with matching major/minor before. */ + // spnt->devtp = inq_devtp_to_devtp (spnt->inq_devtp, spnt);/ + + unlink(TESTDEV); fd = mknod (TESTDEV, 0600 | (isblk(spnt->devtp)? S_IFBLK: S_IFCHR), makedev (spnt->major, spnt->minor)); if (fd) { @@ -1818,11 +1835,14 @@ void fill_in_proc (sname * spnt) return; } fd = open (TESTDEV, O_RDWR | O_NONBLOCK); + unlink (TESTDEV); if (fd == -1) { - perror("open"); + char buf[64]; + sprintf(buf, "open %s %03x:%05x", + isblk(spnt->devtp)? "b": "c", spnt->major, spnt->minor); + perror(buf); return; } - unlink (TESTDEV); inquiry (fd, spnt); get_hsv_os_id(fd, spnt); close (fd); @@ -1835,6 +1855,7 @@ void fill_in_sg (sname * spnt) int status; int fd; errno = 0; + unlink (TESTDEV); status = mknod (TESTDEV, 0600 | S_IFCHR, makedev (spnt->major, spnt->minor)); if (status) { @@ -2037,9 +2058,6 @@ void build_sgdevlist_procscsi () } fclose (scsifile); - /* Now, we need to make sure all high-level modules are loaded */ - trigger_module_loads (); - scsifile = fopen (PROCSCSI, "r"); /* parse /proc/scsi */ while (!feof (scsifile)) { @@ -2231,8 +2249,10 @@ int main (int argc, char * argv[]) fprintf(stderr, DEVSCSI " either does not exist, or is not a directory\n"); exit(0); } - while ((c = getopt(argc, argv, "pflLvqshnderoMm:c:A:")) != -1) { + while ((c = getopt(argc, argv, "ypflLvqshnderoMm:c:A:")) != -1) { switch (c) { + case 'y': + no_sysfs = 1; break; case 'p': no_procscsi = 1; break; case 'f': @@ -2275,6 +2295,10 @@ int main (int argc, char * argv[]) if( verbose >= 1 ) fprintf( stderr, "%s\n", versid ); + + /* Now, we need to make sure all high-level modules are loaded */ + trigger_module_loads (); + if( force ) flush_sdev (); @@ -2291,7 +2315,7 @@ int main (int argc, char * argv[]) register_dev("/dev/scsi/rsth4-334c0i5l0", 9,128, ST, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); #else if (no_procscsi || try_procscsi ()) { - if (find_sysfs ()) { + if (no_sysfs || find_sysfs ()) { if (!quiet) fprintf (stderr, "/proc/scsi/scsi extensions not found. Fall back to scanning.\n"); build_sgdevlist ();