* [PATCH] sg O_EXCL on open() lk 2.6.0-test9
@ 2003-11-16 22:30 Douglas Gilbert
0 siblings, 0 replies; only message in thread
From: Douglas Gilbert @ 2003-11-16 22:30 UTC (permalink / raw)
To: linux-scsi
[-- Attachment #1: Type: text/plain, Size: 213 bytes --]
While on the subject of bugs in sg, one came
to light recently (only in lk 2.6, not lk 2.4).
Changelog:
When detecting a locked sg device (O_EXCL) return
-EBUSY (rather than 0) from sg_open()
Doug Gilbert
[-- Attachment #2: sg290t9ma.diff --]
[-- Type: text/plain, Size: 1029 bytes --]
--- linux/drivers/scsi/sg.c 2003-10-28 09:18:32.000000000 +1000
+++ linux/drivers/scsi/sg.c260t9ma 2003-11-14 20:15:20.000000000 +1000
@@ -243,7 +243,7 @@
Sg_device *sdp;
Sg_fd *sfp;
int res;
- int retval = -EBUSY;
+ int retval;
SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags));
sdp = sg_get_dev(dev);
@@ -270,8 +270,10 @@
retval = -EPERM; /* Can't lock it with read only access */
goto error_out;
}
- if (sdp->headfp && (flags & O_NONBLOCK))
+ if (sdp->headfp && (flags & O_NONBLOCK)) {
+ retval = -EBUSY;
goto error_out;
+ }
res = 0;
__wait_event_interruptible(sdp->o_excl_wait,
((sdp->headfp || sdp->exclude) ? 0 : (sdp->exclude = 1)), res);
@@ -280,8 +282,10 @@
goto error_out;
}
} else if (sdp->exclude) { /* some other fd has an exclusive lock on dev */
- if (flags & O_NONBLOCK)
+ if (flags & O_NONBLOCK) {
+ retval = -EBUSY;
goto error_out;
+ }
res = 0;
__wait_event_interruptible(sdp->o_excl_wait, (!sdp->exclude),
res);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-11-16 22:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-16 22:30 [PATCH] sg O_EXCL on open() lk 2.6.0-test9 Douglas Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).