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

Add File.InnerFile() for safe unpacking.

parent 24dceee8
...@@ -139,6 +139,10 @@ type FileSystem interface { ...@@ -139,6 +139,10 @@ type FileSystem interface {
type File interface { type File interface {
// Called upon registering the filehandle in the inode. // Called upon registering the filehandle in the inode.
SetInode(*Inode) SetInode(*Inode)
// Wrappers around other File implementations, should return
// the inner file here.
InnerFile() File
Read(*ReadIn, BufferPool) ([]byte, Status) Read(*ReadIn, BufferPool) ([]byte, Status)
Write(*WriteIn, []byte) (written uint32, code Status) Write(*WriteIn, []byte) (written uint32, code Status)
......
package fuse package fuse
import ( import (
"log"
"os" "os"
) )
var _ = log.Println
func (me *DefaultFile) SetInode(*Inode) { func (me *DefaultFile) SetInode(*Inode) {
} }
func (me *DefaultFile) InnerFile() File {
return nil
}
func (me *DefaultFile) Read(*ReadIn, BufferPool) ([]byte, Status) { func (me *DefaultFile) Read(*ReadIn, BufferPool) ([]byte, Status) {
return []byte(""), ENOSYS return []byte(""), ENOSYS
} }
......
...@@ -133,7 +133,9 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f ...@@ -133,7 +133,9 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
f = withFlags.File f = withFlags.File
} }
b.WithFlags.File.SetInode(node) if b.WithFlags.File != nil {
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
......
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