resolve merge conflicts of d254ce4 to master

Change-Id: Ia8dff82cb7648b568006d10bc99e2dd40a2d6e8e
diff --git a/BenchmarkGen.h b/BenchmarkGen.h
index 8a4f68b..cd95aae 100644
--- a/BenchmarkGen.h
+++ b/BenchmarkGen.h
@@ -211,7 +211,7 @@
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 30, 32521955));
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 45, 32521985));
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 6350, 32518144)); // mmap2
-int  t3450f18 = TEMP_FAILURE_RETRY(open("file11", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+int  t3450f18 = TEMP_FAILURE_RETRY(open("file11", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 int  t3450f22 = TEMP_FAILURE_RETRY(open("file12", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3450f22, buf, 1));
 close(t3450f22);
@@ -219,7 +219,7 @@
 close(t3450f22);
 t3450f22 = TEMP_FAILURE_RETRY(open("file14", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3450f22);
-t3450f22 = TEMP_FAILURE_RETRY(open("file15", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3450f22 = TEMP_FAILURE_RETRY(open("file15", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3450f22, buf, 1));
 TEMP_FAILURE_RETRY(fsync(t3450f22));
 close(t3450f22);
@@ -390,7 +390,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 22960, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4108, 20480)); // mmap2
 close(t3455f18);
-t3455f18 = TEMP_FAILURE_RETRY(open("file11", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3455f18 = TEMP_FAILURE_RETRY(open("file11", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 3513185));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 46, 3513215));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3262, 3510272)); // mmap2
@@ -404,7 +404,7 @@
 close(t3455f19);
 t3455f19 = TEMP_FAILURE_RETRY(open("file14", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3455f19);
-t3455f19 = TEMP_FAILURE_RETRY(open("file15", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3455f19 = TEMP_FAILURE_RETRY(open("file15", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3455f19, buf, 1));
 TEMP_FAILURE_RETRY(fsync(t3455f19));
 close(t3455f19);
@@ -415,7 +415,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 13748, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4196, 12288)); // mmap2
 close(t3455f18);
-int  t3483f20 = TEMP_FAILURE_RETRY(open("file17", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3483f20 = TEMP_FAILURE_RETRY(open("file17", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 100, 0));
 int  t3483f21 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3483f21, buf, 1, 0));
@@ -467,7 +467,7 @@
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 49152));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 139264));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 172032));
-int  t3483f25 = TEMP_FAILURE_RETRY(open("file19", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3483f25 = TEMP_FAILURE_RETRY(open("file19", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 100, 0));
 int  t3483f26 = TEMP_FAILURE_RETRY(open("file20", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3483f26, buf, 1, 0));
@@ -550,7 +550,7 @@
 int  t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f30, buf, 1, 0));
 close(t3499f30);
-int  t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4096, 516));
@@ -574,7 +574,7 @@
 t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f30, buf, 1, 0));
 close(t3499f30);
-t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4096, 516));
@@ -786,7 +786,7 @@
 t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f31, buf, 1, 0));
 close(t3499f31);
-t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4096, 516));
@@ -813,7 +813,7 @@
 t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f31, buf, 1, 0));
 close(t3499f31);
-t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4096, 516));
@@ -837,7 +837,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f31));
 close(t3499f31);
-int  t3492f31 = TEMP_FAILURE_RETRY(open("file30", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3492f31 = TEMP_FAILURE_RETRY(open("file30", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 100, 0));
 int  t3492f32 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f32, buf, 1, 0));
@@ -883,7 +883,7 @@
 t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f30, buf, 1, 0));
 close(t3499f30);
-t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4096, 516));
@@ -910,7 +910,7 @@
 t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f30, buf, 1, 0));
 close(t3499f30);
-t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4096, 516));
@@ -937,7 +937,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 36389306));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 23, 36389336));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1664, 36388864)); // mmap2
-t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4096, 516));
@@ -1049,7 +1049,7 @@
 int  t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f41, buf, 1, 0));
 close(t3499f41);
