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 { ...@@ -120,9 +120,6 @@ type FileSystem interface {
Open(name string, flags uint32, context *Context) (file File, code Status) Open(name string, flags uint32, context *Context) (file File, code Status)
Create(name string, flags uint32, mode 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 // Directory handling
OpenDir(name string, context *Context) (stream chan DirEntry, code Status) OpenDir(name string, context *Context) (stream chan DirEntry, code Status)
...@@ -140,6 +137,9 @@ type FileSystem interface { ...@@ -140,6 +137,9 @@ type FileSystem interface {
// TODO - should File be thread safe? // TODO - should File be thread safe?
// TODO - should we pass a *Context argument? // TODO - should we pass a *Context argument?
type File interface { type File interface {
// Called upon registering the filehandle in the inode.
SetInode(*Inode)
Read(*ReadIn, BufferPool) ([]byte, Status) Read(*ReadIn, BufferPool) ([]byte, Status)
Write(*WriteIn, []byte) (written uint32, code Status) Write(*WriteIn, []byte) (written uint32, code Status)
Truncate(size uint64) Status Truncate(size uint64) Status
......
...@@ -73,10 +73,6 @@ func (me *DefaultFileSystem) Open(name string, flags uint32, context *Context) ( ...@@ -73,10 +73,6 @@ func (me *DefaultFileSystem) Open(name string, flags uint32, context *Context) (
return nil, ENOSYS 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) { func (me *DefaultFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
return nil, ENOSYS return nil, ENOSYS
} }
......
...@@ -4,6 +4,9 @@ import ( ...@@ -4,6 +4,9 @@ import (
"os" "os"
) )
func (me *DefaultFile) SetInode(*Inode) {
}
func (me *DefaultFile) Read(*ReadIn, BufferPool) ([]byte, Status) { func (me *DefaultFile) Read(*ReadIn, BufferPool) ([]byte, Status) {
return []byte(""), ENOSYS return []byte(""), ENOSYS
} }
......
...@@ -127,11 +127,13 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f ...@@ -127,11 +127,13 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
break break
} }
b.WithFlags.File = withFlags.File
b.WithFlags.FuseFlags |= withFlags.FuseFlags b.WithFlags.FuseFlags |= withFlags.FuseFlags
b.WithFlags.Description += withFlags.Description b.WithFlags.Description += withFlags.Description
f = withFlags.File f = withFlags.File
} }
b.WithFlags.File.SetInode(node)
node.openFiles = append(node.openFiles, b) node.openFiles = append(node.openFiles, b)
handle := me.openFiles.Register(&b.Handled, b) handle := me.openFiles.Register(&b.Handled, b)
return handle, b return handle, b
......
...@@ -82,6 +82,11 @@ func (me *PathNodeFs) Node(name string) *Inode { ...@@ -82,6 +82,11 @@ func (me *PathNodeFs) Node(name string) *Inode {
return n return n
} }
func (me *PathNodeFs) Path(node *Inode) string {
pNode := node.FsNode().(*pathInode)
return pNode.GetPath()
}
func (me *PathNodeFs) LastNode(name string) (*Inode, []string) { func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
if name == "" { if name == "" {
return me.Root().Inode(), nil return me.Root().Inode(), nil
...@@ -316,15 +321,7 @@ func (me *pathInode) ListXAttr(context *Context) (attrs []string, code Status) { ...@@ -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) { func (me *pathInode) Flush(file File, openFlags uint32, context *Context) (code Status) {
code = file.Flush() return 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
} }
func (me *pathInode) OpenDir(context *Context) (chan DirEntry, Status) { func (me *pathInode) OpenDir(context *Context) (chan DirEntry, Status) {
......
...@@ -263,11 +263,3 @@ func (me *SwitchFileSystem) RemoveXAttr(name string, attr string, context *Conte ...@@ -263,11 +263,3 @@ func (me *SwitchFileSystem) RemoveXAttr(name string, attr string, context *Conte
} }
return fs.FileSystem.RemoveXAttr(name, attr, context) 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