~ubuntu-branches/ubuntu/intrepid/cdrdao/intrepid

« back to all changes in this revision

Viewing changes to debian/patches/05-excl.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-06-20 09:58:00 UTC
  • mfrom: (2.1.13 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080620095800-dus8dgw8xzcc520l
Tags: 1:1.2.2-16
* Updating cross build handling in rules.
* Change clean target definition in rules (Closes: #450752, #471224).
* Updating to standards 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh /usr/share/dpatch/dpatch-run
 
2
## 04-excl.dpatch
 
3
##
 
4
## DP: O_EXCL patch from cdrecord (Closes: #272646).
 
5
 
 
6
@DPATCH@
 
7
 
 
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
 
12
   }
 
13
 
 
14
   if (src == dst) {
 
15
+    // unlock src to make swaping possible
 
16
+    src->preventMediumRemoval(0);
 
17
     message(0, "Please insert a recordable medium and hit enter.");
 
18
     getc(stdin);
 
19
   }
 
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,
 
24
 #endif
 
25
 LOCAL  void    sg_settimeout   __PR((int f, int timeout));
 
26
 
 
27
+int    sg_open_excl    __PR((char *device, int mode));
 
28
+
 
29
+int
 
30
+sg_open_excl(device, mode)
 
31
+       char    *device;
 
32
+       int     mode;
 
33
+{
 
34
+       int f;
 
35
+       int i;
 
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);
 
41
+       }
 
42
+       if (f == -1 && errno != EACCES && errno != EBUSY) {
 
43
+           f = open(device, mode);
 
44
+       }
 
45
+       return f;
 
46
+}
 
47
+
 
48
 /*
 
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:
 
52
                
 
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);
 
57
                        if (f < 0) {
 
58
                                /*
 
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];
 
63
 
 
64
-                       f = open(devname, O_RDWR | O_NONBLOCK);
 
65
+                       f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
 
66
                        if (f < 0) {
 
67
                                /*
 
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");
 
71
                }
 
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)*/
 
76
 /*                     goto openpg;*/
 
77
 
 
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.
 
84
  */
 
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   */
 
89
+
 
90
 
 
91
 #define        DEFTIMEOUT      20      /* Default timeout for SCSI command transport */
 
92
 
 
93
@@ -137,7 +138,7 @@ scg_version(scgp, what)
 
94
                 * return "schily" for the SCG_AUTHOR request.
 
95
                 */
 
96
                case SCG_AUTHOR:
 
97
-                       return (_scg_auth_schily);
 
98
+                       return (_scg_auth_ubuntu);
 
99
                case SCG_SCCS_ID:
 
100
                        return (sccsid);
 
101
                default: