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