/[debburn]/mods-archive/23_o_excl.dpatch
ViewVC logotype

Contents of /mods-archive/23_o_excl.dpatch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 224 - (hide annotations) (download)
Tue Sep 5 19:18:45 2006 UTC (6 years, 9 months ago) by blade
File size: 5619 byte(s)
Parked the mods archive outside of the trunk
1 blade 41 #! /bin/sh -e
2     ## 20_open_excl.dpatch by <mpitt@debian.org>
3     ##
4     ## All lines beginning with `## DP:' are a description of the patch.
5     ## DP: No description.
6    
7     if [ $# -lt 1 ]; then
8     echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
9     exit 1
10     fi
11    
12     [ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
13     patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
14    
15     case "$1" in
16     -patch) patch -p1 ${patch_opts} < $0;;
17     -unpatch) patch -R -p1 ${patch_opts} < $0;;
18     *)
19     echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
20     exit 1;;
21     esac
22    
23     exit 0
24    
25     @DPATCH@
26     diff -urNad /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsi-linux-ata.c cdrtools-2.0+a30.pre1/libscg/scsi-linux-ata.c
27     --- /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsi-linux-ata.c 2004-10-19 13:19:33.943939128 +0200
28     +++ cdrtools-2.0+a30.pre1/libscg/scsi-linux-ata.c 2004-10-19 13:22:09.099351920 +0200
29     @@ -267,7 +267,7 @@
30     starget,
31     slun;
32    
33     - f = open(device, O_RDONLY | O_NONBLOCK);
34     + f = sg_open_excl(device, O_RDONLY | O_NONBLOCK);
35    
36     if (f < 0) {
37     if (scgp->errstr)
38     diff -urNad /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsi-linux-pg.c cdrtools-2.0+a30.pre1/libscg/scsi-linux-pg.c
39     --- /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsi-linux-pg.c 2004-10-19 13:19:33.945938824 +0200
40     +++ cdrtools-2.0+a30.pre1/libscg/scsi-linux-pg.c 2004-10-19 13:20:44.774171296 +0200
41     @@ -207,7 +207,7 @@
42     return (0);
43     #endif
44     js_snprintf(devname, sizeof (devname), "/dev/pg%d", tgt);
45     - f = open(devname, O_RDWR | O_NONBLOCK);
46     + f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
47     if (f < 0) {
48     if (scgp->errstr)
49     js_snprintf(scgp->errstr, SCSI_ERRSTR_SIZE,
50     @@ -220,7 +220,7 @@
51     tlun = 0;
52     for (tgt = 0; tgt < MAX_TGT; tgt++) {
53     js_snprintf(devname, sizeof (devname), "/dev/pg%d", tgt);
54     - f = open(devname, O_RDWR | O_NONBLOCK);
55     + f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
56     if (f < 0) {
57     /*
58     * Set up error string but let us clear it later
59     diff -urNad /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsi-linux-sg.c cdrtools-2.0+a30.pre1/libscg/scsi-linux-sg.c
60     --- /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsi-linux-sg.c 2004-10-19 13:20:42.774475296 +0200
61     +++ cdrtools-2.0+a30.pre1/libscg/scsi-linux-sg.c 2004-10-19 13:20:44.777170840 +0200
62     @@ -217,6 +217,28 @@
63     #endif
64     LOCAL void sg_settimeout __PR((int f, int timeout));
65    
66     +int sg_open_excl __PR((char *device, int mode));
67     +
68     +int
69     +sg_open_excl(device, mode)
70     + char *device;
71     + int mode;
72     +{
73     + int f;
74     + int i;
75     + f = open(device, mode|O_EXCL);
76     + for (i = 0; (i < 10) && (f == -1 && (errno == EACCES || errno == EBUSY)); i++) {
77     + fprintf(stderr, "Error trying to open %s exclusively (%s)... retrying in 1 second.\n", device, strerror(errno));
78     + usleep(1000000 + 100000.0 * rand()/(RAND_MAX+1.0));
79     + f = open(device, mode|O_EXCL);
80     + }
81     + if (f == -1 && errno != EACCES && errno != EBUSY) {
82     + f = open(device, mode);
83     + }
84     + return f;
85     +}
86     +
87     +
88     /*
89     * Return version information for the low level SCSI transport code.
90     * This has been introduced to make it easier to trace down problems
91     @@ -375,7 +397,7 @@
92     if (use_ata) for (i=2*busno+tgt >= 0 ? 2*busno+tgt:0; i <= 25; i++) {
93     js_snprintf(devname, sizeof (devname), "/dev/hd%c", i+'a');
94     /* O_NONBLOCK is dangerous */
95     - f = open(devname, O_RDWR | O_NONBLOCK);
96     + f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
97     if (f < 0) {
98     /*
99     * Set up error string but let us clear it later
100     @@ -415,7 +437,7 @@
101     if (nopen == 0) for (i = 0; i < 32; i++) {
102     js_snprintf(devname, sizeof (devname), "/dev/sg%d", i);
103     /* O_NONBLOCK is dangerous */
104     - f = open(devname, O_RDWR | O_NONBLOCK);
105     + f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
106     if (f < 0) {
107     /*
108     * Set up error string but let us clear it later
109     @@ -444,7 +466,7 @@
110     if (nopen == 0) for (i = 0; i <= 25; i++) {
111     js_snprintf(devname, sizeof (devname), "/dev/sg%c", i+'a');
112     /* O_NONBLOCK is dangerous */
113     - f = open(devname, O_RDWR | O_NONBLOCK);
114     + f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
115     if (f < 0) {
116     /*
117     * Set up error string but let us clear it later
118     @@ -483,7 +505,7 @@
119     "Warning: Open by 'devname' is unintentional and not supported.\n");
120     }
121     /* O_NONBLOCK is dangerous */
122     - f = open(device, O_RDWR | O_NONBLOCK);
123     + f = sg_open_excl(device, O_RDWR | O_NONBLOCK);
124     /* if (f < 0 && errno == ENOENT)*/
125     /* goto openpg;*/
126    
127     diff -urNad /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsitransp.c cdrtools-2.0+a30.pre1/libscg/scsitransp.c
128     --- /home/martin/devel/cdr/cdrtools-2.0+a30.pre1/libscg/scsitransp.c 2004-10-19 13:19:33.951937912 +0200
129     +++ cdrtools-2.0+a30.pre1/libscg/scsitransp.c 2004-10-19 13:20:44.779170536 +0200
130     @@ -52,8 +52,8 @@
131     * Choose your name instead of "schily" and make clear that the version
132     * string is related to a modified source.
133     */
134     -LOCAL char _scg_version[] = "0.8"; /* The global libscg version */
135     -LOCAL char _scg_auth_schily[] = "schily"; /* The author for this module */
136     +LOCAL char _scg_version[] = "0.8ubuntu1"; /* The global libscg version */
137     +LOCAL char _scg_auth_ubuntu[] = "ubuntu"; /* The author for this module */
138    
139     #define DEFTIMEOUT 20 /* Default timeout for SCSI command transport */
140    
141     @@ -137,7 +137,7 @@
142     * return "schily" for the SCG_AUTHOR request.
143     */
144     case SCG_AUTHOR:
145     - return (_scg_auth_schily);
146     + return (_scg_auth_ubuntu);
147     case SCG_SCCS_ID:
148     return (sccsid);
149     default:

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5