-t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f41, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f41, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f41, buf, 4096, 516));
@@ -1076,7 +1076,7 @@
 t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f41, buf, 1, 0));
 close(t3499f41);
-t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f41, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f41, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f41, buf, 4096, 516));
@@ -1111,7 +1111,7 @@
 close(t3492f40);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 4096, 36864));
-t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 516));
@@ -1138,7 +1138,7 @@
 t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 1, 0));
 close(t3499f40);
-t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 516));
@@ -1165,7 +1165,7 @@
 t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 1, 0));
 close(t3499f40);
-t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 516));
@@ -1210,7 +1210,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35636928));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 60, 35636958));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2062, 35635200)); // mmap2
-t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 516));
@@ -1237,7 +1237,7 @@
 t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 1, 0));
 close(t3499f40);
-t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 516));
@@ -1279,7 +1279,7 @@
 int  t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f33, buf, 1, 0));
 close(t3499f33);
-t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 4096, 516));
@@ -1306,7 +1306,7 @@
 t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f33, buf, 1, 0));
 close(t3499f33);
-t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 4096, 516));
@@ -1474,7 +1474,7 @@
 int  t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f50, buf, 1, 0));
 close(t3499f50);
-t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 4096, 516));
@@ -1501,7 +1501,7 @@
 t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f50, buf, 1, 0));
 close(t3499f50);
-t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 4096, 516));
@@ -1796,7 +1796,7 @@
 int  t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f55, buf, 1, 0));
 close(t3499f55);
-t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
@@ -1834,8 +1834,8 @@
 TEMP_FAILURE_RETRY(read(t3532f55, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3532f55, buf, 16384));
 close(t3532f55);
-t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
-int  t3505f56 = TEMP_FAILURE_RETRY(open("file59", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
+int  t3505f56 = TEMP_FAILURE_RETRY(open("file59", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
@@ -1863,7 +1863,7 @@
 int  t3499f58 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f58, buf, 1, 0));
 close(t3499f58);
-t3499f58 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f58 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f58, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f58, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f58, buf, 4096, 516));
@@ -1896,7 +1896,7 @@
 t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f55, buf, 1, 0));
 close(t3499f55);
-t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
@@ -1923,7 +1923,7 @@
 t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f55, buf, 1, 0));
 close(t3499f55);
-t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
@@ -2012,7 +2012,7 @@
 t3505f56 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f56, buf, 1, 0));
 close(t3505f56);
-t3505f56 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3505f56 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4096, 516));
@@ -2035,7 +2035,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4, 21032));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4096, 21036));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4, 25132));
-t3499f62 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f62 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 4096, 516));
@@ -2133,7 +2133,7 @@
 int  t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f66, buf, 1, 0));
 close(t3499f66);
-t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4096, 516));
@@ -2196,7 +2196,7 @@
 TEMP_FAILURE_RETRY(read(t3532f61, buf, 16384));
 close(t3532f61);
 t3533f61 = TEMP_FAILURE_RETRY(open("file68", O_RDONLY|O_LARGEFILE));
-t3499f62 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f62 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 512, 0));
 TEMP_FAILURE_RETRY(read(t3533f61, buf, 16384));
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 4, 512));
@@ -2235,7 +2235,7 @@
 int  t3499f80 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f80, buf, 1, 0));
 close(t3499f80);
-t3499f80 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f80 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f80, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f80, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f80, buf, 4096, 516));
@@ -2259,7 +2259,7 @@
 t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f66, buf, 1, 0));
 close(t3499f66);
