#include <u.h>
#include <libc.h>
#define min(a, b) (a) < (b) ? a : b
int
main(int argc, char **argv) {
ulong off, len;
uchar buf[32*1024];
int s, t;
if(argc < 3)
exits("missing arguments");
off = atol(argv[1]);
len = atol(argv[2]) - off;
seek(0, off, 0);
while(len > 0){
s = read(0, buf, min(sizeof(buf), len));
if(s < 0)
exits("read error");
len -= s;
t = write(1, buf, s);
if(t != s)
exits("write error");
}
exits(nil);
return 0;
}
|