From a0de1966c9545bb6bd428928d84ccd6021d463ef Mon Sep 17 00:00:00 2001 From: abushwang Date: Mon, 25 Nov 2024 17:49:13 +0800 Subject: [PATCH] fuse passthrough: fix PassthroughFd return wrong num in no passthrough model Signed-off-by: abushwang --- fs/layer/node.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/layer/node.go b/fs/layer/node.go index 02f9e6488..36d342529 100644 --- a/fs/layer/node.go +++ b/fs/layer/node.go @@ -350,6 +350,7 @@ func (n *node) Open(ctx context.Context, flags uint32) (fh fusefs.FileHandle, fu f := &file{ n: n, ra: ra, + fd: -1, } if n.fs.passThrough { @@ -473,6 +474,9 @@ func (f *file) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno { var _ = (fusefs.FilePassthroughFder)((*file)(nil)) func (f *file) PassthroughFd() (int, bool) { + if f.fd <= 0 { + return -1, false + } return f.fd, true }