-t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4096, 516));
@@ -2403,12 +2403,12 @@
 close(t3519f67);
 t3519f67 = TEMP_FAILURE_RETRY(open("file127", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f67);
-t3519f70 = TEMP_FAILURE_RETRY(open("file128", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+t3519f70 = TEMP_FAILURE_RETRY(open("file128", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3519f70);
-int  t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
-int  t3519f75 = TEMP_FAILURE_RETRY(open("file128", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+int  t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int  t3519f75 = TEMP_FAILURE_RETRY(open("file128", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 close(t3526f70);
-t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3519f75, buf, 2991));
 close(t3519f75);
 TEMP_FAILURE_RETRY(write(t3526f70, buf, 3974));
@@ -2419,7 +2419,7 @@
 TEMP_FAILURE_RETRY(pread(t3499f72, buf, 1, 0));
 close(t3499f72);
 TEMP_FAILURE_RETRY(read(t3519f67, buf, 16384));
-t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4096, 516));
@@ -2441,26 +2441,26 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f72));
 close(t3499f72);
-t3526f70 = TEMP_FAILURE_RETRY(open("file131", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+t3526f70 = TEMP_FAILURE_RETRY(open("file131", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f70);
-t3526f70 = TEMP_FAILURE_RETRY(open("file131", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f70 = TEMP_FAILURE_RETRY(open("file131", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f70, buf, 4622));
 close(t3526f70);
-int  t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f72);
-t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f72, buf, 16384));
 TEMP_FAILURE_RETRY(write(t3526f72, buf, 6849));
 close(t3526f72);
-t3526f70 = TEMP_FAILURE_RETRY(open("file133", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+t3526f70 = TEMP_FAILURE_RETRY(open("file133", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f70);
-int  t3526f75 = TEMP_FAILURE_RETRY(open("file133", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+int  t3526f75 = TEMP_FAILURE_RETRY(open("file133", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f75, buf, 13332));
 close(t3526f75);
 int  t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f70, buf, 1, 0));
 close(t3495f70);
-t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 4096, 516));
@@ -2481,9 +2481,9 @@
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3495f70));
 close(t3495f70);
-int  t3526f93 = TEMP_FAILURE_RETRY(open("file134", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3526f93 = TEMP_FAILURE_RETRY(open("file134", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f93);
-int  t3526f88 = TEMP_FAILURE_RETRY(open("file134", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+int  t3526f88 = TEMP_FAILURE_RETRY(open("file134", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f88, buf, 15056));
 close(t3526f88);
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34433108));
@@ -2498,7 +2498,7 @@
 t3495f75 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f75, buf, 1, 0));
 close(t3495f75);
-t3495f75 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3495f75 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3495f75, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3495f75, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3495f75, buf, 4096, 516));
@@ -2522,7 +2522,7 @@
 int  t3499f74 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f74, buf, 1, 0));
 close(t3499f74);
-t3499f74 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f74 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 4096, 516));
@@ -2543,15 +2543,15 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f74));
 close(t3499f74);
-int  t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f64);
-t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f64, buf, 16384));
 TEMP_FAILURE_RETRY(write(t3526f64, buf, 4873));
 close(t3526f64);
-int  t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f90);
-t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 4199));
 close(t3526f90);
 int  t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@@ -2560,7 +2560,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35511105));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 28, 35511135));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3217, 35508224)); // mmap2
-t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35511441));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 40, 35511471));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
@@ -2596,7 +2596,7 @@
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
-t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4096, 516));
@@ -2623,7 +2623,7 @@
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
-t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4096, 516));
@@ -2650,11 +2650,11 @@
 int  t3499f84 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f84, buf, 1, 0));
 close(t3499f84);
-t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4096, 516));
-int  t3495f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3495f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 4612));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 4616));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4096, 4620));
@@ -2701,7 +2701,7 @@
 int  t3495f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f66, buf, 1, 0));
 close(t3495f66);
-t3495f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3495f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3495f66, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3495f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3495f66, buf, 4096, 516));
@@ -2725,7 +2725,7 @@
 t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f66, buf, 1, 0));
 close(t3499f66);
-t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4096, 516));
@@ -2753,7 +2753,7 @@
 int  t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f66, buf, 1, 0));
 close(t3505f66);
-t3505f66 = TEMP_FAILURE_RETRY(open("file138", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3505f66 = TEMP_FAILURE_RETRY(open("file138", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 t3526f70 = TEMP_FAILURE_RETRY(open("file139", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3526f70, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3526f70, buf, 16384));
@@ -2764,7 +2764,7 @@
 t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f70, buf, 1, 0));
 close(t3495f70);
-t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 4096, 516));
@@ -2786,19 +2786,19 @@
 TEMP_FAILURE_RETRY(fdatasync(t3495f70));
 close(t3495f70);
 TEMP_FAILURE_RETRY(write(t3505f66, buf, 10592));
