From 34c45a7c04a794c9f4d1be68e11f795083ec4adb Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 15 Mar 2018 10:27:04 +0000 Subject: [PATCH] mount, cmount: remove addition of O_CREATE to flags on file open #2141 Previously this was adding it in to all file opens which was causing inefficiencies under Windows where it stats the file using open/fstat/close. This change will make stat operations run much quicker under Windows as they won't have to open the underlying file This problem was introduced in61b6159a05336bd7ba105766de2d2ff171f7fb81 where we added O_CREATE to all file opens and creates. --- cmd/cmount/fs.go | 2 +- cmd/mount/file.go | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/cmount/fs.go b/cmd/cmount/fs.go index f155399ad..b993a222b 100644 --- a/cmd/cmount/fs.go +++ b/cmd/cmount/fs.go @@ -283,7 +283,7 @@ func (fsys *FS) Open(path string, flags int) (errc int, fh uint64) { defer log.Trace(path, "flags=0x%X", flags)("errc=%d, fh=0x%X", &errc, &fh) // translate the fuse flags to os flags - flags = translateOpenFlags(flags) | os.O_CREATE + flags = translateOpenFlags(flags) handle, err := fsys.VFS.OpenFile(path, flags, 0777) if errc != 0 { return translateError(err), fhUnset diff --git a/cmd/mount/file.go b/cmd/mount/file.go index 7632203fe..25f5625e0 100644 --- a/cmd/mount/file.go +++ b/cmd/mount/file.go @@ -3,7 +3,6 @@ package mount import ( - "os" "time" "bazil.org/fuse" @@ -69,10 +68,7 @@ func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenR // fuse flags are based off syscall flags as are os flags, so // should be compatible - // - // we seem to be missing O_CREATE here so add it in to allow - // file creation - handle, err := f.File.Open(int(req.Flags) | os.O_CREATE) + handle, err := f.File.Open(int(req.Flags)) if err != nil { return nil, translateError(err) }