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

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