mount, cmount: add O_CREATE to Open calls since fuse doesn't seem to supply it

This commit is contained in:
Nick Craig-Wood 2017-11-18 11:50:58 +00:00
parent c560017934
commit 61b6159a05
3 changed files with 8 additions and 4 deletions

View File

@ -282,7 +282,7 @@ func (fsys *FS) Open(path string, flags int) (errc int, fh uint64) {
defer fs.Trace(path, "flags=0x%X", flags)("errc=%d, fh=0x%X", &errc, &fh)
// translate the fuse flags to os flags
flags = translateOpenFlags(flags)
flags = translateOpenFlags(flags) | os.O_CREATE
handle, err := fsys.VFS.OpenFile(path, flags, 0777)
if errc != 0 {
return translateError(err), fhUnset
@ -303,7 +303,7 @@ func (fsys *FS) Create(filePath string, flags int, mode uint32) (errc int, fh ui
return translateError(err), fhUnset
}
// translate the fuse flags to os flags
flags = translateOpenFlags(flags)
flags = translateOpenFlags(flags) | os.O_CREATE
handle, err := file.Open(flags)
if err != nil {
return translateError(err), fhUnset

View File

@ -116,7 +116,7 @@ func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.Cr
if err != nil {
return nil, nil, translateError(err)
}
fh, err := file.Open(int(req.Flags))
fh, err := file.Open(int(req.Flags) | os.O_CREATE)
if err != nil {
return nil, nil, translateError(err)
}

View File

@ -3,6 +3,7 @@
package mount
import (
"os"
"time"
"bazil.org/fuse"
@ -64,7 +65,10 @@ 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
handle, err := f.File.Open(int(req.Flags))
//
// 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)
if err != nil {
return nil, translateError(err)
}