rofiles-fuse: Fix truncate call to not use O_CREAT
authorColin Walters <walters@verbum.org>
Wed, 17 Feb 2016 16:01:21 +0000 (11:01 -0500)
committerColin Walters <walters@verbum.org>
Wed, 17 Feb 2016 16:06:53 +0000 (11:06 -0500)
I was getting a compilation error with the GCC hardening flags which
look for a missing mode with `O_CREAT`.  The right fix here is to drop
`O_CREAT`, as truncate() should throw `ENOENT` if the file doesn't
exist.

src/rofiles-fuse/main.c

index 004ad3d2b982960666cf4e3cfbb262f3d4818c45..4337f00fee17e2b76742f24b8367c96cb3b5b863 100644 (file)
@@ -299,7 +299,7 @@ callback_truncate (const char *path, off_t size)
   path = ENSURE_RELPATH (path);
   VERIFY_WRITE(path);
 
-  fd = openat (basefd, path, O_RDWR | O_CREAT);
+  fd = openat (basefd, path, O_WRONLY);
   if (fd == -1)
     return -errno;