-int  t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f70);
-t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3533f70, buf, 4042));
 close(t3533f70);
 TEMP_FAILURE_RETRY(write(t3505f66, buf, 9664));
 TEMP_FAILURE_RETRY(write(t3505f66, buf, 23656));
-t3533f70 = TEMP_FAILURE_RETRY(open("file141", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+t3533f70 = TEMP_FAILURE_RETRY(open("file141", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f70);
-t3526f70 = TEMP_FAILURE_RETRY(open("file142", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
-int  t3533f72 = TEMP_FAILURE_RETRY(open("file141", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f70 = TEMP_FAILURE_RETRY(open("file142", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int  t3533f72 = TEMP_FAILURE_RETRY(open("file141", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 close(t3526f70);
-t3526f70 = TEMP_FAILURE_RETRY(open("file142", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f70 = TEMP_FAILURE_RETRY(open("file142", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f70, buf, 5057));
 TEMP_FAILURE_RETRY(write(t3533f72, buf, 4595));
 close(t3526f70);
@@ -2808,7 +2808,7 @@
 t3499f70 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f70, buf, 1, 0));
 close(t3499f70);
-t3499f70 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f70 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f70, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f70, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f70, buf, 4096, 516));
@@ -2836,7 +2836,7 @@
 t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f66, buf, 1, 0));
 close(t3505f66);
-t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4096, 516));
@@ -2872,7 +2872,7 @@
 t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f66, buf, 1, 0));
 close(t3505f66);
-t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4096, 516));
@@ -2923,9 +2923,9 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34261624));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 49, 34261654));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2993, 34258944)); // mmap2
-int  t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f91);
-t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 31210525));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 44, 31210555));
 TEMP_FAILURE_RETRY(write(t3533f91, buf, 16384));
@@ -2935,7 +2935,7 @@
 int  t3499f91 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f91, buf, 1, 0));
 close(t3499f91);
-t3499f91 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f91 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f91, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f91, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f91, buf, 4096, 516));
@@ -2959,7 +2959,7 @@
 int  t3505f84 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f84, buf, 1, 0));
 close(t3505f84);
-t3505f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3505f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 4096, 516));
@@ -2980,41 +2980,41 @@
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3505f84));
 close(t3505f84);
