Skip to content

Instantly share code, notes, and snippets.

@ryanstout
Created December 18, 2014 21:47
Show Gist options
  • Save ryanstout/ea80059854254d3e6160 to your computer and use it in GitHub Desktop.
Save ryanstout/ea80059854254d3e6160 to your computer and use it in GitHub Desktop.
func (fh *FileHandle) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fs.Intr) fuse.Error {
// fmt.Printf("Read %s - %d at %d\n", fh.FuseFile.Path, req.Size, req.Offset)
buf := make([]byte, req.Size)
// fmt.Printf("ReadAt: %d -- %d -- %d - %s\n", req.Offset, req.Size, len(resp.Data), fh.FuseFile.Path)
size, err := fh.File.ReadAt(buf, req.Offset)
if err != nil && err != io.EOF {
fmt.Printf("ERR FROM READ: %s\n", err)
// return fuse.EIO
return err
}
//
// fmt.Printf("Read %d bytes at %s\n", size, fh.FuseFile.Path)
resp.Data = buf[:size]
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment