Lines 222-228
Link Here
|
222 |
temp = tv.tv_sec - prev_spit_s; |
222 |
temp = tv.tv_sec - prev_spit_s; |
223 |
if(((temp*1000000UL) + (tv.tv_usec - prev_spit_u) > 1000000UL)) { |
223 |
if(((temp*1000000UL) + (tv.tv_usec - prev_spit_u) > 1000000UL)) { |
224 |
unsigned long long thistime; |
224 |
unsigned long long thistime; |
225 |
int i, point1, point2; |
225 |
long i, point1, point2; |
226 |
switch(p_rate) { |
226 |
switch(p_rate) { |
227 |
case 1000 : units1 = "t/s"; |
227 |
case 1000 : units1 = "t/s"; |
228 |
break; |
228 |
break; |
Lines 309-315
Link Here
|
309 |
* if we get an error, go to WO mode |
309 |
* if we get an error, go to WO mode |
310 |
*/ |
310 |
*/ |
311 |
|
311 |
|
312 |
int retval, wantedbytes; |
312 |
int retval; |
|
|
313 |
long wantedbytes; |
313 |
retval = wantedbytes = 0; |
314 |
retval = wantedbytes = 0; |
314 |
|
315 |
|
315 |
if(readptr == bufsize) { |
316 |
if(readptr == bufsize) { |
Lines 373-380
Link Here
|
373 |
return 0; |
374 |
return 0; |
374 |
} |
375 |
} |
375 |
|
376 |
|
376 |
int bytes_to_write() { |
377 |
long bytes_to_write() { |
377 |
int wantedbytes = 0; |
378 |
long wantedbytes = 0; |
378 |
if(writeptr == bufsize) { |
379 |
if(writeptr == bufsize) { |
379 |
writeptr = 0; |
380 |
writeptr = 0; |
380 |
if(readptr == 0) |
381 |
if(readptr == 0) |
Lines 392-398
Link Here
|
392 |
debug("write type 2: "); |
393 |
debug("write type 2: "); |
393 |
} |
394 |
} |
394 |
if(cap) { |
395 |
if(cap) { |
395 |
int temp; |
396 |
long temp; |
396 |
temp = cap - run_avg_o; |
397 |
temp = cap - run_avg_o; |
397 |
temp -= written_this_time; |
398 |
temp -= written_this_time; |
398 |
if(temp < 0) { |
399 |
if(temp < 0) { |
Lines 415-421
Link Here
|
415 |
* also check to see if we can go to mode RW from mode BF |
416 |
* also check to see if we can go to mode RW from mode BF |
416 |
*/ |
417 |
*/ |
417 |
|
418 |
|
418 |
int retval, wantedbytes; |
419 |
int retval; |
|
|
420 |
long wantedbytes; |
419 |
retval = 0; |
421 |
retval = 0; |
420 |
|
422 |
|
421 |
if(writeptr == 0) { |
423 |
if(writeptr == 0) { |
Lines 520-531
Link Here
|
520 |
|
522 |
|
521 |
/* the main program *gasp* */ |
523 |
/* the main program *gasp* */ |
522 |
int main(int argc, char *argv[]) { |
524 |
int main(int argc, char *argv[]) { |
523 |
int finished, retval, filenames, maxval, capping, should_fork; |
525 |
long finished, retval, maxval, capping, should_fork; |
524 |
fd_set readfds, writefds, exceptfds; |
526 |
fd_set readfds, writefds, exceptfds; |
525 |
struct timeval thetime; |
527 |
struct timeval thetime; |
526 |
char *optstr, tch; |
528 |
char *optstr, tch; |
527 |
char *opt_bufsize, *opt_timeout, *opt_cap, *opt_throttle, *opt_min, *opt_init, *opt_progress, *outdev; |
529 |
char *opt_bufsize, *opt_timeout, *opt_cap, *opt_throttle, *opt_min, *opt_init, *opt_progress, *outdev; |
528 |
int temp; |
530 |
long temp; |
529 |
|
531 |
|
530 |
/* defaults */ |
532 |
/* defaults */ |
531 |
opt_min = "10%"; |
533 |
opt_min = "10%"; |
Lines 545-551
Link Here
|
545 |
writeptr = 0; |
547 |
writeptr = 0; |
546 |
readptr = 0; |
548 |
readptr = 0; |
547 |
total_written = 0; |
549 |
total_written = 0; |
548 |
filenames = 0; |
|
|
549 |
mystate = IN; |
550 |
mystate = IN; |
550 |
stdin_mode = 1; |
551 |
stdin_mode = 1; |
551 |
#ifdef DEBUG |
552 |
#ifdef DEBUG |
Lines 704-710
Link Here
|
704 |
if(should_fork) { |
705 |
if(should_fork) { |
705 |
int mypipe[2], rv; |
706 |
int mypipe[2], rv; |
706 |
verbose("forking\n"); |
707 |
verbose("forking\n"); |
707 |
pipe(mypipe); |
708 |
if(pipe(mypipe)) |
|
|
709 |
exit(fprintf(stderr,"No pipe!\n")); |
708 |
rv = fork(); |
710 |
rv = fork(); |
709 |
if(!rv) { |
711 |
if(!rv) { |
710 |
bufsize = 10240; |
712 |
bufsize = 10240; |
Lines 727-733
Link Here
|
727 |
infd = open(argv[my_optind],O_RDONLY); |
729 |
infd = open(argv[my_optind],O_RDONLY); |
728 |
if(infd == -1) |
730 |
if(infd == -1) |
729 |
exit(fprintf(stderr,"Cannot open file: %s\n",argv[my_optind])); |
731 |
exit(fprintf(stderr,"Cannot open file: %s\n",argv[my_optind])); |
730 |
verbose("opening file %s: %i\n",argv[my_optind],infd); |
732 |
verbose("opening file %s: %li\n",argv[my_optind],infd); |
731 |
stdin_mode = 0; |
733 |
stdin_mode = 0; |
732 |
} |
734 |
} |
733 |
my_optind++; |
735 |
my_optind++; |
Lines 735-741
Link Here
|
735 |
|
737 |
|
736 |
buffer = (char *)malloc(bufsize); |
738 |
buffer = (char *)malloc(bufsize); |
737 |
if(buffer == NULL) { |
739 |
if(buffer == NULL) { |
738 |
fprintf(stderr,"malloc()ing a buffer of size %i failed!\n",bufsize); |
740 |
fprintf(stderr,"malloc()ing a buffer of size %li failed!\n",bufsize); |
739 |
fprintf(stderr,"Perhaps you don't have enough memory, perhaps you've\n"); |
741 |
fprintf(stderr,"Perhaps you don't have enough memory, perhaps you've\n"); |
740 |
fprintf(stderr,"exceeded a memory usage quota.\n"); |
742 |
fprintf(stderr,"exceeded a memory usage quota.\n"); |
741 |
exit(1); |
743 |
exit(1); |
Lines 869-875
Link Here
|
869 |
if(my_optind < argc) { |
871 |
if(my_optind < argc) { |
870 |
if(strcmp("-",argv[my_optind])) { |
872 |
if(strcmp("-",argv[my_optind])) { |
871 |
infd = open(argv[my_optind],O_RDONLY|O_NONBLOCK); |
873 |
infd = open(argv[my_optind],O_RDONLY|O_NONBLOCK); |
872 |
verbose("opening file %s: %i\n",argv[my_optind],infd); |
874 |
verbose("opening file %s: %li\n",argv[my_optind],infd); |
873 |
if(infd == -1) |
875 |
if(infd == -1) |
874 |
perror(NAME); |
876 |
perror(NAME); |
875 |
} else { |
877 |
} else { |