-int  t3533f102 = TEMP_FAILURE_RETRY(open("file144", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3533f102 = TEMP_FAILURE_RETRY(open("file144", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f102);
-t3533f72 = TEMP_FAILURE_RETRY(open("file144", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3533f72 = TEMP_FAILURE_RETRY(open("file144", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3533f72, buf, 5550));
 close(t3533f72);
-int  t3526f84 = TEMP_FAILURE_RETRY(open("file145", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3526f84 = TEMP_FAILURE_RETRY(open("file145", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f84);
-int  t3526f101 = TEMP_FAILURE_RETRY(open("file145", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+int  t3526f101 = TEMP_FAILURE_RETRY(open("file145", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f101, buf, 3612));
 close(t3526f101);
-t3526f90 = TEMP_FAILURE_RETRY(open("file146", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+t3526f90 = TEMP_FAILURE_RETRY(open("file146", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f90);
-t3526f90 = TEMP_FAILURE_RETRY(open("file146", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f90 = TEMP_FAILURE_RETRY(open("file146", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 5414));
-int  t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f96);
-t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 close(t3526f90);
 TEMP_FAILURE_RETRY(write(t3533f96, buf, 3834));
 close(t3533f96);
-int  t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3519f90);
-t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3519f90, buf, 3461));
-int  t3526f96 = TEMP_FAILURE_RETRY(open("file149", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3526f96 = TEMP_FAILURE_RETRY(open("file149", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f96);
 close(t3519f90);
-t3526f90 = TEMP_FAILURE_RETRY(open("file149", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3526f90 = TEMP_FAILURE_RETRY(open("file149", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 16384));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 12766));
 close(t3526f90);
-int  t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f90);
-t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
-int  t3505f96 = TEMP_FAILURE_RETRY(open("file151", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int  t3505f96 = TEMP_FAILURE_RETRY(open("file151", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 100, 0));
 TEMP_FAILURE_RETRY(write(t3533f90, buf, 10056));
 close(t3533f90);
@@ -3036,11 +3036,11 @@
 close(t3505f90);
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 16, 24));
 t3505f90 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
-int  t3533f99 = TEMP_FAILURE_RETRY(open("file153", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3533f99 = TEMP_FAILURE_RETRY(open("file153", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f99);
 TEMP_FAILURE_RETRY(pread(t3505f90, buf, 1, 0));
 close(t3505f90);
-t3533f90 = TEMP_FAILURE_RETRY(open("file153", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
+t3533f90 = TEMP_FAILURE_RETRY(open("file153", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 16, 24));
 TEMP_FAILURE_RETRY(write(t3533f90, buf, 13271));
 close(t3533f90);
@@ -3066,7 +3066,7 @@
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
-t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4096, 516));
@@ -3090,7 +3090,7 @@
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
-t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4096, 516));
@@ -3120,7 +3120,7 @@
 t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f92, buf, 1, 0));
 close(t3499f92);
-t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4096, 516));
@@ -3147,7 +3147,7 @@
 t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f92, buf, 1, 0));
 close(t3499f92);
-t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4096, 516));
@@ -3177,7 +3177,7 @@
 int  t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 1, 0));
 close(t3499f100);
-t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4096, 516));
@@ -3201,7 +3201,7 @@
 t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 1, 0));
 close(t3499f100);
-t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4096, 516));
@@ -3228,7 +3228,7 @@
 t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 1, 0));
 close(t3499f100);
-t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4096, 516));
@@ -3252,7 +3252,7 @@
 t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 1, 0));
 close(t3499f100);
-t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4096, 516));
@@ -3282,7 +3282,7 @@
 t3499f84 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f84, buf, 1, 0));
 close(t3499f84);
-int  t3499f27 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3499f27 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f27, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f27, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f27, buf, 4096, 516));
@@ -3309,7 +3309,7 @@
 t3499f27 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f27, buf, 1, 0));
 close(t3499f27);
-t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4096, 516));
@@ -3336,7 +3336,7 @@
 t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f92, buf, 1, 0));
 close(t3499f92);
-t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4096, 516));
@@ -3360,7 +3360,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f92));
 close(t3499f92);
-int  t3545f92 = TEMP_FAILURE_RETRY(open("file154", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3545f92 = TEMP_FAILURE_RETRY(open("file154", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 100, 0));
 int  t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f97, buf, 1, 0));
@@ -3402,7 +3402,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f97, buf, 1, 0));
 close(t3545f97);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 4096, 516));
@@ -3435,7 +3435,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f29, buf, 1, 0));
 close(t3545f29);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 4096, 516));
@@ -3460,7 +3460,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f97));
 close(t3545f97);
-int  t3575f29 = TEMP_FAILURE_RETRY(open("file16", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE));
+int  t3575f29 = TEMP_FAILURE_RETRY(open("file16", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0));
 TEMP_FAILURE_RETRY(write(t3575f29, buf, 17344));
 close(t3575f29);
 t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@@ -3471,7 +3471,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f29, buf, 1, 0));
 close(t3545f29);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-t3545f29 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3545f29 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 4096, 516));
@@ -3499,7 +3499,7 @@
 int  t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f26, buf, 1, 0));
 close(t3499f26);
-t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f26, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f26, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f26, buf, 4096, 516));
@@ -3523,7 +3523,7 @@
 t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f26, buf, 1, 0));
 close(t3499f26);
-int  t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 4096, 516));
@@ -3569,7 +3569,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f29, buf, 1, 0));
 close(t3545f29);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-t3545f29 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3545f29 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 4096, 516));
