Browse Source

Plan 9 from Bell Labs 2014-03-21

David du Colombier 10 years ago
parent
commit
21e0828194
2 changed files with 38 additions and 3 deletions
  1. 26 0
      sys/man/1/pump
  2. 12 3
      sys/src/cmd/pump.c

+ 26 - 0
sys/man/1/pump

@@ -25,6 +25,12 @@ pump \- copy asynchronously via a large circular buffer
 .B -s
 .I start-KB
 ] [
+.B -S
+.I off
+] [
+.B -t
+.I minutes
+] [
 .I file
 \&... ]
 .SH DESCRIPTION
@@ -93,6 +99,19 @@ bytes.
 prevents output until
 .I start-KB
 kilobytes have been read.
+.TP
+.B -S
+seeks both input and output files to
+.I off
+before copying.
+.TP
+.B -t
+stops output after
+.I minutes
+have passed.
+This assumes that
+.I pump
+can copy 10,584,000 bytes per minute.
 .SH EXAMPLES
 Append a
 .IR venti (8)
@@ -117,3 +136,10 @@ venti/rdarena arena0 arena.3 |
 .I Pump
 processes spin while waiting for the circular buffer
 to fill or drain.
+.PP
+.IR Dd ,
+.IR ecp
+and
+.I pump
+occupy slightly different niches
+but perhaps some simplification is possible.

+ 12 - 3
sys/src/cmd/pump.c

@@ -17,6 +17,7 @@ int	done;
 int	ibsize;
 int	obsize;
 int	verb;
+vlong	off;
 
 void	doinput(int);
 void	dooutput(int);
@@ -24,9 +25,9 @@ void	dooutput(int);
 static void
 usage(void)
 {
-	fprint(2, "usage: pump [-f ofile] [-k KB-buffer] [-i ireadsize]\n"
-		"\t[-o owritesize] [-b iando] [-s start-KB] [-d sleeptime] "
-		"[files]\n");
+	fprint(2, "usage: pump [-b iando] [-d sleeptime] [-f ofile] "
+		"[-i ireadsize]\n\t[-k KB-buffer] [-o owritesize] "
+		"[-s start-KB] [-S seek-offset]\n\t[-t mins] [files]\n");
 	exits("usage");
 }
 
@@ -40,6 +41,7 @@ main(int argc, char *argv[])
 	obsize = ibsize = 8*1024;
 	dsize = 0;
 	fo = 1;
+	off = 0;
 
 	ARGBEGIN {
 	default:
@@ -71,6 +73,11 @@ main(int argc, char *argv[])
 			ssize = 800;
 		ssize <<= 10;
 		break;
+	case 'S':
+		off = atoll(EARGF(usage()));
+		if(off < 0)
+			sysfatal("seek offset %lld must be non-negative", off);
+		break;
 	case 't':
 		tsize = atoll(EARGF(usage()));
 		tsize *= 10584000;		/* minutes */
@@ -129,6 +136,7 @@ dooutput(int f)
 {
 	long n, l, c;
 
+	seek(f, off, 0);
 	lock(&arithlock);
 	for (;;) {
 		n = nin - nout;
@@ -171,6 +179,7 @@ doinput(int f)
 {
 	long n, l, c, xnin;
 
+	seek(f, off, 0);
 	lock(&arithlock);
 	if(ssize > 0) {
 		for (xnin = 0; xnin < ssize && !done; xnin += c) {