vfs: add flags parameter to Dir.Create

This commit is contained in:
Nick Craig-Wood 2017-12-07 12:34:18 +00:00
parent 517bdc719b
commit a80d8a21dc
5 changed files with 6 additions and 6 deletions

View File

@ -299,7 +299,7 @@ func (fsys *FS) Create(filePath string, flags int, mode uint32) (errc int, fh ui
if errc != 0 { if errc != 0 {
return errc, fhUnset return errc, fhUnset
} }
file, err := parentDir.Create(leaf) file, err := parentDir.Create(leaf, flags)
if err != nil { if err != nil {
return translateError(err), fhUnset return translateError(err), fhUnset
} }

View File

@ -112,7 +112,7 @@ var _ fusefs.NodeCreater = (*Dir)(nil)
// Create makes a new file // Create makes a new file
func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (node fusefs.Node, handle fusefs.Handle, err error) { func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (node fusefs.Node, handle fusefs.Handle, err error) {
defer log.Trace(d, "name=%q", req.Name)("node=%v, handle=%v, err=%v", &node, &handle, &err) defer log.Trace(d, "name=%q", req.Name)("node=%v, handle=%v, err=%v", &node, &handle, &err)
file, err := d.Dir.Create(req.Name) file, err := d.Dir.Create(req.Name, int(req.Flags))
if err != nil { if err != nil {
return nil, nil, translateError(err) return nil, nil, translateError(err)
} }

View File

@ -326,7 +326,7 @@ func (d *Dir) Open(flags int) (fd Handle, err error) {
} }
// Create makes a new file node // Create makes a new file node
func (d *Dir) Create(name string) (*File, error) { func (d *Dir) Create(name string, flags int) (*File, error) {
// fs.Debugf(path, "Dir.Create") // fs.Debugf(path, "Dir.Create")
if d.vfs.Opt.ReadOnly { if d.vfs.Opt.ReadOnly {
return nil, EROFS return nil, EROFS

View File

@ -281,7 +281,7 @@ func TestDirCreate(t *testing.T) {
defer r.Finalise() defer r.Finalise()
vfs, dir, _ := dirCreate(t, r) vfs, dir, _ := dirCreate(t, r)
file, err := dir.Create("potato") file, err := dir.Create("potato", os.O_WRONLY|os.O_CREATE)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, int64(0), file.Size()) assert.Equal(t, int64(0), file.Size())
@ -306,7 +306,7 @@ func TestDirCreate(t *testing.T) {
assert.Equal(t, int64(5), file2.Size()) assert.Equal(t, int64(5), file2.Size())
vfs.Opt.ReadOnly = true vfs.Opt.ReadOnly = true
_, err = dir.Create("sausage") _, err = dir.Create("sausage", os.O_WRONLY|os.O_CREATE)
assert.Equal(t, EROFS, err) assert.Equal(t, EROFS, err)
} }

View File

@ -403,7 +403,7 @@ func (vfs *VFS) OpenFile(name string, flags int, perm os.FileMode) (fd Handle, e
if err != nil { if err != nil {
return nil, err return nil, err
} }
node, err = dir.Create(leaf) node, err = dir.Create(leaf, flags)
if err != nil { if err != nil {
return nil, err return nil, err
} }