@@ -3598,7 +3598,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f84, buf, 1, 0));
 close(t3545f84);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-int  t3584f84 = TEMP_FAILURE_RETRY(open("file157", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3584f84 = TEMP_FAILURE_RETRY(open("file157", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 100, 0));
 int  t3584f90 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3584f90, buf, 1, 0));
@@ -3608,7 +3608,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f90, buf, 1, 0));
 close(t3545f90);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-t3545f90 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3545f90 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 4096, 516));
@@ -3657,7 +3657,7 @@
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 4096, 16384));
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 4096, 12288));
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 4096, 32768));
-t3545f99 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3545f99 = TEMP_FAILURE_RETRY(open("file155", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4096, 516));
@@ -3785,8 +3785,8 @@
 t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f28, buf, 1, 0));
 close(t3499f28);
-int  t3496f28 = TEMP_FAILURE_RETRY(open("file169", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE));
-int  t3499f103 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3496f28 = TEMP_FAILURE_RETRY(open("file169", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int  t3499f103 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f103, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f103, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f103, buf, 4096, 516));
@@ -3814,7 +3814,7 @@
 TEMP_FAILURE_RETRY(pread(t3499f106, buf, 1, 0));
 close(t3499f106);
 close(t3496f28);
-t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 4096, 516));
@@ -3835,7 +3835,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f28));
 close(t3499f28);
-int  t3541f103 = TEMP_FAILURE_RETRY(open("file170", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3541f103 = TEMP_FAILURE_RETRY(open("file170", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3541f103, buf, 100, 0));
 int  t3541f105 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3541f105, buf, 1, 0));
@@ -3872,7 +3872,7 @@
 int  t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f107, buf, 1, 0));
 close(t3499f107);
-t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f107, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f107, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f107, buf, 4096, 516));
@@ -3896,7 +3896,7 @@
 t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f107, buf, 1, 0));
 close(t3499f107);
-t3499f105 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+t3499f105 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f105, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f105, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f105, buf, 4096, 516));
@@ -3920,7 +3920,7 @@
 int  t3505f106 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f106, buf, 1, 0));
 close(t3505f106);
-int  t3540f107 = TEMP_FAILURE_RETRY(open("file173", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3540f107 = TEMP_FAILURE_RETRY(open("file173", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3540f107, buf, 100, 0));
 int  t3540f108 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3540f108, buf, 1, 0));
@@ -3968,7 +3968,7 @@
 t3499f108 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f108, buf, 1, 0));
 close(t3499f108);
-int  t3597f108 = TEMP_FAILURE_RETRY(open("file177", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC));
+int  t3597f108 = TEMP_FAILURE_RETRY(open("file177", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 100, 0));
 int  t3597f109 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3597f109, buf, 1, 0));
@@ -4035,7 +4035,7 @@
         LOG(ERROR) << "Failed to read random data";
         return -EIO;
     }
-    if ((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC))) < 0) {
+    if ((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644))) < 0) {
         PLOG(ERROR) << "Failed to open " << name;
         return -errno;
     }
@@ -4436,3 +4436,4 @@
 
 }  // namespace vold
 }  // namespace android
+
diff --git a/Loop.cpp b/Loop.cpp
index a5863b3..1127817 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -47,7 +47,7 @@
         struct loop_info64 li;
         int rc;
 
