MCPcopy Index your code
hub / github.com/perkeep/perkeep / Read

Method Read

pkg/fs/mut.go:766–794  ·  view source on GitHub ↗
(ctx context.Context, req *fuse.ReadRequest, res *fuse.ReadResponse)

Source from the content-addressed store, hash-verified

764)
765
766func (h *mutFileHandle) Read(ctx context.Context, req *fuse.ReadRequest, res *fuse.ReadResponse) error {
767 h.f.mu.Lock()
768 defer h.f.mu.Unlock()
769
770 if h.tmp == nil {
771 Logger.Printf("Read called on camli mutFileHandle without a tempfile set")
772 return fuse.EIO
773 }
774
775 if req.Offset > h.f.size {
776 return nil
777 }
778 toRead := int64(req.Size)
779 if remain := h.f.size - req.Offset; remain < toRead {
780 toRead = remain
781 }
782
783 buf := make([]byte, toRead)
784 n, err := h.tmp.ReadAt(buf, req.Offset)
785 if err == io.EOF {
786 err = nil
787 }
788 if err != nil {
789 Logger.Printf("mutFileHandle.Read: %v", err)
790 return fuse.EIO
791 }
792 res.Data = buf[:n]
793 return nil
794}
795
796func (h *mutFileHandle) Write(ctx context.Context, req *fuse.WriteRequest, res *fuse.WriteResponse) error {
797 h.f.mu.Lock()

Callers

nothing calls this directly

Calls 4

LockMethod · 0.80
UnlockMethod · 0.80
PrintfMethod · 0.80
ReadAtMethod · 0.45

Tested by

no test coverage detected