#undef PAGE_MASK
#define PAGE_MASK (PAGE_SIZE - 1)
+// On Windows, we need to open the files using O_BINARY, otherwise certain
+// characters will get translated (e.g. LF to CRLF), which can corrupt our
+// payload.
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
char *original_buf; /* a pointer to the original data */
char *good_buf; /* a pointer to the correct data */
void
check_eofpage(char *s, unsigned offset, char *p, int size)
{
- unsigned long last_page, should_be_zero;
+ uintptr_t last_page, should_be_zero;
if (offset + size <= (file_size & ~page_mask))
return;
* beyond the true end of the file mapping
* (as required by mmap def in 1996 posix 1003.1)
*/
- last_page = ((unsigned long)p + (offset & page_mask) + size) & ~page_mask;
+ last_page = ((uintptr_t)p + (offset & page_mask) + size) & ~page_mask;
for (should_be_zero = last_page + (file_size & page_mask);
should_be_zero < last_page + page_size;
}
clone_filename(filename, sizeof(filename), num_clones);
- if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) {
+ if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) < 0) {
simple_err("do_clone: open", -errno);
exit(162);
}
}
clone_filename(filename, sizeof(filename), clonenum + 1);
- if ((fd = open(filename, O_RDONLY)) < 0) {
+ if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0) {
simple_err("check_clone: open", -errno);
exit(168);
}
unlink(filename);
}
- free(good_buf);
- free(temp_buf);
+ aligned_free(good_buf);
+ aligned_free(temp_buf);
}
void
strcat(dirpath, ".");
strncat(goodfile, iname, 256);
strcat (goodfile, ".fsxgood");
- fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fsxgoodfd = open(goodfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0666);
if (fsxgoodfd < 0) {
prterr(goodfile);
exit(92);
rados_shutdown(cluster);
free(original_buf);
- free(good_buf);
- free(temp_buf);
+ aligned_free(good_buf);
+ aligned_free(temp_buf);
exit(0);
return 0;