Commit 1ee3533f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: rename DefaultOperations to OperationStubs

parent 0c3074f5
...@@ -53,10 +53,4 @@ Decisions ...@@ -53,10 +53,4 @@ Decisions
To decide To decide
========= =========
* A better name for DefaultOperations.
* InodeLink
* ReadonlyOperations
* BaseOperations
* implement remaining file types (exercise Mknod) * implement remaining file types (exercise Mknod)
...@@ -65,7 +65,7 @@ import ( ...@@ -65,7 +65,7 @@ import (
) )
// Operations is the interface that implements the filesystem inode. // Operations is the interface that implements the filesystem inode.
// Each Operations instance must embed DefaultNode. All error // Each Operations instance must embed OperationStubs. All error
// reporting must use the syscall.Errno type. The value 0 (`OK`) // reporting must use the syscall.Errno type. The value 0 (`OK`)
// should be used to indicate success. // should be used to indicate success.
type Operations interface { type Operations interface {
...@@ -79,12 +79,11 @@ type Operations interface { ...@@ -79,12 +79,11 @@ type Operations interface {
// Inode returns the *Inode associated with this Operations // Inode returns the *Inode associated with this Operations
// instance. The identity of the Inode does not change over // instance. The identity of the Inode does not change over
// the lifetime of the node object. Inode() is provided by // the lifetime of the node object. Inode() is provided by
// DefaultOperations, and should not be reimplemented. // OperationStubs, and should not be reimplemented.
Inode() *Inode Inode() *Inode
// StatFs implements statistics for the filesystem that holds // StatFs implements statistics for the filesystem that holds
// this Inode. DefaultNode implements this, because OSX // this Inode.
// filesystem must have a valid StatFs implementation.
StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno
// Access should return if the caller can access the file with // Access should return if the caller can access the file with
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
) )
type keepCacheFile struct { type keepCacheFile struct {
DefaultOperations OperationStubs
keepCache bool keepCache bool
mu sync.Mutex mu sync.Mutex
...@@ -62,7 +62,7 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of ...@@ -62,7 +62,7 @@ func (f *keepCacheFile) Read(ctx context.Context, fh FileHandle, dest []byte, of
} }
type keepCacheRoot struct { type keepCacheRoot struct {
DefaultOperations OperationStubs
keep, nokeep *keepCacheFile keep, nokeep *keepCacheFile
} }
......
...@@ -12,25 +12,25 @@ import ( ...@@ -12,25 +12,25 @@ import (
"github.com/hanwen/go-fuse/internal" "github.com/hanwen/go-fuse/internal"
) )
// DefaultOperations provides no-operation default implementations for // OperationStubs provides no-operation default implementations for
// all the XxxOperations interfaces. The stubs provide useful defaults // all the XxxOperations interfaces. The stubs provide useful defaults
// for implementing a read-only filesystem whose tree is constructed // for implementing a read-only filesystem whose tree is constructed
// beforehand in the OnAdd method of the root. A example is in // beforehand in the OnAdd method of the root. A example is in
// zip_test.go // zip_test.go
// //
// It must be embedded in any Operations implementation. // It must be embedded in any Operations implementation.
type DefaultOperations struct { type OperationStubs struct {
inode_ Inode inode_ Inode
} }
// check that we have implemented all interface methods // check that we have implemented all interface methods
var _ Operations = &DefaultOperations{} var _ Operations = &OperationStubs{}
func (n *DefaultOperations) inode() *Inode { func (n *OperationStubs) inode() *Inode {
return &n.inode_ return &n.inode_
} }
func (n *DefaultOperations) init(ops Operations, attr NodeAttr, bridge *rawBridge, persistent bool) { func (n *OperationStubs) init(ops Operations, attr NodeAttr, bridge *rawBridge, persistent bool) {
n.inode_ = Inode{ n.inode_ = Inode{
ops: ops, ops: ops,
nodeAttr: attr, nodeAttr: attr,
...@@ -44,35 +44,35 @@ func (n *DefaultOperations) init(ops Operations, attr NodeAttr, bridge *rawBridg ...@@ -44,35 +44,35 @@ func (n *DefaultOperations) init(ops Operations, attr NodeAttr, bridge *rawBridg
} }
// Inode returns the Inode for this Operations // Inode returns the Inode for this Operations
func (n *DefaultOperations) Inode() *Inode { func (n *OperationStubs) Inode() *Inode {
return &n.inode_ return &n.inode_
} }
// StatFs zeroes the out argument and returns OK. This is because OSX // StatFs zeroes the out argument and returns OK. This is because OSX
// filesystems must define this, or the mount will not work. // filesystems must define this, or the mount will not work.
func (n *DefaultOperations) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno { func (n *OperationStubs) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
// this should be defined on OSX, or the FS won't mount // this should be defined on OSX, or the FS won't mount
*out = fuse.StatfsOut{} *out = fuse.StatfsOut{}
return OK return OK
} }
// The default OnAdd does nothing. // The default OnAdd does nothing.
func (n *DefaultOperations) OnAdd(ctx context.Context) { func (n *OperationStubs) OnAdd(ctx context.Context) {
} }
// GetAttr zeroes out argument and returns OK. // GetAttr zeroes out argument and returns OK.
func (n *DefaultOperations) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno { func (n *OperationStubs) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
*out = fuse.AttrOut{} *out = fuse.AttrOut{}
return OK return OK
} }
func (n *DefaultOperations) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno { func (n *OperationStubs) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
return syscall.EROFS return syscall.EROFS
} }
// The Access default implementation checks traditional unix // The Access default implementation checks traditional unix
// permissions of the GetAttr result agains the caller. // permissions of the GetAttr result agains the caller.
func (n *DefaultOperations) Access(ctx context.Context, mask uint32) syscall.Errno { func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno {
caller, ok := fuse.FromContext(ctx) caller, ok := fuse.FromContext(ctx)
if !ok { if !ok {
return syscall.EINVAL return syscall.EINVAL
...@@ -91,7 +91,7 @@ func (n *DefaultOperations) Access(ctx context.Context, mask uint32) syscall.Err ...@@ -91,7 +91,7 @@ func (n *DefaultOperations) Access(ctx context.Context, mask uint32) syscall.Err
// FSetAttr delegates to the FileHandle's if f is not nil, or else to the // FSetAttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's SetAttr method. // Inode's SetAttr method.
func (n *DefaultOperations) FSetAttr(ctx context.Context, f FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno { func (n *OperationStubs) FSetAttr(ctx context.Context, f FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
if f != nil { if f != nil {
return f.SetAttr(ctx, in, out) return f.SetAttr(ctx, in, out)
} }
...@@ -99,9 +99,9 @@ func (n *DefaultOperations) FSetAttr(ctx context.Context, f FileHandle, in *fuse ...@@ -99,9 +99,9 @@ func (n *DefaultOperations) FSetAttr(ctx context.Context, f FileHandle, in *fuse
return n.inode_.Operations().SetAttr(ctx, in, out) return n.inode_.Operations().SetAttr(ctx, in, out)
} }
// The Lookup method on the DefaultOperations type looks for an // The Lookup method on the OperationStubs type looks for an
// existing child with the given name, or returns ENOENT. // existing child with the given name, or returns ENOENT.
func (n *DefaultOperations) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*Inode, syscall.Errno) { func (n *OperationStubs) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*Inode, syscall.Errno) {
ch := n.inode().GetChild(name) ch := n.inode().GetChild(name)
if ch == nil { if ch == nil {
return nil, syscall.ENOENT return nil, syscall.ENOENT
...@@ -114,32 +114,32 @@ func (n *DefaultOperations) Lookup(ctx context.Context, name string, out *fuse.E ...@@ -114,32 +114,32 @@ func (n *DefaultOperations) Lookup(ctx context.Context, name string, out *fuse.E
} }
// Mkdir returns EROFS // Mkdir returns EROFS
func (n *DefaultOperations) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*Inode, syscall.Errno) { func (n *OperationStubs) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*Inode, syscall.Errno) {
return nil, syscall.EROFS return nil, syscall.EROFS
} }
// Mknod returns EROFS // Mknod returns EROFS
func (n *DefaultOperations) Mknod(ctx context.Context, name string, mode uint32, dev uint32, out *fuse.EntryOut) (*Inode, syscall.Errno) { func (n *OperationStubs) Mknod(ctx context.Context, name string, mode uint32, dev uint32, out *fuse.EntryOut) (*Inode, syscall.Errno) {
return nil, syscall.EROFS return nil, syscall.EROFS
} }
// Rmdir returns EROFS // Rmdir returns EROFS
func (n *DefaultOperations) Rmdir(ctx context.Context, name string) syscall.Errno { func (n *OperationStubs) Rmdir(ctx context.Context, name string) syscall.Errno {
return syscall.EROFS return syscall.EROFS
} }
// Unlink returns EROFS // Unlink returns EROFS
func (n *DefaultOperations) Unlink(ctx context.Context, name string) syscall.Errno { func (n *OperationStubs) Unlink(ctx context.Context, name string) syscall.Errno {
return syscall.EROFS return syscall.EROFS
} }
// The default OpenDir always succeeds // The default OpenDir always succeeds
func (n *DefaultOperations) OpenDir(ctx context.Context) syscall.Errno { func (n *OperationStubs) OpenDir(ctx context.Context) syscall.Errno {
return OK return OK
} }
// The default ReadDir returns the list of children from the tree // The default ReadDir returns the list of children from the tree
func (n *DefaultOperations) ReadDir(ctx context.Context) (DirStream, syscall.Errno) { func (n *OperationStubs) ReadDir(ctx context.Context) (DirStream, syscall.Errno) {
r := []fuse.DirEntry{} r := []fuse.DirEntry{}
for k, ch := range n.inode().Children() { for k, ch := range n.inode().Children() {
r = append(r, fuse.DirEntry{Mode: ch.Mode(), r = append(r, fuse.DirEntry{Mode: ch.Mode(),
...@@ -150,12 +150,12 @@ func (n *DefaultOperations) ReadDir(ctx context.Context) (DirStream, syscall.Err ...@@ -150,12 +150,12 @@ func (n *DefaultOperations) ReadDir(ctx context.Context) (DirStream, syscall.Err
} }
// Rename returns EROFS // Rename returns EROFS
func (n *DefaultOperations) Rename(ctx context.Context, name string, newParent Operations, newName string, flags uint32) syscall.Errno { func (n *OperationStubs) Rename(ctx context.Context, name string, newParent Operations, newName string, flags uint32) syscall.Errno {
return syscall.EROFS return syscall.EROFS
} }
// Read delegates to the FileHandle argument. // Read delegates to the FileHandle argument.
func (n *DefaultOperations) Read(ctx context.Context, f FileHandle, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) { func (n *OperationStubs) Read(ctx context.Context, f FileHandle, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
if f != nil { if f != nil {
return f.Read(ctx, dest, off) return f.Read(ctx, dest, off)
} }
...@@ -163,17 +163,17 @@ func (n *DefaultOperations) Read(ctx context.Context, f FileHandle, dest []byte, ...@@ -163,17 +163,17 @@ func (n *DefaultOperations) Read(ctx context.Context, f FileHandle, dest []byte,
} }
// Symlink returns EROFS // Symlink returns EROFS
func (n *DefaultOperations) Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (node *Inode, errno syscall.Errno) { func (n *OperationStubs) Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (node *Inode, errno syscall.Errno) {
return nil, syscall.EROFS return nil, syscall.EROFS
} }
// Readlink return ENOTSUP // Readlink return ENOTSUP
func (n *DefaultOperations) Readlink(ctx context.Context) ([]byte, syscall.Errno) { func (n *OperationStubs) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
return nil, syscall.ENOTSUP return nil, syscall.ENOTSUP
} }
// Fsync delegates to the FileHandle // Fsync delegates to the FileHandle
func (n *DefaultOperations) Fsync(ctx context.Context, f FileHandle, flags uint32) syscall.Errno { func (n *OperationStubs) Fsync(ctx context.Context, f FileHandle, flags uint32) syscall.Errno {
if f != nil { if f != nil {
return f.Fsync(ctx, flags) return f.Fsync(ctx, flags)
} }
...@@ -181,7 +181,7 @@ func (n *DefaultOperations) Fsync(ctx context.Context, f FileHandle, flags uint3 ...@@ -181,7 +181,7 @@ func (n *DefaultOperations) Fsync(ctx context.Context, f FileHandle, flags uint3
} }
// Write delegates to the FileHandle // Write delegates to the FileHandle
func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte, off int64) (written uint32, errno syscall.Errno) { func (n *OperationStubs) Write(ctx context.Context, f FileHandle, data []byte, off int64) (written uint32, errno syscall.Errno) {
if f != nil { if f != nil {
return f.Write(ctx, data, off) return f.Write(ctx, data, off)
} }
...@@ -189,13 +189,13 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte ...@@ -189,13 +189,13 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte
return 0, syscall.EROFS return 0, syscall.EROFS
} }
func (n *DefaultOperations) CopyFileRange(ctx context.Context, fhIn FileHandle, func (n *OperationStubs) CopyFileRange(ctx context.Context, fhIn FileHandle,
offIn uint64, out *Inode, fhOut FileHandle, offOut uint64, offIn uint64, out *Inode, fhOut FileHandle, offOut uint64,
len uint64, flags uint64) (uint32, syscall.Errno) { len uint64, flags uint64) (uint32, syscall.Errno) {
return 0, syscall.EROFS return 0, syscall.EROFS
} }
func (n *DefaultOperations) Lseek(ctx context.Context, f FileHandle, off uint64, whence uint32) (uint64, syscall.Errno) { func (n *OperationStubs) Lseek(ctx context.Context, f FileHandle, off uint64, whence uint32) (uint64, syscall.Errno) {
if f != nil { if f != nil {
return f.Lseek(ctx, off, whence) return f.Lseek(ctx, off, whence)
} }
...@@ -203,7 +203,7 @@ func (n *DefaultOperations) Lseek(ctx context.Context, f FileHandle, off uint64, ...@@ -203,7 +203,7 @@ func (n *DefaultOperations) Lseek(ctx context.Context, f FileHandle, off uint64,
} }
// GetLk delegates to the FileHandlef // GetLk delegates to the FileHandlef
func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) { func (n *OperationStubs) GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
if f != nil { if f != nil {
return f.GetLk(ctx, owner, lk, flags, out) return f.GetLk(ctx, owner, lk, flags, out)
} }
...@@ -212,7 +212,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6 ...@@ -212,7 +212,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6
} }
// SetLk delegates to the FileHandle // SetLk delegates to the FileHandle
func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) { func (n *OperationStubs) SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
if f != nil { if f != nil {
return f.SetLk(ctx, owner, lk, flags) return f.SetLk(ctx, owner, lk, flags)
} }
...@@ -221,7 +221,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6 ...@@ -221,7 +221,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6
} }
// SetLkw delegates to the FileHandle // SetLkw delegates to the FileHandle
func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) { func (n *OperationStubs) SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
if f != nil { if f != nil {
return f.SetLkw(ctx, owner, lk, flags) return f.SetLkw(ctx, owner, lk, flags)
} }
...@@ -230,7 +230,7 @@ func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint ...@@ -230,7 +230,7 @@ func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint
} }
// Flush delegates to the FileHandle // Flush delegates to the FileHandle
func (n *DefaultOperations) Flush(ctx context.Context, f FileHandle) syscall.Errno { func (n *OperationStubs) Flush(ctx context.Context, f FileHandle) syscall.Errno {
if f != nil { if f != nil {
return f.Flush(ctx) return f.Flush(ctx)
} }
...@@ -239,7 +239,7 @@ func (n *DefaultOperations) Flush(ctx context.Context, f FileHandle) syscall.Err ...@@ -239,7 +239,7 @@ func (n *DefaultOperations) Flush(ctx context.Context, f FileHandle) syscall.Err
} }
// Release delegates to the FileHandle // Release delegates to the FileHandle
func (n *DefaultOperations) Release(ctx context.Context, f FileHandle) syscall.Errno { func (n *OperationStubs) Release(ctx context.Context, f FileHandle) syscall.Errno {
if f != nil { if f != nil {
return f.Release(ctx) return f.Release(ctx)
} }
...@@ -247,7 +247,7 @@ func (n *DefaultOperations) Release(ctx context.Context, f FileHandle) syscall.E ...@@ -247,7 +247,7 @@ func (n *DefaultOperations) Release(ctx context.Context, f FileHandle) syscall.E
} }
// Allocate delegates to the FileHandle // Allocate delegates to the FileHandle
func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) (errno syscall.Errno) { func (n *OperationStubs) Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) (errno syscall.Errno) {
if f != nil { if f != nil {
return f.Allocate(ctx, off, size, mode) return f.Allocate(ctx, off, size, mode)
} }
...@@ -257,7 +257,7 @@ func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint ...@@ -257,7 +257,7 @@ func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint
// FGetAttr delegates to the FileHandle's if f is not nil, or else to the // FGetAttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's GetAttr method. // Inode's GetAttr method.
func (n *DefaultOperations) FGetAttr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno { func (n *OperationStubs) FGetAttr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno {
if f != nil { if f != nil {
f.GetAttr(ctx, out) f.GetAttr(ctx, out)
} }
...@@ -265,91 +265,91 @@ func (n *DefaultOperations) FGetAttr(ctx context.Context, f FileHandle, out *fus ...@@ -265,91 +265,91 @@ func (n *DefaultOperations) FGetAttr(ctx context.Context, f FileHandle, out *fus
} }
// Open returns ENOTSUP // Open returns ENOTSUP
func (n *DefaultOperations) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, errno syscall.Errno) { func (n *OperationStubs) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, errno syscall.Errno) {
return nil, 0, syscall.ENOTSUP return nil, 0, syscall.ENOTSUP
} }
// Create returns ENOTSUP // Create returns ENOTSUP
func (n *DefaultOperations) Create(ctx context.Context, name string, flags uint32, mode uint32) (node *Inode, fh FileHandle, fuseFlags uint32, errno syscall.Errno) { func (n *OperationStubs) Create(ctx context.Context, name string, flags uint32, mode uint32) (node *Inode, fh FileHandle, fuseFlags uint32, errno syscall.Errno) {
return nil, nil, 0, syscall.EROFS return nil, nil, 0, syscall.EROFS
} }
// Link returns ENOTSUP // Link returns ENOTSUP
func (n *DefaultOperations) Link(ctx context.Context, target Operations, name string, out *fuse.EntryOut) (node *Inode, errno syscall.Errno) { func (n *OperationStubs) Link(ctx context.Context, target Operations, name string, out *fuse.EntryOut) (node *Inode, errno syscall.Errno) {
return nil, syscall.EROFS return nil, syscall.EROFS
} }
// The default GetXAttr returns ENOATTR // The default GetXAttr returns ENOATTR
func (n *DefaultOperations) GetXAttr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno) { func (n *OperationStubs) GetXAttr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno) {
return 0, ENOATTR return 0, ENOATTR
} }
// The default SetXAttr returns ENOATTR // The default SetXAttr returns ENOATTR
func (n *DefaultOperations) SetXAttr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno { func (n *OperationStubs) SetXAttr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno {
return syscall.EROFS return syscall.EROFS
} }
// The default RemoveXAttr returns ENOATTR // The default RemoveXAttr returns ENOATTR
func (n *DefaultOperations) RemoveXAttr(ctx context.Context, attr string) syscall.Errno { func (n *OperationStubs) RemoveXAttr(ctx context.Context, attr string) syscall.Errno {
return ENOATTR return ENOATTR
} }
// The default RemoveXAttr returns an empty list // The default RemoveXAttr returns an empty list
func (n *DefaultOperations) ListXAttr(ctx context.Context, dest []byte) (uint32, syscall.Errno) { func (n *OperationStubs) ListXAttr(ctx context.Context, dest []byte) (uint32, syscall.Errno) {
return 0, OK return 0, OK
} }
// DefaultFileHandle satisfies the FileHandle interface, and provides // FileHandleStubs satisfies the FileHandle interface, and provides
// stub methods that return ENOTSUP for all operations. // stub methods that return ENOTSUP for all operations.
type DefaultFileHandle struct { type FileHandleStubs struct {
} }
var _ = FileHandle((*DefaultFileHandle)(nil)) var _ = FileHandle((*FileHandleStubs)(nil))
func (f *DefaultFileHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) { func (f *FileHandleStubs) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
return nil, syscall.ENOTSUP return nil, syscall.ENOTSUP
} }
func (f *DefaultFileHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno) { func (f *FileHandleStubs) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno) {
return 0, syscall.ENOTSUP return 0, syscall.ENOTSUP
} }
func (f *DefaultFileHandle) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) { func (f *FileHandleStubs) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) { func (f *FileHandleStubs) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) { func (f *FileHandleStubs) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) Flush(ctx context.Context) syscall.Errno { func (f *FileHandleStubs) Flush(ctx context.Context) syscall.Errno {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) Release(ctx context.Context) syscall.Errno { func (f *FileHandleStubs) Release(ctx context.Context) syscall.Errno {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno { func (f *FileHandleStubs) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno { func (f *FileHandleStubs) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) Allocate(ctx context.Context, off uint64, size uint64, mode uint32) (errno syscall.Errno) { func (f *FileHandleStubs) Allocate(ctx context.Context, off uint64, size uint64, mode uint32) (errno syscall.Errno) {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) { func (f *FileHandleStubs) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) {
return syscall.ENOTSUP return syscall.ENOTSUP
} }
func (f *DefaultFileHandle) Lseek(ctx context.Context, off uint64, whence uint32) (uint64, syscall.Errno) { func (f *FileHandleStubs) Lseek(ctx context.Context, off uint64, whence uint32) (uint64, syscall.Errno) {
return 0, syscall.ENOTSUP return 0, syscall.ENOTSUP
} }
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
) )
type dioRoot struct { type dioRoot struct {
DefaultOperations OperationStubs
} }
func (r *dioRoot) OnAdd(ctx context.Context) { func (r *dioRoot) OnAdd(ctx context.Context) {
...@@ -27,7 +27,7 @@ func (r *dioRoot) OnAdd(ctx context.Context) { ...@@ -27,7 +27,7 @@ func (r *dioRoot) OnAdd(ctx context.Context) {
// A file handle that pretends that every hole/data starts at // A file handle that pretends that every hole/data starts at
// multiples of 1024 // multiples of 1024
type dioFH struct { type dioFH struct {
DefaultFileHandle FileHandleStubs
} }
func (f *dioFH) Lseek(ctx context.Context, off uint64, whence uint32) (uint64, syscall.Errno) { func (f *dioFH) Lseek(ctx context.Context, off uint64, whence uint32) (uint64, syscall.Errno) {
...@@ -42,7 +42,7 @@ func (fh *dioFH) Read(ctx context.Context, data []byte, off int64) (fuse.ReadRes ...@@ -42,7 +42,7 @@ func (fh *dioFH) Read(ctx context.Context, data []byte, off int64) (fuse.ReadRes
// overrides Open so it can return a dioFH file handle // overrides Open so it can return a dioFH file handle
type dioFile struct { type dioFile struct {
DefaultOperations OperationStubs
} }
func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, errno syscall.Errno) { func (f *dioFile) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, errno syscall.Errno) {
......
...@@ -17,12 +17,12 @@ import ( ...@@ -17,12 +17,12 @@ import (
) )
type interruptRoot struct { type interruptRoot struct {
DefaultOperations OperationStubs
child interruptOps child interruptOps
} }
type interruptOps struct { type interruptOps struct {
DefaultOperations OperationStubs
interrupted bool interrupted bool
} }
......
...@@ -41,7 +41,7 @@ func (n *loopbackRoot) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.E ...@@ -41,7 +41,7 @@ func (n *loopbackRoot) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.E
} }
type loopbackNode struct { type loopbackNode struct {
DefaultOperations OperationStubs
} }
func (n *loopbackNode) root() *loopbackRoot { func (n *loopbackNode) root() *loopbackRoot {
......
...@@ -106,7 +106,7 @@ func TestZipFS(t *testing.T) { ...@@ -106,7 +106,7 @@ func TestZipFS(t *testing.T) {
// zipFile is a file read from a zip archive. // zipFile is a file read from a zip archive.
type zipFile struct { type zipFile struct {
DefaultOperations OperationStubs
file *zip.File file *zip.File
mu sync.Mutex mu sync.Mutex
...@@ -157,7 +157,7 @@ func (zf *zipFile) Read(ctx context.Context, f FileHandle, dest []byte, off int6 ...@@ -157,7 +157,7 @@ func (zf *zipFile) Read(ctx context.Context, f FileHandle, dest []byte, off int6
// zipRoot is the root of the Zip filesystem. Its only functionality // zipRoot is the root of the Zip filesystem. Its only functionality
// is populating the filesystem. // is populating the filesystem.
type zipRoot struct { type zipRoot struct {
DefaultOperations OperationStubs
r *zip.Reader r *zip.Reader
} }
...@@ -177,7 +177,7 @@ func (zr *zipRoot) OnAdd(ctx context.Context) { ...@@ -177,7 +177,7 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
} }
ch := p.GetChild(component) ch := p.GetChild(component)
if ch == nil { if ch == nil {
ch = p.NewPersistentInode(ctx, &DefaultOperations{}, ch = p.NewPersistentInode(ctx, &OperationStubs{},
NodeAttr{Mode: fuse.S_IFDIR}) NodeAttr{Mode: fuse.S_IFDIR})
p.AddChild(component, ch, true) p.AddChild(component, ch, true)
} }
......
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