Wojtek Pilorz reported: >I have just compiled cdrtools 1.11a38 on my system (RedHat Linux 6.2, >Linux kernel 2.2.19+IDE patches), and cdrecord seems to always respond >with 'Resource temporarily unavailable. Cannot send SCSI cmd via ioctl'; >even -scanbus does not work; Introducing important (even if small) changes short before a major release date never is good. It seems that it was a bad idea to trust Linus Torvalds when incorporating a patch send by him.... he just does not know enough about constraints of the Linux SCSI driver system :-( Here is a patch that tries to work around the problems. Please test and report. If it does not work for all of you, I will need to remove the patch from Linus completely. ------- scsi-linux-sg.c ------- *** /tmp/da004wW Thu Jan 1 01:00:00 1970 --- scsi-linux-sg.c Sun Oct 20 14:15:08 2002 *************** *** 186,191 **** --- 186,192 ---- #ifdef SG_IO LOCAL int sg_rwsend __PR((SCSI *scgp)); #endif + LOCAL void sg_clearnblock __PR((int f)); LOCAL BOOL sg_setup __PR((SCSI *scgp, int f, int busno, int tgt, int tlun)); LOCAL void sg_initdev __PR((SCSI *scgp, int f)); LOCAL int sg_mapbus __PR((SCSI *scgp, int busno, int ino)); *************** *** 325,330 **** --- 326,332 ---- for (i=0; i < 32; i++) { js_snprintf(devname, sizeof(devname), "/dev/sg%d", i); + /* O_NONBLOCK is dangerous */ f = open(devname, O_RDWR | O_NONBLOCK); if (f < 0) { /* *************** *** 341,346 **** --- 343,349 ---- return (0); } } else { + sg_clearnblock(f); /* Be very proper about this */ if (sg_setup(scgp, f, busno, tgt, tlun)) return (++nopen); if (busno < 0 && tgt < 0 && tlun < 0) *************** *** 352,357 **** --- 355,361 ---- if (nopen == 0) for (i=0; i <= 25; i++) { js_snprintf(devname, sizeof(devname), "/dev/sg%c", i+'a'); + /* O_NONBLOCK is dangerous */ f = open(devname, O_RDWR | O_NONBLOCK); if (f < 0) { /* *************** *** 368,373 **** --- 372,378 ---- return (0); } } else { + sg_clearnblock(f); /* Be very proper about this */ if (sg_setup(scgp, f, busno, tgt, tlun)) return (++nopen); if (busno < 0 && tgt < 0 && tlun < 0) *************** *** 383,388 **** --- 388,394 ---- js_fprintf((FILE *)scgp->errfile, "Warning: Open by 'devname' is unintentional and not supported.\n"); } + /* O_NONBLOCK is dangerous */ f = open(device, O_RDWR | O_NONBLOCK); /* if (f < 0 && errno == ENOENT)*/ /* goto openpg;*/ *************** *** 400,405 **** --- 406,412 ---- return (0); } + sg_clearnblock(f); /* Be very proper about this */ if (!sg_mapdev(scgp, f, &busno, &tgt, &tlun, 0, 0)) { close(f); /* *************** *** 476,481 **** --- 483,507 ---- pg_close(scgp); #endif return (0); + } + + /* + * The Linux kernel becomes more and more unmaintainable. + * Every year, a new incompatible SCSI transport interface is introduced. + * Each of them has it's own contradictory constraints. + * While you cannot have O_NONBLOCK set during operation, at leat one + * of the drivers requires O_NONBLOCK to be set during open(). + * This is used to clear O_NONBLOCK immediately after open() succeeded. + */ + LOCAL void + sg_clearnblock(f) + int f; + { + int n; + + n = fcntl(f, F_GETFL); + n &= ~O_NONBLOCK; + fcntl(f, F_SETFL, n); } LOCAL BOOL Jörg EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js@cs.tu-berlin.de (uni) If you don't have iso-8859-1 schilling@fokus.gmd.de (work) chars I am J"org Schilling URL: http://www.fokus.gmd.de/usr/schilling ftp://ftp.fokus.gmd.de/pub/unix _______________________________________________ Cdrecord-support mailing list Cdrecord-support@lists.berlios.de http://lists.berlios.de/mailman/listinfo/cdrecord-support