lkml.org 
[lkml]   [2000]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 2.2: Support O_NONBLOCK for SCSI disks
Unless I misunderstood Eric Youngdale's reply, he agrees that the
below patch is OK.

Index: drivers/scsi/sd.c
--- drivers/scsi/sd.c.prev
+++ drivers/scsi/sd.c Fri Jun 23 12:50:23 2000
@@ -151,34 +151,41 @@ static int sd_open(struct inode * inode,
* is being re-read.
*/
-
while (rscsi_disks[target].device->busy)
barrier();
- if(rscsi_disks[target].device->removable) {
+
+ /*
+ * When opening removable disks, we check media...
+ * ... unless media don't matter, due to O_NONBLOCK.
+ */
+ if ( rscsi_disks[target].device->removable
+ && !(filp->f_flags & O_NONBLOCK) )
+ {
+ /*
+ * Note disk change and/or removal.
+ * Also try to read new partition table (if any).
+ */
check_disk_change(inode->i_rdev);

- /*
- * If the drive is empty, just let the open fail.
- */
+ /*
+ * If the drive is empty, let the open fail.
+ */
if ( !rscsi_disks[target].ready )
- return -ENXIO;
+ return -ENXIO;

- /*
- * Similarly, if the device has the write protect tab set,
- * have the open fail if the user expects to be able to write
- * to the thing.
- */
- if ( (rscsi_disks[target].write_prot) && (filp->f_mode & 2) )
- return -EROFS;
+ /*
+ * If the device has the write protect tab set,
+ * let the open fail if the user expects to be able to write.
+ */
+ if ( (rscsi_disks[target].write_prot) && (filp->f_mode & 2) )
+ return -EROFS;
}

/*
- * It is possible that the disk changing stuff resulted in the device being taken
- * offline. If this is the case, report this to the user, and don't pretend that
- * the open actually succeeded.
+ * It is possible that the disk changing stuff (or something
+ * else?) resulted in the device being taken offline.
+ * If so, let the open fail.
*/
- if( !rscsi_disks[target].device->online )
- {
+ if ( !rscsi_disks[target].device->online )
return -ENXIO;
- }

/*
@@ -1069,5 +1076,4 @@ static int check_scsidisk_media_change(k
int target;
struct inode inode;
- int flag = 0;

target = DEVICE_NR(full_dev);
@@ -1121,9 +1127,9 @@ static int check_scsidisk_media_change(k
* struct and tested at open ! Daniel Roche ( dan@lectra.fr )
*/
-
rscsi_disks[target].ready = 1; /* FLOPTICAL */

retval = rscsi_disks[target].device->changed;
- if(!flag) rscsi_disks[target].device->changed = 0;
+ rscsi_disks[target].device->changed = 0;
+
return retval;
}
--
Chip Salzenberg - a.k.a. - <chip@valinux.com>
"I wanted to play hopscotch with the impenetrable mystery of existence,
but he stepped in a wormhole and had to go in early." // MST3K
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.026 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site