btrfs-progs: drop O_CREATE from open_ctree_fs_info
authorDavid Sterba <dsterba@suse.com>
Fri, 20 May 2016 11:09:17 +0000 (13:09 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 1 Jun 2016 12:56:56 +0000 (14:56 +0200)
We stat the filesystem path before trying to open it so there's no point
to pass O_CREAT ("btrfs-progs: add stat check in open_ctree_fs_info").

Signed-off-by: David Sterba <dsterba@suse.com>
disk-io.c

index b4f185f..77eb0a6 100644 (file)
--- a/disk-io.c
+++ b/disk-io.c
@@ -1328,7 +1328,7 @@ struct btrfs_fs_info *open_ctree_fs_info(const char *filename,
        int fp;
        int ret;
        struct btrfs_fs_info *info;
-       int oflags = O_CREAT | O_RDWR;
+       int oflags = O_RDWR;
        struct stat st;
 
        ret = stat(filename, &st);
@@ -1344,7 +1344,7 @@ struct btrfs_fs_info *open_ctree_fs_info(const char *filename,
        if (!(flags & OPEN_CTREE_WRITES))
                oflags = O_RDONLY;
 
-       fp = open(filename, oflags, 0600);
+       fp = open(filename, oflags);
        if (fp < 0) {
                error("cannot open '%s': %s", filename, strerror(errno));
                return NULL;