1 | diff -urNp buffer-1.19.orig/buffer.c buffer-1.19/buffer.c
|
---|
2 | --- buffer-1.19.orig/buffer.c 2000-01-04 03:46:11.000000000 +0100
|
---|
3 | +++ buffer-1.19/buffer.c 2008-09-20 01:19:18.000000000 +0200
|
---|
4 | @@ -78,7 +78,7 @@
|
---|
5 | * Christoph Wicki <wicki@iis.ethz.ch>
|
---|
6 | *
|
---|
7 | * Revision 1.7 1992/07/23 20:42:03 lmjm
|
---|
8 | - * Added 't' option to print total writen at end.
|
---|
9 | + * Added 't' option to print total written at end.
|
---|
10 | *
|
---|
11 | * Revision 1.6 1992/04/07 19:57:30 lmjm
|
---|
12 | * Added Kevins -B and -p options.
|
---|
13 | @@ -93,7 +93,7 @@
|
---|
14 | * Make sofar printing size an option.
|
---|
15 | *
|
---|
16 | * Revision 1.3 90/05/15 23:27:46 lmjm
|
---|
17 | - * Added -S option (show how much has been writen).
|
---|
18 | + * Added -S option (show how much has been written).
|
---|
19 | * Added -m option to specify how much shared memory to grab.
|
---|
20 | * Now tries to fill this with blocks.
|
---|
21 | * reader waits for writer to terminate and then frees the shared mem and sems.
|
---|
22 | @@ -109,6 +109,10 @@
|
---|
23 | * Initial revision
|
---|
24 | *
|
---|
25 | */
|
---|
26 | +#include <stdlib.h>
|
---|
27 | +#include <string.h>
|
---|
28 | +#include <limits.h>
|
---|
29 | +#include <sys/time.h>
|
---|
30 | #include <unistd.h>
|
---|
31 | #include <stdio.h>
|
---|
32 | #include <signal.h>
|
---|
33 | @@ -139,6 +143,14 @@
|
---|
34 | #define K *1024
|
---|
35 | #define M *1024*1024
|
---|
36 |
|
---|
37 | +#if defined __GNUC__ || __STDC_VERSION__ >= 199901L
|
---|
38 | +#define NUM_K_TYPE unsigned long long
|
---|
39 | +#define NUM_K_FMT "llu"
|
---|
40 | +#else
|
---|
41 | +#define NUM_K_TYPE unsigned long
|
---|
42 | +#define NUM_K_FMT "lu"
|
---|
43 | +#endif
|
---|
44 | +
|
---|
45 | /* Some forward declarations */
|
---|
46 | void byee();
|
---|
47 | void start_reader_and_writer();
|
---|
48 | @@ -162,7 +174,7 @@
|
---|
49 | void pr_out();
|
---|
50 | void end_writer();
|
---|
51 |
|
---|
52 | -/* When showing print a note every this many bytes writen */
|
---|
53 | +/* When showing print a note every this many bytes written */
|
---|
54 | int showevery = 0;
|
---|
55 | #define PRINT_EVERY 10 K
|
---|
56 |
|
---|
57 | @@ -253,7 +265,9 @@
|
---|
58 |
|
---|
59 | char print_total = 0;
|
---|
60 | /* Number of K output */
|
---|
61 | -unsigned long outk = 0;
|
---|
62 | +NUM_K_TYPE outk = 0;
|
---|
63 | +
|
---|
64 | +struct timeval starttime;
|
---|
65 |
|
---|
66 | int
|
---|
67 | main( argc, argv )
|
---|
68 | @@ -265,6 +279,8 @@
|
---|
69 | set_handlers();
|
---|
70 |
|
---|
71 | buffer_allocate();
|
---|
72 | +
|
---|
73 | + gettimeofday(&starttime, NULL);
|
---|
74 |
|
---|
75 | start_reader_and_writer();
|
---|
76 |
|
---|
77 | @@ -290,7 +306,7 @@
|
---|
78 |
|
---|
79 | while( (c = getopt( argc, argv, "BS:Zdm:s:b:p:u:ti:o:z:" )) != -1 ){
|
---|
80 | switch( c ){
|
---|
81 | - case 't': /* Print to stderr the total no of bytes writen */
|
---|
82 | + case 't': /* Print to stderr the total no of bytes written */
|
---|
83 | print_total++;
|
---|
84 | break;
|
---|
85 | case 'u': /* pause after write for given microseconds */
|
---|
86 | @@ -387,8 +403,8 @@
|
---|
87 | fprintf( stderr, "Usage: %s [-B] [-t] [-S size] [-m memsize] [-b blocks] [-p percent] [-s blocksize] [-u pause] [-i infile] [-o outfile] [-z size]\n",
|
---|
88 | progname );
|
---|
89 | fprintf( stderr, "-B = blocked device - pad out last block\n" );
|
---|
90 | - fprintf( stderr, "-t = show total amount writen at end\n" );
|
---|
91 | - fprintf( stderr, "-S size = show amount writen every size bytes\n" );
|
---|
92 | + fprintf( stderr, "-t = show total amount written at end\n" );
|
---|
93 | + fprintf( stderr, "-S size = show amount written every size bytes\n" );
|
---|
94 | fprintf( stderr, "-m size = size of shared mem chunk to grab\n" );
|
---|
95 | fprintf( stderr, "-b num = number of blocks in queue\n" );
|
---|
96 | fprintf( stderr, "-p percent = don't start writing until percent blocks filled\n" );
|
---|
97 | @@ -400,6 +416,11 @@
|
---|
98 | byee( -1 );
|
---|
99 | }
|
---|
100 | }
|
---|
101 | +
|
---|
102 | + if (argc > optind) {
|
---|
103 | + fprintf( stderr, "too many arguments\n" );
|
---|
104 | + byee( -1 );
|
---|
105 | + }
|
---|
106 |
|
---|
107 | if (zflag) showevery = blocksize;
|
---|
108 |
|
---|
109 | @@ -510,9 +531,9 @@
|
---|
110 | get_buffer();
|
---|
111 |
|
---|
112 | if( debug )
|
---|
113 | - fprintf( stderr, "%s pbuffer is 0x%08x, buffer_size is %d [%d x %d]\n",
|
---|
114 | + fprintf( stderr, "%s pbuffer is 0x%08lx, buffer_size is %d [%d x %d]\n",
|
---|
115 | proc_string,
|
---|
116 | - (char *)pbuffer, buffer_size, blocks, blocksize );
|
---|
117 | + (unsigned long)pbuffer, buffer_size, blocks, blocksize );
|
---|
118 |
|
---|
119 | #ifdef SYS5
|
---|
120 | memset( (char *)pbuffer, '\0', buffer_size );
|
---|
121 | @@ -531,7 +552,17 @@
|
---|
122 | pbuffer->blocks_free_lock = 1;
|
---|
123 | /* start this off so lock() can be called on it for each block
|
---|
124 | * till all the blocks are used up */
|
---|
125 | + /* Initializing the semaphore to "blocks - 1" causes a hang when using option
|
---|
126 | + * "-p 100" because it always keeps one block free, so we'll never reach 100% fill
|
---|
127 | + * level. However, there doesn't seem to be a good reason to keep one block free,
|
---|
128 | + * so we initialize the semaphore to "blocks" instead.
|
---|
129 | + * <mbuck@debian.org> 2004-01-11
|
---|
130 | + */
|
---|
131 | +#if 0
|
---|
132 | sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks - 1 );
|
---|
133 | +#else
|
---|
134 | + sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks );
|
---|
135 | +#endif
|
---|
136 |
|
---|
137 | /* Detattach the shared memory so the fork doesnt do anything odd */
|
---|
138 | shmdt( (char *)pbuffer );
|
---|
139 | @@ -651,7 +682,7 @@
|
---|
140 | int
|
---|
141 | fill_block()
|
---|
142 | {
|
---|
143 | - int bytes;
|
---|
144 | + int bytes = 0;
|
---|
145 | char *start;
|
---|
146 | int toread;
|
---|
147 | static char eof_reached = 0;
|
---|
148 | @@ -710,7 +741,7 @@
|
---|
149 | {
|
---|
150 | int filled = 0;
|
---|
151 | int maxfilled = (blocks * percent) / 100;
|
---|
152 | - int first_block;
|
---|
153 | + int first_block = 0;
|
---|
154 |
|
---|
155 | if( debug )
|
---|
156 | fprintf( stderr, "\tW: Entering writer\n blocks = %d\n maxfilled = %d\n",
|
---|
157 | @@ -745,7 +776,7 @@
|
---|
158 | }
|
---|
159 |
|
---|
160 | if( print_total ){
|
---|
161 | - fprintf( stderr, "Kilobytes Out %lu\n", outk );
|
---|
162 | + fprintf( stderr, "Kilobytes Out %" NUM_K_FMT "\n", outk );
|
---|
163 | }
|
---|
164 |
|
---|
165 | if( debug )
|
---|
166 | @@ -786,14 +817,14 @@
|
---|
167 | void
|
---|
168 | write_block_to_stdout()
|
---|
169 | {
|
---|
170 | - static unsigned long out = 0;
|
---|
171 | + unsigned long out = 0;
|
---|
172 | static unsigned long last_gb = 0;
|
---|
173 | - static unsigned long next_k = 0;
|
---|
174 | + static NUM_K_TYPE next_k = 0;
|
---|
175 | int written;
|
---|
176 |
|
---|
177 | if( next_k == 0 && showevery ){
|
---|
178 | if( debug > 3 )
|
---|
179 | - fprintf( stderr, "W: next_k = %lu showevery = %d\n", next_k, showevery );
|
---|
180 | + fprintf( stderr, "W: next_k = %" NUM_K_FMT " showevery = %d\n", next_k, showevery );
|
---|
181 | showevery = showevery / 1024;
|
---|
182 | next_k = showevery;
|
---|
183 | }
|
---|
184 | @@ -801,7 +832,7 @@
|
---|
185 | if( (written = write( fdout, curr_block->data, curr_block->bytes )) != curr_block->bytes ){
|
---|
186 | report_proc();
|
---|
187 | perror( "write of data failed" );
|
---|
188 | - fprintf( stderr, "bytes to write=%d, bytes written=%d, total written %10luK\n", curr_block->bytes, written, outk );
|
---|
189 | + fprintf( stderr, "bytes to write=%d, bytes written=%d, total written %10" NUM_K_FMT "K\n", curr_block->bytes, written, outk );
|
---|
190 | byee( -1 );
|
---|
191 | }
|
---|
192 |
|
---|
193 | @@ -828,7 +859,7 @@
|
---|
194 | }
|
---|
195 | if( showevery ){
|
---|
196 | if( debug > 3 )
|
---|
197 | - fprintf( stderr, "W: outk = %lu, next_k = %lu\n",
|
---|
198 | + fprintf( stderr, "W: outk = %" NUM_K_FMT ", next_k = %" NUM_K_FMT "\n",
|
---|
199 | outk, next_k );
|
---|
200 | if( outk >= next_k ){
|
---|
201 | pr_out();
|
---|
202 | @@ -917,13 +948,12 @@
|
---|
203 | do_size( arg )
|
---|
204 | char *arg;
|
---|
205 | {
|
---|
206 | - char format[ 20 ];
|
---|
207 | - int ret;
|
---|
208 | + int ret = 0;
|
---|
209 |
|
---|
210 | - *format = '\0';
|
---|
211 | - sscanf( arg, "%d%s", &ret, format );
|
---|
212 | + char unit = '\0';
|
---|
213 | + sscanf( arg, "%d%c", &ret, &unit );
|
---|
214 |
|
---|
215 | - switch( *format ){
|
---|
216 | + switch( unit ){
|
---|
217 | case 'm':
|
---|
218 | case 'M':
|
---|
219 | ret = ret K K;
|
---|
220 | @@ -944,7 +974,36 @@
|
---|
221 | void
|
---|
222 | pr_out()
|
---|
223 | {
|
---|
224 | - fprintf( stderr, " %10luK\r", outk );
|
---|
225 | + struct timeval now;
|
---|
226 | + unsigned long ms_delta, k_per_s;
|
---|
227 | +
|
---|
228 | + gettimeofday(&now, NULL);
|
---|
229 | + ms_delta = (now.tv_sec - starttime.tv_sec) * 1000
|
---|
230 | + + (now.tv_usec - starttime.tv_usec) / 1000;
|
---|
231 | + if (ms_delta) {
|
---|
232 | + /* Use increased accuracy for small amounts of data,
|
---|
233 | + * decreased accuracy for *huge* throughputs > 4.1GB/s
|
---|
234 | + * to avoid division by 0. This will overflow if your
|
---|
235 | + * machine's throughput exceeds 4TB/s - you deserve to
|
---|
236 | + * loose if you're still using 32 bit longs on such a
|
---|
237 | + * beast ;-)
|
---|
238 | + * <mbuck@debian.org>
|
---|
239 | + */
|
---|
240 | + if (outk < ULONG_MAX / 1000) {
|
---|
241 | + k_per_s = (outk * 1000) / ms_delta;
|
---|
242 | + } else if (ms_delta >= 1000) {
|
---|
243 | + k_per_s = outk / (ms_delta / 1000);
|
---|
244 | + } else {
|
---|
245 | + k_per_s = (outk / ms_delta) * 1000;
|
---|
246 | + }
|
---|
247 | + fprintf( stderr, " %10" NUM_K_FMT "K, %10luK/s\r", outk, k_per_s );
|
---|
248 | + } else {
|
---|
249 | + if (outk) {
|
---|
250 | + fprintf( stderr, " %10" NUM_K_FMT "K, ?K/s\r", outk );
|
---|
251 | + } else {
|
---|
252 | + fprintf( stderr, " 0K, 0K/s\r");
|
---|
253 | + }
|
---|
254 | + }
|
---|
255 | }
|
---|
256 |
|
---|
257 | #ifdef SYS5
|
---|
258 | diff -urNp buffer-1.19.orig/buffer.man buffer-1.19/buffer.man
|
---|
259 | --- buffer-1.19.orig/buffer.man 2000-01-04 03:44:32.000000000 +0100
|
---|
260 | +++ buffer-1.19/buffer.man 2008-09-20 01:18:48.000000000 +0200
|
---|
261 | @@ -37,7 +37,8 @@
|
---|
262 | Use the given file as the output file. The default is stdout.
|
---|
263 | .TP
|
---|
264 | .B \-S size
|
---|
265 | -After every chunk this size has been writen print out how much been writen so far.
|
---|
266 | +After every chunk of this size has been written, print out how much has
|
---|
267 | +been written so far. Also prints the total througput.
|
---|
268 | By default this is not set.
|
---|
269 | .TP
|
---|
270 | .B \-s size
|
---|
271 | @@ -71,9 +72,9 @@
|
---|
272 | throughput on some drives.)
|
---|
273 | .TP
|
---|
274 | .B \-B
|
---|
275 | -Force each block writen to be padded out to the blocksize. This is needed by some tape
|
---|
276 | +Force each block written to be padded out to the blocksize. This is needed by some tape
|
---|
277 | and cartridge drives. Defaults to unpadded. This only affects the
|
---|
278 | -last block writen.
|
---|
279 | +last block written.
|
---|
280 | .TP
|
---|
281 | .B \-t
|
---|
282 | On exiting print to stderr a brief message showing the total number of
|
---|
283 | @@ -82,7 +83,7 @@
|
---|
284 | .B \-Z
|
---|
285 | If reading/writing directly to a character device (like a tape drive)
|
---|
286 | then after each gigabyte perform an lseek to the start of the file.
|
---|
287 | -Use this flag with extreme care. If can only be used on devices where
|
---|
288 | +Use this flag with extreme care. It can only be used on devices where
|
---|
289 | an lseek does not rewind the tape but does reset the kernels position
|
---|
290 | flags. It is used to allow more than 2 gigabytes to be written.
|
---|
291 | .PP
|
---|
292 | diff -urNp buffer-1.19.orig/debian/changelog buffer-1.19/debian/changelog
|
---|
293 | --- buffer-1.19.orig/debian/changelog 1970-01-01 01:00:00.000000000 +0100
|
---|
294 | +++ buffer-1.19/debian/changelog 2008-09-20 01:18:48.000000000 +0200
|
---|
295 | @@ -0,0 +1,98 @@
|
---|
296 | +buffer (1.19-7) unstable; urgency=low
|
---|
297 | +
|
---|
298 | + * Really changed priority this time. Sigh.
|
---|
299 | +
|
---|
300 | + -- Martin Buck <mbuck@debian.org> Sat, 1 Jan 2005 23:46:26 +0100
|
---|
301 | +
|
---|
302 | +buffer (1.19-6) unstable; urgency=low
|
---|
303 | +
|
---|
304 | + * Changed priority to optional. Closes: #283803
|
---|
305 | +
|
---|
306 | + -- Martin Buck <mbuck@debian.org> Thu, 30 Dec 2004 15:04:31 +0100
|
---|
307 | +
|
---|
308 | +buffer (1.19-5) unstable; urgency=low
|
---|
309 | +
|
---|
310 | + * Disabled obsolete declaration of shmat(). Closes: #260395
|
---|
311 | +
|
---|
312 | + -- Martin Buck <mbuck@debian.org> Tue, 27 Jul 2004 23:50:50 +0200
|
---|
313 | +
|
---|
314 | +buffer (1.19-4) unstable; urgency=low
|
---|
315 | +
|
---|
316 | + * Fixed hang when using option "-p 100". Closes: #224984
|
---|
317 | +
|
---|
318 | + -- Martin Buck <mbuck@debian.org> Sun, 11 Jan 2004 23:20:39 +0100
|
---|
319 | +
|
---|
320 | +buffer (1.19-3) unstable; urgency=low
|
---|
321 | +
|
---|
322 | + * Added largefile support. Closes: #156847
|
---|
323 | + * Made sure -S/-z works properly with files > 4 TB.
|
---|
324 | + * Upgraded to Standards-Version 3.5.8
|
---|
325 | +
|
---|
326 | + -- Martin Buck <mbuck@debian.org> Fri, 31 Jan 2003 23:55:43 +0100
|
---|
327 | +
|
---|
328 | +buffer (1.19-2) unstable; urgency=low
|
---|
329 | +
|
---|
330 | + * Fixed buffer overrun in option parsing.
|
---|
331 | + Fixed (rather theoretical) potential division by zero in
|
---|
332 | + throughput calculation.
|
---|
333 | + Closes: #123543
|
---|
334 | +
|
---|
335 | + -- Martin Buck <mbuck@debian.org> Tue, 11 Dec 2001 23:34:46 +0100
|
---|
336 | +
|
---|
337 | +buffer (1.19-1) unstable; urgency=low
|
---|
338 | +
|
---|
339 | + * New upstream version. Closes: #91961
|
---|
340 | + * Added a few spelling fixes from FreeBSD version 1.17.1
|
---|
341 | + * Added (slightly modified version of) patch from Marc Schaefer that prints
|
---|
342 | + the throughput with option -S
|
---|
343 | + * Fixed a few gcc warnings
|
---|
344 | +
|
---|
345 | + -- Martin Buck <mbuck@debian.org> Thu, 5 Apr 2001 22:10:07 +0200
|
---|
346 | +
|
---|
347 | +buffer (1.17-6) unstable; urgency=low
|
---|
348 | +
|
---|
349 | + * Added Build-Depends. Closes: #70332
|
---|
350 | +
|
---|
351 | + -- Martin Buck <mbuck@debian.org> Mon, 5 Mar 2001 22:19:09 +0100
|
---|
352 | +
|
---|
353 | +buffer (1.17-5) unstable; urgency=low
|
---|
354 | +
|
---|
355 | + * Cleaned up debian/rules
|
---|
356 | + * Upgraded to Debian policy 3.0.1.1
|
---|
357 | +
|
---|
358 | + -- Martin Buck <mbuck@debian.org> Mon, 13 Sep 1999 23:19:57 +0200
|
---|
359 | +
|
---|
360 | +buffer (1.17-4) unstable; urgency=low
|
---|
361 | +
|
---|
362 | + * buffer now complains if non-option arguments are found
|
---|
363 | + * Document changes from original version in copyright-file
|
---|
364 | + * Checked conformance with Debian policy 2.5.0
|
---|
365 | +
|
---|
366 | + -- Martin Buck <mbuck@debian.org> Sun, 29 Aug 1999 00:57:03 +0200
|
---|
367 | +
|
---|
368 | +buffer (1.17-3) unstable; urgency=low
|
---|
369 | +
|
---|
370 | + * NMU; added missing SEM_SEMUN_UNDEFINED
|
---|
371 | + * closes: #31931
|
---|
372 | + * fixes: #31920
|
---|
373 | +
|
---|
374 | + -- Hartmut Koptein <koptein@debian.org> Fri, 9 Jul 1999 10:04:49 +0200
|
---|
375 | +
|
---|
376 | +buffer (1.17-2) unstable; urgency=low
|
---|
377 | +
|
---|
378 | + * Applied patch from Paul Slootman (closes: Bug#26098):
|
---|
379 | + - egcs complains about NULL where union expected. Now it builds on Alpha.
|
---|
380 | + - typos in manpage fixed.
|
---|
381 | + * Switched from debstd to debhelper
|
---|
382 | +
|
---|
383 | + -- Martin Buck <mbuck@debian.org> Wed, 9 Sep 1998 22:35:29 +0200
|
---|
384 | +
|
---|
385 | +buffer (1.17-1) unstable; urgency=low
|
---|
386 | +
|
---|
387 | + * Initial Release.
|
---|
388 | +
|
---|
389 | + -- Martin Buck <mbuck@debian.org> Wed, 27 Aug 1997 01:11:29 +0200
|
---|
390 | +
|
---|
391 | +Local variables:
|
---|
392 | +mode: debian-changelog
|
---|
393 | +End:
|
---|
394 | diff -urNp buffer-1.19.orig/debian/control buffer-1.19/debian/control
|
---|
395 | --- buffer-1.19.orig/debian/control 1970-01-01 01:00:00.000000000 +0100
|
---|
396 | +++ buffer-1.19/debian/control 2008-09-20 01:18:48.000000000 +0200
|
---|
397 | @@ -0,0 +1,19 @@
|
---|
398 | +Source: buffer
|
---|
399 | +Section: utils
|
---|
400 | +Priority: optional
|
---|
401 | +Maintainer: Martin Buck <mbuck@debian.org>
|
---|
402 | +Standards-Version: 3.5.8
|
---|
403 | +Build-Depends: debhelper (>= 4)
|
---|
404 | +
|
---|
405 | +Package: buffer
|
---|
406 | +Architecture: any
|
---|
407 | +Depends: ${shlibs:Depends}
|
---|
408 | +Description: Buffering/reblocking program for tape backups, printing, etc.
|
---|
409 | + Buffer implements double buffering and can be used to keep backup tapes
|
---|
410 | + streaming or printers printing. It can also be used to convert a data
|
---|
411 | + stream to a given output blocksize.
|
---|
412 | + .
|
---|
413 | + Buffer uses shared memory to convert a variable input data rate to a
|
---|
414 | + constant output data rate. It is typically used in a pipe between a backup
|
---|
415 | + program and the tape device, but there are also other applications like
|
---|
416 | + buffering printer data in lpd's input filter.
|
---|
417 | diff -urNp buffer-1.19.orig/debian/copyright buffer-1.19/debian/copyright
|
---|
418 | --- buffer-1.19.orig/debian/copyright 1970-01-01 01:00:00.000000000 +0100
|
---|
419 | +++ buffer-1.19/debian/copyright 2008-09-20 01:18:48.000000000 +0200
|
---|
420 | @@ -0,0 +1,11 @@
|
---|
421 | +This package was debianized by Martin Buck mbuck@debian.org on
|
---|
422 | +Wed, 27 Aug 1997 01:11:29 +0200.
|
---|
423 | +
|
---|
424 | +It was downloaded from
|
---|
425 | +http://sunsite.org.uk/public/public/packages/buffer/
|
---|
426 | +
|
---|
427 | +Copyright:
|
---|
428 | +GPL (see /usr/share/common-licenses/GPL)
|
---|
429 | +In addtion under NO circumstances can I (Lee McLoughlin), or Imperial
|
---|
430 | +College, be held liable for any event caused by the running or storing of
|
---|
431 | +this program or its documentation.
|
---|
432 | diff -urNp buffer-1.19.orig/debian/rules buffer-1.19/debian/rules
|
---|
433 | --- buffer-1.19.orig/debian/rules 1970-01-01 01:00:00.000000000 +0100
|
---|
434 | +++ buffer-1.19/debian/rules 2008-09-20 01:18:48.000000000 +0200
|
---|
435 | @@ -0,0 +1,64 @@
|
---|
436 | +#!/usr/bin/make -f
|
---|
437 | +
|
---|
438 | +export DH_COMPAT = 4
|
---|
439 | +
|
---|
440 | +CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
---|
441 | +
|
---|
442 | +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
---|
443 | + CFLAGS += -O0
|
---|
444 | +else
|
---|
445 | + CFLAGS += -O2
|
---|
446 | +endif
|
---|
447 | +
|
---|
448 | +
|
---|
449 | +build: build-stamp
|
---|
450 | +build-stamp:
|
---|
451 | + dh_testdir
|
---|
452 | +
|
---|
453 | + make CFLAGS="$(CFLAGS)"
|
---|
454 | +
|
---|
455 | + touch build-stamp
|
---|
456 | +
|
---|
457 | +clean:
|
---|
458 | + dh_testdir
|
---|
459 | + dh_testroot
|
---|
460 | + -rm -f build-stamp install-stamp
|
---|
461 | + -make clean
|
---|
462 | + dh_clean
|
---|
463 | +
|
---|
464 | +install: install-stamp
|
---|
465 | +install-stamp: build-stamp
|
---|
466 | + dh_testdir
|
---|
467 | + dh_testroot
|
---|
468 | + dh_clean -k
|
---|
469 | + dh_installdirs usr/bin usr/share/man/man1
|
---|
470 | + make install INSTBIN=debian/buffer/usr/bin INSTMAN=debian/buffer/usr/share/man/man1 S=1
|
---|
471 | + touch install-stamp
|
---|
472 | +
|
---|
473 | +binary-indep: build install
|
---|
474 | +
|
---|
475 | +binary-arch: build install
|
---|
476 | + dh_testdir
|
---|
477 | + dh_testroot
|
---|
478 | + dh_installdocs README
|
---|
479 | +# dh_installexamples
|
---|
480 | +# dh_installmenu
|
---|
481 | +# dh_installemacsen
|
---|
482 | +# dh_installinit
|
---|
483 | +# dh_installcron
|
---|
484 | +# dh_installman
|
---|
485 | +# dh_undocumented
|
---|
486 | + dh_installchangelogs
|
---|
487 | + dh_strip
|
---|
488 | + dh_compress
|
---|
489 | + dh_fixperms
|
---|
490 | +# dh_suidregister
|
---|
491 | + dh_installdeb
|
---|
492 | + dh_shlibdeps
|
---|
493 | + dh_gencontrol
|
---|
494 | +# dh_makeshlibs
|
---|
495 | + dh_md5sums
|
---|
496 | + dh_builddeb
|
---|
497 | +
|
---|
498 | +binary: binary-indep binary-arch
|
---|
499 | +.PHONY: build clean binary-indep binary-arch binary install
|
---|
500 | diff -urNp buffer-1.19.orig/sem.c buffer-1.19/sem.c
|
---|
501 | --- buffer-1.19.orig/sem.c 2000-01-04 03:49:12.000000000 +0100
|
---|
502 | +++ buffer-1.19/sem.c 2008-09-20 01:18:48.000000000 +0200
|
---|
503 | @@ -27,6 +27,7 @@
|
---|
504 | * semaphores */
|
---|
505 |
|
---|
506 | #include <stdio.h>
|
---|
507 | +#include <unistd.h>
|
---|
508 | #include <sys/types.h>
|
---|
509 | #include <sys/stat.h>
|
---|
510 | #include <sys/ipc.h>
|
---|
511 | @@ -103,7 +119,7 @@
|
---|
512 | return sem;
|
---|
513 | }
|
---|
514 |
|
---|
515 | -static
|
---|
516 | +static void
|
---|
517 | do_sem( sem_id, pbuf, err )
|
---|
518 | int sem_id;
|
---|
519 | struct sembuf *pbuf;
|
---|
520 | @@ -156,10 +157,13 @@
|
---|
521 | remove_sems( sem_id )
|
---|
522 | int sem_id;
|
---|
523 | {
|
---|
524 | + union semun arg;
|
---|
525 | +
|
---|
526 | if( sem_id == -1 )
|
---|
527 | return;
|
---|
528 |
|
---|
529 | - if( semctl( sem_id, 0, IPC_RMID, NULL ) == -1 ){
|
---|
530 | + arg.val = 0;
|
---|
531 | + if( semctl( sem_id, 0, IPC_RMID, arg ) == -1 ){
|
---|
532 | report_proc();
|
---|
533 | perror( "internal error, failed to remove semaphore" );
|
---|
534 | }
|
---|