From d415c9a91d70d9206ddb141488c06a96fd132d85 Mon Sep 17 00:00:00 2001 From: Alex Fishman Date: Wed, 8 May 2024 18:04:59 +0300 Subject: [PATCH 1/2] Restrict the use of a write lock exclusively to the fuse-t platform. Signed-off-by: Alex Fishman --- connection.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/connection.go b/connection.go index 5b3c4ec..dfbb856 100644 --- a/connection.go +++ b/connection.go @@ -525,12 +525,13 @@ func (c *Connection) Reply(ctx context.Context, opErr error) error { noResponse := c.kernelResponse(outMsg, inMsg.Header().Unique, op, opErr) if !noResponse { - // writev is not atomic - writeLock.Lock() - defer writeLock.Unlock() - var err error if outMsg.Sglist != nil { + if fusekernel.IsPlatformFuseT { + // writev is not atomic on macos, restrict to fuse-t platform + writeLock.Lock() + defer writeLock.Unlock() + } _, err = writev(int(c.dev.Fd()), outMsg.Sglist) } else { err = c.writeMessage(outMsg.OutHeaderBytes()) From 5abc939b3d72805f70f7bb5be96e89fb29641698 Mon Sep 17 00:00:00 2001 From: Alex Fishman Date: Wed, 8 May 2024 18:15:08 +0300 Subject: [PATCH 2/2] Ingore loopbackfs errors for special folders Signed-off-by: Alex Fishman --- samples/roloopbackfs/inode.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/roloopbackfs/inode.go b/samples/roloopbackfs/inode.go index 11854f8..fbde3f2 100644 --- a/samples/roloopbackfs/inode.go +++ b/samples/roloopbackfs/inode.go @@ -116,12 +116,12 @@ func (in *inodeEntry) ListChildren(inodes *sync.Map) ([]*fuseutil.Dirent, error) if err != nil { return nil, err } - dirents := make([]*fuseutil.Dirent, len(children)) + dirents := []*fuseutil.Dirent{} for i, child := range children { childInode, err := getOrCreateInode(inodes, in.id, child.Name()) if err != nil || childInode == nil { - return nil, nil + continue } var childType fuseutil.DirentType @@ -133,12 +133,12 @@ func (in *inodeEntry) ListChildren(inodes *sync.Map) ([]*fuseutil.Dirent, error) childType = fuseutil.DT_File } - dirents[i] = &fuseutil.Dirent{ + dirents = append(dirents, &fuseutil.Dirent{ Offset: fuseops.DirOffset(i + 1), Inode: childInode.Id(), Name: child.Name(), Type: childType, - } + }) } return dirents, nil }