Commit ab0b2f5f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop FileSystem.Flush().

Instead, add File.SetInode(), so Files can update inodes if needed.
parent f9cea038
......@@ -120,9 +120,6 @@ type FileSystem interface {
Open(name string, flags uint32, context *Context) (file File, code Status)
Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status)
// Flush() gets called as a file opened for read/write.
Flush(name string) Status
// Directory handling
OpenDir(name string, context *Context) (stream chan DirEntry, code Status)
......@@ -140,6 +137,9 @@ type FileSystem interface {
// TODO - should File be thread safe?
// TODO - should we pass a *Context argument?
type File interface {
// Called upon registering the filehandle in the inode.
SetInode(*Inode)
Read(*ReadIn, BufferPool) ([]byte, Status)
Write(*WriteIn, []byte) (written uint32, code Status)
Truncate(size uint64) Status
......
......@@ -73,10 +73,6 @@ func (me *DefaultFileSystem) Open(name string, flags uint32, context *Context) (
return nil, ENOSYS
}
func (me *DefaultFileSystem) Flush(name string) Status {
return OK
}
func (me *DefaultFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
return nil, ENOSYS
}
......
......@@ -4,6 +4,9 @@ import (
"os"
)
func (me *DefaultFile) SetInode(*Inode) {
}
func (me *DefaultFile) Read(*ReadIn, BufferPool) ([]byte, Status) {
return []byte(""), ENOSYS
}
......
......@@ -127,11 +127,13 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
break
}
b.WithFlags.File = withFlags.File
b.WithFlags.FuseFlags |= withFlags.FuseFlags
b.WithFlags.Description += withFlags.Description
f = withFlags.File
}
b.WithFlags.File.SetInode(node)
node.openFiles = append(node.openFiles, b)
handle := me.openFiles.Register(&b.Handled, b)
return handle, b
......
......@@ -82,6 +82,11 @@ func (me *PathNodeFs) Node(name string) *Inode {
return n
}
func (me *PathNodeFs) Path(node *Inode) string {
pNode := node.FsNode().(*pathInode)
return pNode.GetPath()
}
func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
if name == "" {
return me.Root().Inode(), nil
......@@ -316,15 +321,7 @@ func (me *pathInode) ListXAttr(context *Context) (attrs []string, code Status) {
}
func (me *pathInode) Flush(file File, openFlags uint32, context *Context) (code Status) {
code = file.Flush()
// TODO - drop this. The filesystem should hook into Flush of the file itself.
if code.Ok() && openFlags&O_ANYWRITE != 0 {
// We only signal releases to the FS if the
// open could have changed things.
path := me.GetPath()
code = me.fs.Flush(path)
}
return code
return file.Flush()
}
func (me *pathInode) OpenDir(context *Context) (chan DirEntry, Status) {
......
......@@ -263,11 +263,3 @@ func (me *SwitchFileSystem) RemoveXAttr(name string, attr string, context *Conte
}
return fs.FileSystem.RemoveXAttr(name, attr, context)
}
func (me *SwitchFileSystem) Flush(name string) Status {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Flush(name)
}
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