*** 3000test.c 2021-02-24 16:49:19.000000000 -0500 --- 3000test-dir-nommap.c 2025-03-16 23:04:18.701254629 -0400 *************** *** 13,18 **** --- 13,20 ---- #include #include #include + #include + #include void report_error(char *error) { *************** *** 23,32 **** int main(int argc, char *argv[]) { ! struct stat statbuf; ! char *fn; int fd; ! size_t len, i, count; char *data; --- 25,33 ---- int main(int argc, char *argv[]) { ! char *fn, fna[256]; int fd; ! size_t len, i, count, bytesread, bytestoread; char *data; *************** *** 42,81 **** fn = argv[1]; ! if (stat(fn, &statbuf)) { ! report_error(strerror(errno)); ! } ! ! len = statbuf.st_size; printf("File %s: \n", fn); ! printf(" inode %ld\n", statbuf.st_ino); ! printf(" length %ld\n", len); ! if (S_ISREG(statbuf.st_mode)) { fd = open(fn, O_RDONLY); if (fd == -1) { report_error(strerror(errno)); } - data = (char *) mmap(NULL, len, - PROT_READ, MAP_SHARED, fd, 0); - if (data == MAP_FAILED) { - report_error(strerror(errno)); - } count = 0; ! for (i=0; id_name)) { ! ! printf("File %s: \n", fn); ! printf(" inode %ld\n", e->d_fileno); ! if (e->d_type == DT_REG) { fd = open(fn, O_RDONLY); if (fd == -1) { report_error(strerror(errno)); } count = 0; ! bytesread = bytestoread = 128*1024; ! while (bytesread == bytestoread) { ! data = malloc(bytestoread); ! bytesread = read(fd, data, bytestoread); ! ! for (i=0; i