From: ianmdlvl Date: Sat, 21 May 2005 13:47:28 +0000 (+0000) Subject: @@ -1,3 +1,9 @@ X-Git-Tag: debian_version_4_0_99_0_16 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=6ed40dfb1e1c0d5de4ea311161dd4d0180bfb364;ds=sidebyside @@ -1,3 +1,9 @@ +chiark-utils (4.0.99.0.16) unstable; urgency=low + + * Size for readbuffer/writebuffer may be in k or bytes. + + -- Ian Jackson Sat, 21 May 2005 14:47:18 +0100 + chiark-utils (4.0.99.0.15) unstable; urgency=low * /etc/chiark-backup/snap/lvm (backup/lvm in the source tree) now --- diff --git a/cprogs/readbuffer.1 b/cprogs/readbuffer.1 index 361faea..18f6214 100644 --- a/cprogs/readbuffer.1 +++ b/cprogs/readbuffer.1 @@ -11,6 +11,10 @@ reads data on standard input and writes it to standard output. It will internally buffer up to \fIsize\fR megabytes of data, and will only read more data when the buffer is at least 75% empty. .PP +\fIsize\fR may also be suffixed with +.BR m ", " k ", or " b +to indicate that it is in megabytes (2^20), kilobytes (2^10) or bytes. +.PP It is intended for use in situations where many small reads are undesirable for performance reasons, e.g. tape drives. .SH OPTIONS diff --git a/cprogs/rwbuffer.c b/cprogs/rwbuffer.c index f2ec48d..ee97fca 100644 --- a/cprogs/rwbuffer.c +++ b/cprogs/rwbuffer.c @@ -39,7 +39,7 @@ unsigned char *buf, *wp, *rp; int used, seeneof, maxselfd; -size_t buffersize; +size_t buffersize= RWBUFFER_SIZE_MB_DEF*1024*1024; fd_set readfds; fd_set writefds; @@ -84,7 +84,7 @@ void startupcore(void) { void startup(const char *const *argv) { const char *arg; char *ep; - unsigned long opt_buffersize=RWBUFFER_SIZE_MB_DEF; + int shift=-1; assert(argv[0]); @@ -92,15 +92,22 @@ void startup(const char *const *argv) { if (!strcmp(arg,"--mlock")) { opt_mlock= 1; } else if (isdigit((unsigned char)arg[0])) { - opt_buffersize= strtoul(arg,&ep,0); - if (opt_buffersize > RWBUFFER_SIZE_MB_MAX) + buffersize= strtoul(arg,&ep,0); + if (ep[0] && ep[1]) usageerr("buffer size spec. invalid"); + switch (ep[0]) { + case 0: case 'm': shift= 20; break; + case 'k': shift= 10; break; + case 'b': shift= 0; break; + default: usageerr("buffer size unit unknown"); + } + if (buffersize > (RWBUFFER_SIZE_MB_MAX >> shift)) usageerr("buffer size too big"); + buffersize <<= shift; } else { usageerr("invalid option"); } } - buffersize= opt_buffersize*1024*1024; startupcore(); nonblock(0,1); nonblock(1,1); } diff --git a/cprogs/writebuffer.1 b/cprogs/writebuffer.1 index 796ba93..b3f28ab 100644 --- a/cprogs/writebuffer.1 +++ b/cprogs/writebuffer.1 @@ -12,6 +12,10 @@ will buffer internally up to \fIsize\fR megabytes and will only write data when the buffer is at least 75% full or when there is no more input to fill the buffer. .PP +\fIsize\fR may also be suffixed with +.BR m ", " k ", or " b +to indicate that it is in megabytes (2^20), kilobytes (2^10) or bytes. +.PP It is intended for use in situations where many small writes are undesirable for performance reasons, e.g. tape drives. .SH OPTIONS diff --git a/debian/changelog b/debian/changelog index 65c50f4..1e8592e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +chiark-utils (4.0.99.0.16) unstable; urgency=low + + * Size for readbuffer/writebuffer may be in k or bytes. + + -- Ian Jackson Sat, 21 May 2005 14:47:18 +0100 + chiark-utils (4.0.99.0.15) unstable; urgency=low * /etc/chiark-backup/snap/lvm (backup/lvm in the source tree) now