// mmap example code // (compile with gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE to // enable large file support) // Note that we do not need to use mmap64 once we use these -D options. /* large file mmap test */ #include #include #include #include #include int main (int argc, char *argv[]) { int fd; char *fpointer; struct stat filestat; fd=open(argv[1],O_RDONLY); perror("open"); fstat(fd,&filestat); perror ("fstat"); printf ("file is %u bytes long\n",filestat.st_size); mmap (0,10000000,PROT_READ, MAP_SHARED,fd,0); perror ("mmap"); return (0); }