-        sprintf(filename, "/dev/block/loop%d", i);
+        snprintf(filename, sizeof(filename), "/dev/block/loop%d", i);
 
         if ((fd = open(filename, O_RDWR | O_CLOEXEC)) < 0) {
             if (errno != ENOENT) {
@@ -91,7 +91,7 @@
         struct loop_info64 li;
         int rc;
 
-        sprintf(filename, "/dev/block/loop%d", i);
+        snprintf(filename, sizeof(filename), "/dev/block/loop%d", i);
 
         if ((fd = open(filename, O_RDWR | O_CLOEXEC)) < 0) {
             if (errno != ENOENT) {
@@ -137,7 +137,7 @@
         int rc;
         char *secontext = NULL;
 
-        sprintf(filename, "/dev/block/loop%d", i);
+        snprintf(filename, sizeof(filename), "/dev/block/loop%d", i);
 
         /*
          * The kernel starts us off with 8 loop nodes, but more
diff --git a/Process.cpp b/Process.cpp
index 962a460..7dc0144 100644
--- a/Process.cpp
+++ b/Process.cpp
@@ -85,7 +85,7 @@
 
     // compute path to process's directory of open files
     char    path[PATH_MAX];
-    sprintf(path, "/proc/%d/fd", pid);
+    snprintf(path, sizeof(path), "/proc/%d/fd", pid);
     DIR *dir = opendir(path);
     if (!dir)
         return 0;
@@ -129,7 +129,7 @@
     FILE *file;
     char buffer[PATH_MAX + 100];
 
-    sprintf(buffer, "/proc/%d/maps", pid);
+    snprintf(buffer, sizeof(buffer), "/proc/%d/maps", pid);
     file = fopen(buffer, "r");
     if (!file)
         return 0;
@@ -155,7 +155,7 @@
     char    path[PATH_MAX];
     char    link[PATH_MAX];
 
-    sprintf(path, "/proc/%d/%s", pid, name);
+    snprintf(path, sizeof(path), "/proc/%d/%s", pid, name);
     if (readSymLink(path, link, sizeof(link)) && pathMatchesMountPoint(link, mountPoint)) 
         return 1;
     return 0;
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index e1ee96c..374e35f 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -584,11 +584,17 @@
                 _exit(0);
             }
             if (TEMP_FAILURE_RETRY(mount(storageSource.c_str(), "/storage",
-                    NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) {
+                    NULL, MS_BIND | MS_REC, NULL)) == -1) {
                 PLOG(ERROR) << "Failed to mount " << storageSource << " for "
                         << de->d_name;
                 _exit(1);
             }
+            if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL,
+                    MS_REC | MS_SLAVE, NULL)) == -1) {
+                PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for "
+                        << de->d_name;
+                _exit(1);
+            }
 
             // Mount user-specific symlink helper into place
             userid_t user_id = multiuser_get_user_id(uid);
@@ -1001,24 +1007,6 @@
 
     oldNumSec = info.st_size / 512;
 
-    unsigned long numImgSectors;
-    if (sb.c_opts & ASEC_SB_C_OPTS_EXT4)
-        numImgSectors = adjustSectorNumExt4(numSectors);
-    else
-        numImgSectors = adjustSectorNumFAT(numSectors);
-    /*
-     *  add one block for the superblock
-     */
-    SLOGD("Resizing from %lu sectors to %lu sectors", oldNumSec, numImgSectors + 1);
-    if (oldNumSec == numImgSectors + 1) {
-        SLOGW("Size unchanged; ignoring resize request");
-        return 0;
-    } else if (oldNumSec > numImgSectors + 1) {
-        SLOGE("Only growing is currently supported.");
-        close(fd);
-        return -1;
-    }
-
     /*
      * Try to read superblock.
      */
@@ -1044,10 +1032,26 @@
         return -1;
     }
 
+    unsigned long numImgSectors;
     if (!(sb.c_opts & ASEC_SB_C_OPTS_EXT4)) {
         SLOGE("Only ext4 partitions are supported for resize");
         errno = EINVAL;
         return -1;
+    } else {
+        numImgSectors = adjustSectorNumExt4(numSectors);
+    }
+
+    /*
+     *  add one block for the superblock
+     */
+    SLOGD("Resizing from %lu sectors to %lu sectors", oldNumSec, numImgSectors + 1);
+    if (oldNumSec == numImgSectors + 1) {
+        SLOGW("Size unchanged; ignoring resize request");
+        return 0;
+    } else if (oldNumSec > numImgSectors + 1) {
+        SLOGE("Only growing is currently supported.");
+        close(fd);
+        return -1;
     }
 
     if (Loop::resizeImageFile(asecFileName, numImgSectors + 1)) {
diff --git a/bench/benchgen.py b/bench/benchgen.py
index 9a2bcd7..c852169 100644
--- a/bench/benchgen.py
+++ b/bench/benchgen.py
@@ -183,7 +183,12 @@
                 if handle not in defined:
                     print >>bench, "int ",
                     defined.add(handle)
-                print >>bench, '%s = TEMP_FAILURE_RETRY(open("file%s", %s));' % (handle, f.ident, e.args[2])
+                create_mode = ''
+                if 'O_CREAT' in e.args[2]:
+                    assert len(e.args) > 3, 'File creation lacks a mode?'
+                    create_mode = ', ' + e.args[3]
+                print >>bench, '%s = TEMP_FAILURE_RETRY(open("file%s", %s%s));' \
+                        % (handle, f.ident, e.args[2], create_mode)
 
         elif e.call == "close":
             fd, f, handle = extract_file(e, e.args[0])
@@ -273,7 +278,7 @@
         LOG(ERROR) << "Failed to read random data";
         return -EIO;
     }
-    if ((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC))) < 0) {
+    if ((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644))) < 0) {
         PLOG(ERROR) << "Failed to open " << name;
         return -errno;
     }
