// // Created by haraldwolff on 21.08.22. // #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]){ int f1 = open(argv[1], O_RDWR); if (f1 < 0) { printf("could not open %s (%s)\n", argv[1], strerror(errno)); exit(EXIT_FAILURE); } long size1 = lseek(f1, 0, SEEK_END); void *mm1 = mmap(NULL, size1, PROT_READ | PROT_WRITE, MAP_SHARED, f1, 0); if (mm1 == MAP_FAILED){ printf("could not mmap file."); exit(EXIT_FAILURE); } int f2 = open(argv[2], O_RDWR); if (f2 < 0) { printf("could not open %s (%s)\n", argv[2], strerror(errno)); exit(EXIT_FAILURE); } long size2 = lseek(f2, 0, SEEK_END); void *mm2 = mmap(NULL, size2, PROT_READ | PROT_WRITE, MAP_SHARED, f2, 0); if (mm2 == MAP_FAILED){ printf("could not mmap file."); exit(EXIT_FAILURE); } long offset = 0; u_int64_t *t1 = (u_int64_t *)mm1; u_int64_t *t2 = (u_int64_t *)mm2; while (offset < size1) { uint64_t h1 = dhash( &t1[(offset >> 3)], 4096); uint64_t h2 = dhash( &t2[(offset >> 3)], 4096); if (h1 != h2) { fprintf(stdout,"\r%0lx %0lx %0lx\n", offset, h1, h2); fflush(stdout); } offset += 4096; fprintf(stdout, "\roffset: 0x%llx %d%%", offset, (100 * offset / size1)); fflush(stdout); } munmap(mm1, size1); munmap(mm2, size2); close(f1); close(f2); }