Commit 449d6e2e authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Don't discard ENOSYS from DefaultFile.

parent 0fa3281f
......@@ -23,7 +23,7 @@ func (f *DefaultFile) String() string {
}
func (f *DefaultFile) Read(buf []byte, off int64) (ReadResult, Status) {
return &ReadResultData{}, ENOSYS
return nil, ENOSYS
}
func (f *DefaultFile) Write(data []byte, off int64) (uint32, Status) {
......
package fuse
import (
"io/ioutil"
"log"
"os"
"testing"
)
var _ = log.Println
type DefaultReadFS struct {
DefaultFileSystem
size uint64
exist bool
}
func (fs *DefaultReadFS) GetAttr(name string, context *Context) (*Attr, Status) {
if name == "" {
return &Attr{Mode: S_IFDIR | 0755}, OK
}
if name == "file" {
return &Attr{Mode: S_IFREG | 0644, Size: fs.size}, OK
}
return nil, ENOENT
}
func (fs *DefaultReadFS) Open(name string, f uint32, context *Context) (File, Status) {
return &DefaultFile{}, OK
}
func defaultReadTest() (root string, cleanup func()) {
fs := &NotifyFs{}
var err error
dir, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
pathfs := NewPathNodeFs(fs, nil)
state, _, err := MountNodeFileSystem(dir, pathfs, nil)
CheckSuccess(err)
state.Debug = VerboseTest()
go state.Loop()
return dir, func() {
state.Unmount()
os.Remove(dir)
}
}
func TestDefaultRead(t *testing.T) {
root, clean := defaultReadTest()
defer clean()
_, err := ioutil.ReadFile(root + "/file")
if err == nil {
t.Fatal("should have failed read.")
}
}
......@@ -283,7 +283,7 @@ func doRead(state *MountState, req *request) {
if fd, ok := req.readResult.(*ReadResultFd); ok {
req.fdData = fd
req.flatData = nil
} else if req.readResult != nil {
} else if req.readResult != nil && req.status.Ok() {
req.flatData, req.status = req.readResult.Bytes(buf)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment