chiark / gitweb /
From Peter Maydell (/u2/pmaydell/iwjbackup/) as per <E156bwm-0005xq-00@watchdragon...
[chiark-utils.git] / backup / readbuffer.c
index 4cd31afb864ce6c966062038c9a5ad5631d5b57b..2513977a232b82aabb0c8c7fabc3fcefc8184c85 100644 (file)
@@ -1,4 +1,23 @@
-/**/
+/*
+ * readbuffer.c
+ *
+ * Copyright (C) 1997,1998 Ian Jackson <ian@chiark.greenend.org.uk>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this file; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
 
 #include <sys/time.h>
 #include <sys/types.h>
@@ -7,9 +26,9 @@
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
-#include <sys/mman.h>
 
-#define BUFFER 16*1024*1024
+/* was 16MB -- PMM */
+#define BUFFER 6*1024*1024
 #define WAITEMPTY ((BUFFER*1)/4)
 
 static inline int min(int a, int b) { return a<=b ? a : b; }
@@ -21,7 +40,7 @@ static void nonblock(int fd) {
   if (fcntl(fd,F_SETFL,r) == -1) { perror("fcntl setfl"); exit(1); }
 }
 
-int main(int argc, const char *const *argv) {
+int main(void) {
   static unsigned char buf[BUFFER];
   
   unsigned char *wp, *rp;
@@ -31,11 +50,6 @@ int main(int argc, const char *const *argv) {
 
   used=0; wp=rp=buf; reading=1; seeneof=0;
   nonblock(0); nonblock(1);
-  if (argv[1] && !strcmp(argv[1],"--mlock")) {
-    if (mlock(buf,sizeof(buf))) { perror("mlock"); exit(1); }
-    argv++; argc--;
-  }
-  if (argv[1]) { fputs("usage: readbuffer [--mlock]\n",stderr); exit(1); }
   while (!seeneof || used) {
     FD_ZERO(&readfds);
     if (reading) {