src/fsync-err: don't truncate files on second open
authorJeff Layton <jlayton@redhat.com>
Fri, 27 Apr 2018 16:34:59 +0000 (12:34 -0400)
committerEryu Guan <guaneryu@gmail.com>
Wed, 2 May 2018 02:53:48 +0000 (10:53 +0800)
...and no need for O_CREAT flag.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
src/fsync-err.c

index 146688ddb01e636ca8223b6c3d44d0505d83683e..bd05dcc0a898ba639a52107913f38f4511783a7e 100644 (file)
@@ -170,9 +170,9 @@ int main(int argc, char **argv)
                        ret = fsync(fd[i]);
                        if (ret < 0) {
                                /*
-                                * We did a failed write and fsync on each fd before.
-                                * Now the error should be clear since we've not done
-                                * any writes since then.
+                                * We did a failed write and fsync on each fd
+                                * before.  Now the error should be clear since
+                                * we've not done any writes since then.
                                 */
                                printf("Third fsync on fd[%d] failed: %m\n", i);
                                return 1;
@@ -220,7 +220,7 @@ int main(int argc, char **argv)
                        printf("Close of fd[%d] returned unexpected error: %m\n", i);
                        return 1;
                }
-               fd[i] = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+               fd[i] = open(fname, O_WRONLY, 0644);
                if (fd[i] < 0) {
                        printf("Second open of fd[%d] failed: %m\n", i);
                        return 1;