1
#!/bin/sh /usr/share/dpatch/dpatch-run
4
## DP: O_EXCL patch from cdrecord (Closes: #272646).
8
diff -Naurp cdrdao-1.2.2.orig/dao/main.cc cdrdao-1.2.2/dao/main.cc
9
--- cdrdao-1.2.2.orig/dao/main.cc 2006-09-19 09:07:11.000000000 +0000
10
+++ cdrdao-1.2.2/dao/main.cc 2007-09-04 20:25:20.000000000 +0000
11
@@ -2027,6 +2027,8 @@ static int copyCd(CdrDriver *src, CdrDri
15
+ // unlock src to make swaping possible
16
+ src->preventMediumRemoval(0);
17
message(0, "Please insert a recordable medium and hit enter.");
20
diff -Naurp cdrdao-1.2.2.orig/scsilib/libscg/scsi-linux-sg.c cdrdao-1.2.2/scsilib/libscg/scsi-linux-sg.c
21
--- cdrdao-1.2.2.orig/scsilib/libscg/scsi-linux-sg.c 2006-09-20 10:51:11.000000000 +0000
22
+++ cdrdao-1.2.2/scsilib/libscg/scsi-linux-sg.c 2007-09-04 20:25:20.000000000 +0000
23
@@ -225,6 +225,27 @@ LOCAL long sg_raisedma __PR((SCSI *scgp,
25
LOCAL void sg_settimeout __PR((int f, int timeout));
27
+int sg_open_excl __PR((char *device, int mode));
30
+sg_open_excl(device, mode)
36
+ f = open(device, mode|O_EXCL);
37
+ for (i = 0; (i < 10) && (f == -1 && (errno == EACCES || errno == EBUSY)); i++) {
38
+ fprintf(stderr, "Error trying to open %s exclusively (%s)... retrying in 1 second.\n", device, strerror(errno));
39
+ usleep(1000000 + 100000.0 * rand()/(RAND_MAX+1.0));
40
+ f = open(device, mode|O_EXCL);
42
+ if (f == -1 && errno != EACCES && errno != EBUSY) {
43
+ f = open(device, mode);
49
* Return version information for the low level SCSI transport code.
50
* This has been introduced to make it easier to trace down problems
51
@@ -407,7 +428,7 @@ scanopen:
53
for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
54
devname = globbuf.gl_pathv[i];
55
- f = open(devname, O_RDWR | O_NONBLOCK);
56
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
59
* Set up error string but let us clear it later
60
@@ -458,7 +479,7 @@ scanopen:
61
for (i = 0; globbuf.gl_pathv && globbuf.gl_pathv[i] != NULL ; i++) {
62
devname = globbuf.gl_pathv[i];
64
- f = open(devname, O_RDWR | O_NONBLOCK);
65
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
68
* Set up error string but let us clear it later
69
@@ -511,7 +532,7 @@ openbydev:
70
"Warning: Open by 'devname' is unintentional and not supported.\n");
72
/* O_NONBLOCK is dangerous */
73
- f = open(device, O_RDWR | O_NONBLOCK);
74
+ f = sg_open_excl(device, O_RDWR | O_NONBLOCK);
75
/* if (f < 0 && errno == ENOENT)*/
78
diff -Naurp cdrdao-1.2.2.orig/scsilib/libscg/scsitransp.c cdrdao-1.2.2/scsilib/libscg/scsitransp.c
79
--- cdrdao-1.2.2.orig/scsilib/libscg/scsitransp.c 2004-06-17 20:20:27.000000000 +0000
80
+++ cdrdao-1.2.2/scsilib/libscg/scsitransp.c 2007-09-04 20:25:20.000000000 +0000
81
@@ -52,8 +52,9 @@ static char sccsid[] =
82
* Choose your name instead of "schily" and make clear that the version
83
* string is related to a modified source.
85
-LOCAL char _scg_version[] = "0.8"; /* The global libscg version */
86
-LOCAL char _scg_auth_schily[] = "schily"; /* The author for this module */
87
+LOCAL char _scg_version[] = "0.8ubuntu1"; /* The global libscg version */
88
+LOCAL char _scg_auth_ubuntu[] = "ubuntu"; /* The author for this module */
91
#define DEFTIMEOUT 20 /* Default timeout for SCSI command transport */
93
@@ -137,7 +138,7 @@ scg_version(scgp, what)
94
* return "schily" for the SCG_AUTHOR request.
97
- return (_scg_auth_schily);
98
+ return (_scg_auth_ubuntu);