diff --git a/fuseops/ops.go b/fuseops/ops.go index d73c42c..5a857bf 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -384,25 +384,25 @@ type ReadDirOp struct { // offset, and return array offsets into that cached listing. Offset DirOffset - // The maximum number of bytes to return in ReadDirResponse.Data. A smaller - // number is acceptable. - Size int - - // Set by the file system: a buffer consisting of a sequence of FUSE - // directory entries in the format generated by fuse_add_direntry - // (http://goo.gl/qCcHCV), which is consumed by parse_dirfile - // (http://goo.gl/2WUmD2). Use fuseutil.AppendDirent to generate this data. + // The destination buffer, whose length gives the size of the read. // - // The buffer must not exceed the length specified in ReadDirRequest.Size. It - // is okay for the final entry to be truncated; parse_dirfile copes with this - // by ignoring the partial record. + // The output data should consist of a sequence of FUSE directory entries in + // the format generated by fuse_add_direntry (http://goo.gl/qCcHCV), which is + // consumed by parse_dirfile (http://goo.gl/2WUmD2). Use + // fuseutil.AppendDirent to generate this data. + // + // It is okay for the final entry to be truncated if it doesn't fit; + // parse_dirfile copes with this by ignoring the partial record. // // Each entry returned exposes a directory offset to the user that may later // show up in ReadDirRequest.Offset. See notes on that field for more // information. - // - // An empty buffer indicates the end of the directory has been reached. - Data []byte + Dst []byte + + // Set by the file system: the number of bytes read into Dst. It is okay for + // this to be less than len(Dst) if there is less data available. A value of + // zero means that the end of the directory has been reached. + BytesRead int } // Release a previously-minted directory handle. The kernel sends this when @@ -455,20 +455,21 @@ type ReadFileOp struct { Inode InodeID Handle HandleID - // The range of the file to read. + // The offset within the file at which to read. + Offset int64 + + // The destination buffer, whose length gives the size of the read. + Dst []byte + + // Set by the file system: the number of bytes read. // - // The FUSE documentation requires that exactly the number of bytes be - // returned, except in the case of EOF or error (http://goo.gl/ZgfBkF). This - // appears to be because it uses file mmapping machinery + // The FUSE documentation requires that exactly the requested number of bytes + // be returned, except in the case of EOF or error (http://goo.gl/ZgfBkF). + // This appears to be because it uses file mmapping machinery // (http://goo.gl/SGxnaN) to read a page at a time. It appears to understand // where EOF is by checking the inode size (http://goo.gl/0BkqKD), returned // by a previous call to LookUpInode, GetInodeAttributes, etc. - Offset int64 - Size int - - // Set by the file system: the data read. If this is less than the requested - // size, it indicates EOF. An error should not be returned in this case. - Data []byte + BytesRead int } // Write data to a file previously opened with CreateFile or OpenFile.