1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
diff -ur cdrdao-1.2.2.orig/dao/main.cc cdrdao-1.2.2/dao/main.cc
--- cdrdao-1.2.2.orig/dao/main.cc 2006-09-19 12:07:11.000000000 +0300
+++ cdrdao-1.2.2/dao/main.cc 2008-06-10 20:57:36.000000000 +0300
@@ -2027,6 +2027,8 @@
}
if (src == dst) {
+ // unlock src to make swaping possible
+ src->preventMediumRemoval(0);
message(0, "Please insert a recordable medium and hit enter.");
getc(stdin);
}
diff -ur cdrdao-1.2.2.orig/scsilib/libscg/scsi-linux-sg.c cdrdao-1.2.2/scsilib/libscg/scsi-linux-sg.c
--- cdrdao-1.2.2.orig/scsilib/libscg/scsi-linux-sg.c 2006-09-20 13:51:11.000000000 +0300
+++ cdrdao-1.2.2/scsilib/libscg/scsi-linux-sg.c 2008-06-10 20:57:36.000000000 +0300
@@ -225,6 +225,27 @@
#endif
LOCAL void sg_settimeout __PR((int f, int timeout));
+int sg_open_excl __PR((char *device, int mode));
+
+int
+sg_open_excl(device, mode)
+ char *device;
+ int mode;
+{
+ int f;
+ int i;
+ f = open(device, mode|O_EXCL);
+ for (i = 0; (i < 10) && (f == -1 && (errno == EACCES || errno == EBUSY)); i++) {
+ fprintf(stderr, "Error trying to open %s exclusively (%s)... retrying in 1 second.\n", device, strerror(errno));
+ usleep(1000000 + 100000.0 * rand()/(RAND_MAX+1.0));
+ f = open(device, mode|O_EXCL);
+ }
+ if (f == -1 && errno != EACCES && errno != EBUSY) {
+ f = open(device, mode);
+ }
+ return f;
+}
+
/*
* Return version information for the low level SCSI transport code.
* This has been introduced to make it easier to trace down problems
@@ -407,7 +428,7 @@
for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
devname = globbuf.gl_pathv[i];
- f = open(devname, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
if (f < 0) {
/*
* Set up error string but let us clear it later
@@ -458,7 +479,7 @@
for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
devname = globbuf.gl_pathv[i];
- f = open(devname, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
if (f < 0) {
/*
* Set up error string but let us clear it later
@@ -511,7 +532,7 @@
"Warning: Open by 'devname' is unintentional and not supported.\n");
}
/* O_NONBLOCK is dangerous */
- f = open(device, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(device, O_RDWR | O_NONBLOCK);
/* if (f < 0 && errno == ENOENT)*/
/* goto openpg;*/
|