summaryrefslogtreecommitdiff
path: root/misc/buffer
diff options
context:
space:
mode:
authorMario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>2005-12-13 17:33:18 +0000
committerMario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>2005-12-13 17:33:18 +0000
commitfae54139e3ac8b6689c7ba0af8b13e278351a4de (patch)
treee9104eb67a7a3a3eb0c14692c15c43cc9ce9f88f /misc/buffer
parentUpdate to 2.3-20051212 (diff)
o Update to 1.19
o Add several patches from Gentoo portage CVS Approved by: maintainer (thanks jonny) Obtained from: Gentoo portage CVS
Notes
Notes: svn path=/head/; revision=151110
Diffstat (limited to 'misc/buffer')
-rw-r--r--misc/buffer/Makefile20
-rw-r--r--misc/buffer/distinfo5
-rw-r--r--misc/buffer/files/patch-aa11
-rw-r--r--misc/buffer/files/patch-buffer.c170
-rw-r--r--misc/buffer/files/patch-buffer.man33
-rw-r--r--misc/buffer/files/patch-sem.c19
6 files changed, 240 insertions, 18 deletions
diff --git a/misc/buffer/Makefile b/misc/buffer/Makefile
index 9eafc6832a9f..c006aed408d5 100644
--- a/misc/buffer/Makefile
+++ b/misc/buffer/Makefile
@@ -6,17 +6,27 @@
#
PORTNAME= buffer
-PORTVERSION= 1.17.1
+PORTVERSION= 1.19
CATEGORIES= misc
-MASTER_SITES= ${MASTER_SITE_LOCAL}
-MASTER_SITE_SUBDIR= steve
+MASTER_SITES= ${MASTER_SITE_GENTOO} \
+ http://www.mondorescue.org/download/MondoCD/TGZS/
+MASTER_SITE_SUBDIR= distfiles
+EXTRACT_SUFX= .tgz
MAINTAINER= jonny@jonny.eng.br
COMMENT= Buffer sporadic I/O for faster tape and pipe throughput
-USE_BZIP2= yes
-NO_WRKSUBDIR= yes
+USE_REINPLACE= yes
+
MAN1= buffer.1
PLIST_FILES= bin/buffer
+post-patch:
+ @${REINPLACE_CMD} -E \
+ -e 's|^(CC[[:space:]]*=).*$$|\1${CC}|' \
+ -e 's|^(CFLAGS[[:space:]]*=).*$$|\1${CFLAGS}|' \
+ -e 's|^(INSTBIN[[:space:]]*=).*$$|\1${PREFIX}/bin|' \
+ -e 's|^(INSTMAN[[:space:]]*=).*$$|\1${MAN1PREFIX}/man/man1|' \
+ ${WRKSRC}/Makefile
+
.include <bsd.port.mk>
diff --git a/misc/buffer/distinfo b/misc/buffer/distinfo
index b2690a65c058..9117e3852bed 100644
--- a/misc/buffer/distinfo
+++ b/misc/buffer/distinfo
@@ -1,2 +1,3 @@
-MD5 (buffer-1.17.1.tar.bz2) = fb9a5166926d11a35b7844735cf88a8c
-SIZE (buffer-1.17.1.tar.bz2) = 16096
+MD5 (buffer-1.19.tgz) = ef1f84473adb3bc2870dd5b0ad4ea82a
+SHA256 (buffer-1.19.tgz) = ec7da9f9737cd03c11a26f8380ab7d567b252b862b989da430b1e92db79b42c8
+SIZE (buffer-1.19.tgz) = 34960
diff --git a/misc/buffer/files/patch-aa b/misc/buffer/files/patch-aa
deleted file mode 100644
index 5d2ab971088c..000000000000
--- a/misc/buffer/files/patch-aa
+++ /dev/null
@@ -1,11 +0,0 @@
---- buffer.c.orig Sun Jul 7 18:54:56 2002
-+++ buffer.c Sun Jul 7 18:55:06 2002
-@@ -117,8 +117,6 @@
- static char *rcsid = "$Header: /a/swan/home/swan/staff/csg/lmjm/src/buffer/RCS/buffer.c,v 1.17 1993/06/04 10:26:39 lmjm Exp lmjm $";
- #endif
-
--extern char *shmat();
--
- /* General macros */
- #define TRUE 1
- #define FALSE 0
diff --git a/misc/buffer/files/patch-buffer.c b/misc/buffer/files/patch-buffer.c
new file mode 100644
index 000000000000..fb108cda2767
--- /dev/null
+++ b/misc/buffer/files/patch-buffer.c
@@ -0,0 +1,170 @@
+--- buffer.c.orig Sat Jan 19 20:47:17 2002
++++ buffer.c Tue Dec 13 11:57:38 2005
+@@ -114,12 +114,17 @@
+ #include <signal.h>
+ #include <fcntl.h>
+ #include <errno.h>
++#include <machine/param.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/ipc.h>
++#include <sys/limits.h>
+ #include <sys/shm.h>
+ #include <sys/sem.h>
+ #include <sys/wait.h>
++#include <sys/time.h>
++#include <stdlib.h>
++#include <strings.h>
+ #include "sem.h"
+
+ #ifndef lint
+@@ -127,7 +132,6 @@
+ #endif
+
+ #ifndef __alpha
+-extern char *shmat();
+ #endif /* __alpha */
+
+ /* General macros */
+@@ -252,6 +256,8 @@
+ /* Number of K output */
+ unsigned long outk = 0;
+
++struct timeval starttime;
++
+ int
+ main( argc, argv )
+ int argc;
+@@ -263,6 +269,8 @@
+
+ buffer_allocate();
+
++ gettimeofday(&starttime, NULL);
++
+ start_reader_and_writer();
+
+ byee( 0 );
+@@ -384,8 +392,8 @@
+ 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",
+ progname );
+ fprintf( stderr, "-B = blocked device - pad out last block\n" );
+- fprintf( stderr, "-t = show total amount writen at end\n" );
+- fprintf( stderr, "-S size = show amount writen every size bytes\n" );
++ fprintf( stderr, "-t = show total amount written at end\n" );
++ fprintf( stderr, "-S size = show amount written every size bytes\n" );
+ fprintf( stderr, "-m size = size of shared mem chunk to grab\n" );
+ fprintf( stderr, "-b num = number of blocks in queue\n" );
+ fprintf( stderr, "-p percent = don't start writing until percent blocks filled\n" );
+@@ -398,6 +406,11 @@
+ }
+ }
+
++ if (argc > optind) {
++ fprintf( stderr, "too many arguments\n" );
++ byee( -1 );
++ }
++
+ if (zflag) showevery = blocksize;
+
+ /* If -b was not given try and work out the max buffer size */
+@@ -507,9 +520,9 @@
+ get_buffer();
+
+ if( debug )
+- fprintf( stderr, "%s pbuffer is 0x%08x, buffer_size is %d [%d x %d]\n",
++ fprintf( stderr, "%s pbuffer is 0x%08lx, buffer_size is %d [%d x %d]\n",
+ proc_string,
+- (char *)pbuffer, buffer_size, blocks, blocksize );
++ (unsigned long)pbuffer, buffer_size, blocks, blocksize );
+
+ #ifdef SYS5
+ memset( (char *)pbuffer, '\0', buffer_size );
+@@ -526,9 +539,11 @@
+ lock( pbuffer->semid, pbuffer->blocks_used_lock );
+
+ pbuffer->blocks_free_lock = 1;
+- /* start this off so lock() can be called on it for each block
+- * till all the blocks are used up */
+- sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks - 1 );
++ /* Initializing the semaphore to "blocks - 1" causes a hang when using option
++ * "-p 100" because it always keeps one block free, so we'll never reach 100% fill
++ * level. However, there doesn't seem to be a good reason to keep one block free,
++ * so we initialize the semaphore to "blocks" instead. */
++ sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks );
+
+ /* Detattach the shared memory so the fork doesnt do anything odd */
+ shmdt( (char *)pbuffer );
+@@ -648,7 +663,7 @@
+ int
+ fill_block()
+ {
+- int bytes;
++ int bytes = 0;
+ char *start;
+ int toread;
+ static char eof_reached = 0;
+@@ -707,7 +722,7 @@
+ {
+ int filled = 0;
+ int maxfilled = (blocks * percent) / 100;
+- int first_block;
++ int first_block = 0;
+
+ if( debug )
+ fprintf( stderr, "\tW: Entering writer\n blocks = %d\n maxfilled = %d\n",
+@@ -914,13 +929,12 @@
+ do_size( arg )
+ char *arg;
+ {
+- char format[ 20 ];
+- int ret;
++ int ret = 0;
+
+- *format = '\0';
+- sscanf( arg, "%d%s", &ret, format );
++ char unit = '\0';
++ sscanf( arg, "%d%c", &ret, &unit );
+
+- switch( *format ){
++ switch( unit ){
+ case 'm':
+ case 'M':
+ ret = ret K K;
+@@ -941,7 +955,36 @@
+ void
+ pr_out()
+ {
+- fprintf( stderr, " %10luK\r", outk );
++ struct timeval now;
++ unsigned long ms_delta, k_per_s;
++
++ gettimeofday(&now, NULL);
++ ms_delta = (now.tv_sec - starttime.tv_sec) * 1000
++ + (now.tv_usec - starttime.tv_usec) / 1000;
++ if (ms_delta) {
++ /* Use increased accuracy for small amounts of data,
++ * decreased accuracy for *huge* throughputs > 4.1GB/s
++ * to avoid division by 0. This will overflow if your
++ * machine's throughput exceeds 4TB/s - you deserve to
++ * loose if you're still using 32 bit longs on such a
++ * beast ;-)
++ * <mbuck@debian.org>
++ */
++ if (outk < ULONG_MAX / 1000) {
++ k_per_s = (outk * 1000) / ms_delta;
++ } else if (ms_delta >= 1000) {
++ k_per_s = outk / (ms_delta / 1000);
++ } else {
++ k_per_s = (outk / ms_delta) * 1000;
++ }
++ fprintf( stderr, " %10luK, %10luK/s\r", outk, k_per_s );
++ } else {
++ if (outk) {
++ fprintf( stderr, " %10luK, ?K/s\r", outk );
++ } else {
++ fprintf( stderr, " 0K, 0K/s\r");
++ }
++ }
+ }
+
+ #ifdef SYS5
diff --git a/misc/buffer/files/patch-buffer.man b/misc/buffer/files/patch-buffer.man
new file mode 100644
index 000000000000..b2001a2cbec9
--- /dev/null
+++ b/misc/buffer/files/patch-buffer.man
@@ -0,0 +1,33 @@
+--- buffer.man.orig Tue Dec 13 11:55:36 2005
++++ buffer.man Tue Dec 13 11:56:56 2005
+@@ -37,7 +37,8 @@
+ Use the given file as the output file. The default is stdout.
+ .TP
+ .B \-S size
+-After every chunk this size has been writen print out how much been writen so far.
++After every chunk of this size has been written, print out how much
++been written so far. Also prints the total throughput.
+ By default this is not set.
+ .TP
+ .B \-s size
+@@ -71,9 +72,9 @@
+ throughput on some drives.)
+ .TP
+ .B \-B
+-Force each block writen to be padded out to the blocksize. This is needed by some tape
++Force each block written to be padded out to the blocksize. This is needed by some tape
+ and cartridge drives. Defaults to unpadded. This only affects the
+-last block writen.
++last block written.
+ .TP
+ .B \-t
+ On exiting print to stderr a brief message showing the total number of
+@@ -82,7 +83,7 @@
+ .B \-Z
+ If reading/writing directly to a character device (like a tape drive)
+ then after each gigabyte perform an lseek to the start of the file.
+-Use this flag with extreme care. If can only be used on devices where
++Use this flag with extreme care. It can only be used on devices where
+ an lseek does not rewind the tape but does reset the kernels position
+ flags. It is used to allow more than 2 gigabytes to be written.
+ .PP
diff --git a/misc/buffer/files/patch-sem.c b/misc/buffer/files/patch-sem.c
new file mode 100644
index 000000000000..f6fe3c210bc4
--- /dev/null
+++ b/misc/buffer/files/patch-sem.c
@@ -0,0 +1,19 @@
+--- sem.c.orig Tue Dec 13 00:33:03 2005
++++ sem.c Tue Dec 13 00:35:22 2005
+@@ -27,6 +27,7 @@
+ * semaphores */
+
+ #include <stdio.h>
++#include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/ipc.h>
+@@ -95,7 +96,7 @@
+ return sem;
+ }
+
+-static
++static void
+ do_sem( sem_id, pbuf, err )
+ int sem_id;
+ struct sembuf *pbuf;