vfs: add tests and subsequent fixes

* Tests for VFS layer
  * Small fixes found during testing
  * Fix Close, Flush and Release behaviour for ReadFileHandle and WriteFileHandle
  * Fix nil object bugs on File
This commit is contained in:
Nick Craig-Wood
2017-10-29 21:14:05 +00:00
parent 07ec8073fe
commit e18122e88b
18 changed files with 1536 additions and 59 deletions

View File

@@ -5,6 +5,7 @@
package cmount
import (
"io"
"os"
"path"
"runtime"
@@ -397,13 +398,10 @@ func (fsys *FS) Read(path string, buff []byte, ofst int64, fh uint64) (n int) {
if errc != 0 {
return errc
}
rfh, ok := handle.(*vfs.ReadFileHandle)
if !ok {
// Can only read from read file handle
return -fuse.EIO
}
n, err := rfh.ReadAt(buff, ofst)
if err != nil {
n, err := handle.ReadAt(buff, ofst)
if err == io.EOF {
err = nil
} else if err != nil {
return translateError(err)
}
return n