diff --git a/fuse/api.go b/fuse/api.go index 085d9df5..215d59fd 100644 --- a/fuse/api.go +++ b/fuse/api.go @@ -112,7 +112,7 @@ type ReadResult interface { Done() } -type ReadResultFd interface { +type ReadResultWithFd interface { ReadResult ReadFd() uintptr } diff --git a/fuse/opcode.go b/fuse/opcode.go index 44f40845..f16b6669 100644 --- a/fuse/opcode.go +++ b/fuse/opcode.go @@ -396,7 +396,7 @@ func doRead(server *Server, req *request) { } req.readResult, req.status = server.fileSystem.Read(req.cancel, in, buf) - if fd, ok := req.readResult.(ReadResultFd); ok { + if fd, ok := req.readResult.(ReadResultWithFd); ok { req.fdData = fd req.flatData = nil } else if req.readResult != nil && req.status.Ok() { diff --git a/fuse/read.go b/fuse/read.go index 22075040..ee050815 100644 --- a/fuse/read.go +++ b/fuse/read.go @@ -30,6 +30,10 @@ func ReadResultData(b []byte) ReadResult { return &readResultData{b} } +func ReadResultFd(fd uintptr, off int64, sz int) ReadResult { + return &readResultFd{fd, off, sz} +} + // ReadResultFd is the read return for zero-copy file data. type readResultFd struct { // Splice from the following file. diff --git a/fuse/request.go b/fuse/request.go index 22d0a3e2..8eab1aee 100644 --- a/fuse/request.go +++ b/fuse/request.go @@ -36,7 +36,7 @@ type request struct { // Output data. status Status flatData []byte - fdData ReadResultFd + fdData ReadResultWithFd slices [][]byte // In case of read, keep read result here so we can call