From: Steve Lord Date: Tue, 18 Jun 2002 11:55:12 +0000 (+0000) Subject: make this run at a reasonable speed - say a few hundred times faster X-Git-Tag: v1.1.0~1077 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea2c992037b5b9d5bac9d21e0fa26409e59c0725;p=xfstests-dev.git make this run at a reasonable speed - say a few hundred times faster --- diff --git a/src/mmapcat.c b/src/mmapcat.c index 3784d3b8..845916c8 100644 --- a/src/mmapcat.c +++ b/src/mmapcat.c @@ -1,26 +1,31 @@ /* mmapcat.c - derived from source by misiek@pld.ORG.PL */ -#include +#include #include -#include #include #include #include int main(int argc, char **argv) { - int fd; - char *ptr; - struct stat64 st; + int fd,n; + char *ptr, *ptr2; + struct stat st; - fd = open(argv[1], O_RDONLY); - if (fd < 0) { + fd=open(argv[1],O_RDONLY); + if(fd<0) { perror(argv[1]); exit(1); } - fstat64(fd, &st); - ptr = mmap64(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - while (*ptr != 0) - write(1, ptr++, 1); + fstat(fd,&st); + if(st.st_size%4096==0) { + fprintf(stderr,"bad file size!\n"); + exit(1); + } + + ptr2 = ptr = mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,fd,0); + while (*ptr!=0) ptr++; + write(1,ptr2,ptr - ptr2); exit(0); } +