chiark / gitweb /
@@ -1,3 +1,9 @@ debian_version_4_0_99_0_16
authorianmdlvl <ianmdlvl>
Sat, 21 May 2005 13:47:28 +0000 (13:47 +0000)
committerianmdlvl <ianmdlvl>
Sat, 21 May 2005 13:47:28 +0000 (13:47 +0000)
+chiark-utils (4.0.99.0.16) unstable; urgency=low
+
+  * Size for readbuffer/writebuffer may be in k or bytes.
+
+ -- Ian Jackson <ian@davenant.greenend.org.uk>  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

cprogs/readbuffer.1
cprogs/rwbuffer.c
cprogs/writebuffer.1
debian/changelog

index 361faea93c96ede864571dedc235816ae0fad8da..18f6214f25c30a5ac2cd6efc4e69a274066f6056 100644 (file)
@@ -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
index f2ec48da0e5a00086b8884e8e1afc0de36f8d6d7..ee97fca6bac443802b18194127bc58e42822fc9b 100644 (file)
@@ -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);
 }
index 796ba93435cd1ab6afde69ed6d8dffd8dd76da3b..b3f28ab6bd4c013151cb4390259d0de62c4f0ea8 100644 (file)
@@ -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
index 65c50f4a59fb3cde1a396a2e8245dfdf63cd20b0..1e8592e9bfdce7daefb1a06e724342c41cad0db5 100644 (file)
@@ -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 <ian@davenant.greenend.org.uk>  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