source: ProjectBuilder/projects/buffer/pbconf/1.19/buffer/pbpatch/01-debian-patches.all@ 551

Last change on this file since 551 was 551, checked in by Bruno Cornec, 16 years ago

Fedora fixes for buffer in order to submit it for inclusion

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