Skip to content

Commit

Permalink
fs: fix and test Create without file handles
Browse files Browse the repository at this point in the history
Addresses #537

Change-Id: I832d93efbf993d63f9163d1ca7bf07b4602bda56
  • Loading branch information
hanwen committed Nov 15, 2024
1 parent e2bee1b commit 756578b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ func (b *rawBridge) Create(cancel <-chan struct{}, input *fuse.CreateIn, name st
}

child, fe := b.addNewChild(parent, name, child, f, input.Flags|syscall.O_CREAT|syscall.O_EXCL, &out.EntryOut)
out.Fh = uint64(fe.fh)
if fe != nil {
out.Fh = uint64(fe.fh)
}
out.OpenFlags = flags

b.addBackingID(child, f, &out.OpenOut)
Expand Down
24 changes: 24 additions & 0 deletions fs/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,27 @@ func TestParallelMount(t *testing.T) {
}
}
}

type handleLessCreateNode struct {
Inode
}

var _ = (NodeCreater)((*handleLessCreateNode)(nil))

func (n *handleLessCreateNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *Inode, fh FileHandle, fuseFlags uint32, errno syscall.Errno) {
f := &MemRegularFile{
Attr: fuse.Attr{
Mode: mode,
},
}
ch := n.NewPersistentInode(ctx, f, StableAttr{Mode: fuse.S_IFREG})
n.AddChild(name, ch, true)
return ch, nil, fuse.FOPEN_KEEP_CACHE, 0
}

func TestHandleLessCreate(t *testing.T) {
hlcn := &handleLessCreateNode{}
dir, _ := testMount(t, hlcn, nil)

posixtest.FileBasic(t, dir)
}

0 comments on commit 756578b

Please sign in to comment.