Skip to content

Commit 69138a9

Browse files
committed
Add permission mode to opens().
1 parent bfaa9a0 commit 69138a9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/tools/fsync/test_fsync.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
3939
printf("Simple write timing:\n");
4040
/* write only */
4141
gettimeofday(&start_t, NULL);
42-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1)
42+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT, 0600)) == -1)
4343
die("can't open /var/tmp/test_fsync.out");
4444
write(tmpfile, &strout, 200);
4545
close(tmpfile);
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
5252
printf("Compare fsync before and after write's close:\n");
5353
/* write, fsync, close */
5454
gettimeofday(&start_t, NULL);
55-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1)
55+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT, 0600)) == -1)
5656
die("can't open /var/tmp/test_fsync.out");
5757
write(tmpfile, &strout, 200);
5858
fsync(tmpfile);
@@ -65,12 +65,12 @@ int main(int argc, char *argv[])
6565

6666
/* write, close, fsync */
6767
gettimeofday(&start_t, NULL);
68-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1)
68+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT, 0600)) == -1)
6969
die("can't open /var/tmp/test_fsync.out");
7070
write(tmpfile, &strout, 200);
7171
close(tmpfile);
7272
/* reopen file */
73-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1)
73+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT, 0600)) == -1)
7474
die("can't open /var/tmp/test_fsync.out");
7575
fsync(tmpfile);
7676
close(tmpfile);
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
8585
#ifdef OPEN_DATASYNC_FLAG
8686
/* open_dsync, write */
8787
gettimeofday(&start_t, NULL);
88-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT | O_DSYNC)) == -1)
88+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT | O_DSYNC, 0600)) == -1)
8989
die("can't open /var/tmp/test_fsync.out");
9090
write(tmpfile, &strout, 200);
9191
close(tmpfile);
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
9898

9999
/* open_fsync, write */
100100
gettimeofday(&start_t, NULL);
101-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT | OPEN_SYNC_FLAG)) == -1)
101+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT | OPEN_SYNC_FLAG, 0600)) == -1)
102102
die("can't open /var/tmp/test_fsync.out");
103103
write(tmpfile, &strout, 200);
104104
close(tmpfile);
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
111111
#ifdef HAVE_FDATASYNC
112112
/* write, fdatasync */
113113
gettimeofday(&start_t, NULL);
114-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1)
114+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT, 0600)) == -1)
115115
die("can't open /var/tmp/test_fsync.out");
116116
write(tmpfile, &strout, 200);
117117
fdatasync(tmpfile);
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
125125

126126
/* write, fsync, close */
127127
gettimeofday(&start_t, NULL);
128-
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1)
128+
if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT, 0600)) == -1)
129129
die("can't open /var/tmp/test_fsync.out");
130130
write(tmpfile, &strout, 200);
131131
fsync(tmpfile);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy