Index: VERSION =================================================================== RCS file: /home/cvsroot/scsidev/VERSION,v retrieving revision 1.8.2.3 retrieving revision 1.8.2.4 diff -u -r1.8.2.3 -r1.8.2.4 --- VERSION 2002/07/29 15:48:00 1.8.2.3 +++ VERSION 2002/08/07 07:49:36 1.8.2.4 @@ -1 +1 @@ -2.25 +2.26 Index: scsidev.c =================================================================== RCS file: /home/cvsroot/scsidev/scsidev.c,v retrieving revision 1.28.2.17 retrieving revision 1.28.2.18 diff -u -r1.28.2.17 -r1.28.2.18 --- scsidev.c 2002/07/29 23:56:28 1.28.2.17 +++ scsidev.c 2002/08/07 07:49:36 1.28.2.18 @@ -91,6 +91,11 @@ * underlying real dev node now. * -> 2.25 * + * * 2002/08/07: Kurt Garloff + * - Fix segfault for failed inquiries + * - Explicitly set alias device types (could be wrong) + * - Check blk vs. chr devtype when updating dev node + * -> 2.26 */ #include @@ -111,7 +116,7 @@ #include -static char rcsid[] ="$Id: scsidev.c,v 1.28.2.17 2002/07/29 23:56:28 garloff Exp $"; +static char rcsid[] ="$Id: scsidev.c,v 1.28.2.18 2002/08/07 07:49:36 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"\ @@ -321,7 +326,7 @@ } /// Used for alias registration -sname * register_dev (char * name, int major, int minor, +sname * register_dev (char * name, int major, int minor, enum devtype_t devtp, int hnum, int hid, int chan, int id, int lun, int part, char * hostname, char* oldname, sname * alias, sname * rel) @@ -341,6 +346,7 @@ } spnt->major = major; spnt->minor = minor; + spnt->devtp = devtp; spnt->hostnum = hnum; spnt->hostid = hid; spnt->chan = chan; @@ -661,6 +667,8 @@ ++recreate; else if (statbuf.st_rdev != makedev (major, minor)) ++recreate; + else if ((statbuf.st_mode & S_IFMT) != (fmode & S_IFMT)) + ++recreate; /* Don't test permissions here, just set them later */ if (recreate) { if (!status) @@ -929,14 +937,6 @@ oldscsiname (spnt); return status; -#if 0 - spnt = register_dev (scsidev, major, minor, - h_id, id[1], chan, scsi_id, lun, -1, hostname, 0, NULL, NULL); - create_dev (spnt, use_symlink); - if (!quiet) printf ("Found %s (Type %02x) %c on %s \n", scsidev, - spnt->inq_devtp, (spnt->rmvbl? 'R' : ' '), - hostname); -#endif } int build_disk (sname * spnt, int no) @@ -1916,16 +1916,16 @@ flush_sdev (); #ifdef DEBUG - register_dev("/dev/scsi/sdh4-334c0i0l0", 8, 0, 6, 0x334, 0, 0, 0, -1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sdh4-334c0i0l0p1",8, 1, 6, 0x334, 0, 0, 0, 1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sdh4-334c0i0l0p2",8, 2, 6, 0x334, 0, 0, 0, 2, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sdh4-334c0i0l0p3",8, 3, 6, 0x334, 0, 0, 0, 3, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sgh4-334c0i0l0", 21, 0, 6, 0x334, 0, 0, 0, -1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sgh4-334c0i2l0", 21, 1, 6, 0x334, 0, 2, 0, -1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sgh4-334c0i5l0", 21, 2, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/srh4-334c0i2l0", 11, 0, 6, 0x334, 0, 2, 0, -1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/sth4-334c0i5l0", 9, 0, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); - register_dev("/dev/scsi/rsth4-334c0i5l0", 9,128, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sdh4-334c0i0l0", 8, 0, SD, 6, 0x334, 0, 0, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sdh4-334c0i0l0p1",8, 1, SD, 6, 0x334, 0, 0, 0, 1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sdh4-334c0i0l0p2",8, 2, SD, 6, 0x334, 0, 0, 0, 2, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sdh4-334c0i0l0p3",8, 3, SD, 6, 0x334, 0, 0, 0, 3, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sgh4-334c0i0l0", 21, 0, SG, 6, 0x334, 0, 0, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sgh4-334c0i2l0", 21, 1, SG, 6, 0x334, 0, 2, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sgh4-334c0i5l0", 21, 2, SG, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/srh4-334c0i2l0", 11, 0, SR, 6, 0x334, 0, 2, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/sth4-334c0i5l0", 9, 0, ST, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); + register_dev("/dev/scsi/rsth4-334c0i5l0", 9,128, ST, 6, 0x334, 0, 5, 0, -1, "debug", 0, NULL, NULL); #else if (try_procscsi ()) { if (!quiet) @@ -2132,7 +2132,6 @@ char * pnt1; sname * spnt, * spnt1, *match; char scsidev[64]; - int type; int lun, chan, id, part, hostid, hostnum; int line; @@ -2362,15 +2361,13 @@ fprintf (stderr, "\n"); } - type = isblk (match->devtp)? S_IFBLK: S_IFCHR; - /* * If this is just an ordinary single device type, * Just create it. */ sprintf (scsidev, DEVSCSI "/%s", name); spnt1 = register_dev (scsidev, match->major, match->minor, - match->hostnum, match->hostid, + match->devtp, match->hostnum, match->hostid, match->chan, match->id, match->lun, 0, match->hostname, match->name, match, 0); create_dev (spnt1, symlink_alias); @@ -2383,9 +2380,9 @@ sprintf (scsidev, DEVSCSI "/n%s", name); spnt1 = register_dev (scsidev, match->major, match->minor | 0x80, - match->hostnum, match->hostid, - match->chan, match->id, match->lun, 0, - match->hostname, nm2, match, spnt1); + match->devtp, match->hostnum, match->hostid, + match->chan, match->id, match->lun, 0, + match->hostname, nm2, match, spnt1); create_dev (spnt1, symlink_alias); } @@ -2411,8 +2408,8 @@ sprintf(scsidev, DEVSCSI "/%s-p%d", name, spnt->partition); - spnt2 = register_dev (scsidev, match->major, spnt->minor, - match->hostnum, match->hostid, + spnt2 = register_dev (scsidev, match->major, spnt->minor, + match->devtp, match->hostnum, match->hostid, match->chan, match->id, match->lun, spnt->partition, match->hostname, spnt->name, spnt, spnt1); create_dev (spnt2, symlink_alias); @@ -2532,8 +2529,10 @@ int ln; int off; int lun; int ansi; + spnt->wwid = no_wwid; spnt->serial = no_serial; //infile = open(spnt->name, O_RDWR); - if( infile == -1 ) return -1; + if (infile == -1) + return -1; // Std. inquiry status = get_inq_page (infile, 0, buffer, 0, 0); @@ -2550,7 +2549,6 @@ spnt->rev = getstr (pagestart, 32, 35); spnt->inq_devtp = pagestart[0] & 0x1f; spnt->rmvbl = (pagestart[1] & 0x80) >> 7; - spnt->wwid = no_wwid; spnt->serial = no_serial; ansi = pagestart[2] & 7; if (ansi >= 3)