mount,vfs: unify Read and Write handles in preparation for ReadWrite handles

This commit is contained in:
Nick Craig-Wood
2017-11-02 18:22:26 +00:00
parent e18122e88b
commit 5634659ea3
6 changed files with 27 additions and 85 deletions

View File

@@ -69,20 +69,12 @@ func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenR
return nil, translateError(err)
}
switch h := handle.(type) {
case *vfs.ReadFileHandle:
if f.VFS().Opt.NoSeek {
resp.Flags |= fuse.OpenNonSeekable
}
fh = &ReadFileHandle{h}
case *vfs.WriteFileHandle:
// See if seeking is supported and set FUSE hint accordingly
if _, err = handle.Seek(0, 1); err != nil {
resp.Flags |= fuse.OpenNonSeekable
fh = &WriteFileHandle{h}
default:
panic("unknown file handle type")
}
return fh, nil
return &FileHandle{handle}, nil
}
// Check interface satisfied