diff --git a/cryptfs.c b/cryptfs.c
index 2a52336..258557c 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -1068,6 +1068,7 @@
   struct dm_target_spec *tgt;
   char *crypt_params;
   char master_key_ascii[129]; /* Large enough to hold 512 bit key and null */
+  size_t buff_offset;
   int i;
 
   io = (struct dm_ioctl *) buffer;
@@ -1093,8 +1094,11 @@
 
   crypt_params = buffer + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
   convert_key_to_hex_ascii(master_key, crypt_ftr->keysize, master_key_ascii);
-  sprintf(crypt_params, "%s %s 0 %s 0 %s", crypt_ftr->crypto_type_name,
-          master_key_ascii, real_blk_name, extra_params);
+
+  buff_offset = crypt_params - buffer;
+  snprintf(crypt_params, sizeof(buffer) - buff_offset, "%s %s 0 %s 0 %s",
+           crypt_ftr->crypto_type_name, master_key_ascii, real_blk_name,
+           extra_params);
   crypt_params += strlen(crypt_params) + 1;
   crypt_params = (char *) (((unsigned long)crypt_params + 7) & ~8); /* Align to an 8 byte boundary */
   tgt->next = crypt_params - buffer;
@@ -1448,7 +1452,7 @@
   /* Copy intermediate key if needed by params */
   if (intermediate_key && intermediate_key_size) {
     *intermediate_key = (unsigned char*) malloc(KEY_LEN_BYTES);
-    if (intermediate_key) {
+    if (*intermediate_key) {
       memcpy(*intermediate_key, ikey, KEY_LEN_BYTES);
       *intermediate_key_size = KEY_LEN_BYTES;
     }
@@ -1889,7 +1893,8 @@
   } else {
     /* Try mounting the file system anyway, just in case the problem's with
      * the footer, not the key. */
-    sprintf(tmp_mount_point, "%s/tmp_mnt", mount_point);
+    snprintf(tmp_mount_point, sizeof(tmp_mount_point), "%s/tmp_mnt",
+             mount_point);
     mkdir(tmp_mount_point, 0755);
     if (fs_mgr_do_mount(fstab, DATA_MNT_POINT, crypto_blkdev, tmp_mount_point)) {
       SLOGE("Error temp mounting decrypted block device\n");
diff --git a/fs/Vfat.cpp b/fs/Vfat.cpp
index 38681c9..1803c4b 100644
--- a/fs/Vfat.cpp
+++ b/fs/Vfat.cpp
@@ -139,7 +139,7 @@
     flags |= (ro ? MS_RDONLY : 0);
     flags |= (remount ? MS_REMOUNT : 0);
 
-    sprintf(mountData,
+    snprintf(mountData, sizeof(mountData),
             "utf8,uid=%d,gid=%d,fmask=%o,dmask=%o,shortname=mixed",
             ownerUid, ownerGid, permMask, permMask);