104 lines
3.0 KiB
Diff
104 lines
3.0 KiB
Diff
|
--- cdrtools-2.01/scsilib/libscg/oexcl.c.excl 2004-09-22 12:03:23.426676328 +0200
|
||
|
+++ cdrtools-2.01/scsilib/libscg/oexcl.c 2004-09-22 12:03:23.426676328 +0200
|
||
|
@@ -0,0 +1,29 @@
|
||
|
+#include <stdlib.h>
|
||
|
+#include <unistd.h>
|
||
|
+#include <sys/types.h>
|
||
|
+#include <sys/stat.h>
|
||
|
+#include <fcntl.h>
|
||
|
+#include <stdio.h>
|
||
|
+
|
||
|
+int openexcl(const char *device, int mode)
|
||
|
+{
|
||
|
+ int f, i;
|
||
|
+
|
||
|
+ f = open(device, mode | O_EXCL);
|
||
|
+
|
||
|
+ if (f < 0) {
|
||
|
+ f = open(device, mode);
|
||
|
+
|
||
|
+ if (f >= 0) {
|
||
|
+ close(f);
|
||
|
+ f = -1;
|
||
|
+ for (i = 0; (i < 10) && (f == -1); i++) {
|
||
|
+ fprintf(stderr, "Error trying to open %s exclusively ... retrying in 1 second.\n", device);
|
||
|
+ usleep(1000000 + 100000.0 * rand()/(RAND_MAX+1.0));
|
||
|
+ f = open(device, O_RDONLY | O_NONBLOCK | O_EXCL);
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ return f;
|
||
|
+}
|
||
|
--- cdrtools-2.01/scsilib/libscg/scsi-linux-ata.c.excl 2004-09-22 12:03:23.423676784 +0200
|
||
|
+++ cdrtools-2.01/scsilib/libscg/scsi-linux-ata.c 2004-09-22 12:03:23.427676176 +0200
|
||
|
@@ -112,6 +112,7 @@
|
||
|
LOCAL void sglog __PR((const char *fmt, ...));
|
||
|
|
||
|
#include <vadefs.h>
|
||
|
+#include "oexcl.h"
|
||
|
|
||
|
/* VARARGS1 */
|
||
|
#ifdef PROTOTYPES
|
||
|
@@ -267,7 +268,7 @@
|
||
|
starget,
|
||
|
slun;
|
||
|
|
||
|
- f = open(device, O_RDWR | O_NONBLOCK);
|
||
|
+ f = openexcl(device, O_RDWR | O_NONBLOCK);
|
||
|
|
||
|
if (f < 0) {
|
||
|
if (scgp->errstr)
|
||
|
--- cdrtools-2.01/scsilib/libscg/oexcl.h.excl 2004-09-22 12:03:23.428676024 +0200
|
||
|
+++ cdrtools-2.01/scsilib/libscg/oexcl.h 2004-09-22 12:03:23.428676024 +0200
|
||
|
@@ -0,0 +1,5 @@
|
||
|
+#ifndef OEXCL_H
|
||
|
+
|
||
|
+extern int openexcl(const char *device, int mode);
|
||
|
+
|
||
|
+#endif
|
||
|
--- cdrtools-2.01/scsilib/libscg/Targets.excl 2002-10-19 20:33:37.000000000 +0200
|
||
|
+++ cdrtools-2.01/scsilib/libscg/Targets 2004-09-22 12:03:23.428676024 +0200
|
||
|
@@ -1,3 +1,3 @@
|
||
|
CFILES= scsitransp.c scsihack.c scsiopen.c scgsettarget.c \
|
||
|
- scsierrs.c scgtimes.c scsihelp.c \
|
||
|
+ scsierrs.c scgtimes.c scsihelp.c oexcl.c \
|
||
|
rdummy.c
|
||
|
--- cdrtools-2.01/scsilib/libscg/scsi-linux-sg.c.excl 2004-09-22 12:03:23.422676936 +0200
|
||
|
+++ cdrtools-2.01/scsilib/libscg/scsi-linux-sg.c 2004-09-22 12:12:49.271654816 +0200
|
||
|
@@ -79,6 +79,7 @@
|
||
|
#endif
|
||
|
|
||
|
#include "scsi/sg.h"
|
||
|
+#include "oexcl.h"
|
||
|
|
||
|
#undef sense /* conflict in struct cdrom_generic_command */
|
||
|
#include <linux/cdrom.h>
|
||
|
@@ -94,7 +95,7 @@
|
||
|
* Choose your name instead of "schily" and make clear that the version
|
||
|
* string is related to a modified source.
|
||
|
*/
|
||
|
-LOCAL char _scg_trans_version[] = "scsi-linux-sg.c-1.83"; /* The version for this transport*/
|
||
|
+LOCAL char _scg_trans_version[] = "scsi-linux-sg.c-1.83-RH"; /* The version for this transport*/
|
||
|
|
||
|
#ifndef SCSI_IOCTL_GET_BUS_NUMBER
|
||
|
#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
|
||
|
@@ -247,7 +249,7 @@
|
||
|
* return "schily" for the SCG_AUTHOR request.
|
||
|
*/
|
||
|
case SCG_AUTHOR:
|
||
|
- return (_scg_auth_schily);
|
||
|
+ return ("schily - Red Hat");
|
||
|
case SCG_SCCS_ID:
|
||
|
return (__sccsid);
|
||
|
case SCG_KVERSION:
|
||
|
@@ -479,7 +483,7 @@
|
||
|
b = -1;
|
||
|
}
|
||
|
/* O_NONBLOCK is dangerous */
|
||
|
- f = open(device, O_RDWR | O_NONBLOCK);
|
||
|
+ f = openexcl(device, O_RDWR | O_NONBLOCK);
|
||
|
/* if (f < 0 && errno == ENOENT)*/
|
||
|
/* goto openpg;*/
|
||
|
|