diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index b33f0b4..c05883e 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -177,7 +177,11 @@ rewriteVisibilityMap(const char *fromfile, const char *tofile)
 	if ((fromfile == NULL) || (tofile == NULL))
 		return "Invalid old file or new file";
 
+#ifndef WIN32
 	if ((src_fd = open(fromfile, O_RDONLY, 0)) < 0)
+#else
+	if ((src_fd = open(fromfile, O_RDONLY | O_BINARY)) < 0)
+#endif
 		return getErrorText();
 
 	if (fstat(src_fd, &statbuf) != 0)
@@ -213,6 +217,11 @@ rewriteVisibilityMap(const char *fromfile, const char *tofile)
 		{
 			close(dst_fd);
 			close(src_fd);
+
+			pg_log(PG_WARNING,
+				   "could not read expected bytes: read = %u, expected = %u\n",
+				   BLCKSZ, bytesRead);
+
 			return getErrorText();
 		}
 
