Moved NotImplementedFileSystem to reduce clutter.

geesefs-0-30-9
Aaron Jacobs 2015-02-27 09:59:51 +11:00
parent 3a8a8855a1
commit 923b2e69ea
6 changed files with 53 additions and 44 deletions

View File

@ -8,13 +8,13 @@ and contains a decent amount of canned behavior.
The chief improvements and/or differences from the bazil.org packages are: The chief improvements and/or differences from the bazil.org packages are:
* A single interface (`FileSystem`) for all of the methods that you might care * A single interface (`fuse.FileSystem`) for all of the methods that you might
about. care about.
* No surprises in the form of magic/default behaviors. You must provide an * No surprises in the form of magic/default behaviors. You must provide an
implementation for every method in the interface. Embed a implementation for every method in the interface. Embed a
`NotImplementedFileSystem` struct to have default implementations that `fuseutil.NotImplementedFileSystem` struct to have default implementations
return `ENOSYS`. that return `ENOSYS`.
* Every method, struct, and field is thoroughly documented. This may help you * Every method, struct, and field is thoroughly documented. This may help you
get your bearings in the world of FUSE, the Linux VFS, traditional file get your bearings in the world of FUSE, the Linux VFS, traditional file

View File

@ -15,8 +15,8 @@ import (
// FUSE. See also the comments on request and response structs. // FUSE. See also the comments on request and response structs.
// //
// Not all methods need to have interesting implementations. Embed a field of // Not all methods need to have interesting implementations. Embed a field of
// type NotImplementedFileSystem to inherit defaults that return ENOSYS to the // type fuseutil.NotImplementedFileSystem to inherit defaults that return
// kernel. // ENOSYS to the kernel.
// //
// Must be safe for concurrent access via all methods. // Must be safe for concurrent access via all methods.
type FileSystem interface { type FileSystem interface {

5
fuseutil/doc.go Normal file
View File

@ -0,0 +1,5 @@
// Copyright 2015 Google Inc. All Rights Reserved.
// Author: jacobsa@google.com (Aaron Jacobs)
// Types and functions that make it easier to work with package fuse.
package fuseutil

View File

@ -0,0 +1,40 @@
// Copyright 2015 Google Inc. All Rights Reserved.
// Author: jacobsa@google.com (Aaron Jacobs)
package fuseutil
import (
"github.com/jacobsa/fuse"
"golang.org/x/net/context"
)
// Embed this within your file system type to inherit default implementations
// of all methods that return fuse.ENOSYS.
type NotImplementedFileSystem struct {
}
var _ fuse.FileSystem = &NotImplementedFileSystem{}
func (fs *NotImplementedFileSystem) LookUpInode(
ctx context.Context,
req *fuse.LookUpInodeRequest) (*fuse.LookUpInodeResponse, error) {
return nil, fuse.ENOSYS
}
func (fs *NotImplementedFileSystem) ForgetInode(
ctx context.Context,
req *fuse.ForgetInodeRequest) (*fuse.ForgetInodeResponse, error) {
return nil, fuse.ENOSYS
}
func (fs *NotImplementedFileSystem) OpenDir(
ctx context.Context,
req *fuse.OpenDirRequest) (*fuse.OpenDirResponse, error) {
return nil, fuse.ENOSYS
}
func (fs *NotImplementedFileSystem) ReleaseHandle(
ctx context.Context,
req *fuse.ReleaseHandleRequest) (*fuse.ReleaseHandleResponse, error) {
return nil, fuse.ENOSYS
}

View File

@ -1,37 +0,0 @@
// Copyright 2015 Google Inc. All Rights Reserved.
// Author: jacobsa@google.com (Aaron Jacobs)
package fuse
import "golang.org/x/net/context"
// Embed this within your file system type to inherit default implementations
// of all methods that return ENOSYS.
type NotImplementedFileSystem struct {
}
var _ FileSystem = &NotImplementedFileSystem{}
func (fs *NotImplementedFileSystem) LookUpInode(
ctx context.Context,
req *LookUpInodeRequest) (*LookUpInodeResponse, error) {
return nil, ENOSYS
}
func (fs *NotImplementedFileSystem) ForgetInode(
ctx context.Context,
req *ForgetInodeRequest) (*ForgetInodeResponse, error) {
return nil, ENOSYS
}
func (fs *NotImplementedFileSystem) OpenDir(
ctx context.Context,
req *OpenDirRequest) (*OpenDirResponse, error) {
return nil, ENOSYS
}
func (fs *NotImplementedFileSystem) ReleaseHandle(
ctx context.Context,
req *ReleaseHandleRequest) (*ReleaseHandleResponse, error) {
return nil, ENOSYS
}

View File

@ -5,6 +5,7 @@ package samples
import ( import (
"github.com/jacobsa/fuse" "github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/gcsfuse/timeutil" "github.com/jacobsa/gcsfuse/timeutil"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -17,7 +18,7 @@ import (
// //
// Each file contains the string "Hello, world!". // Each file contains the string "Hello, world!".
type HelloFS struct { type HelloFS struct {
fuse.NotImplementedFileSystem fuseutil.NotImplementedFileSystem
Clock timeutil.Clock Clock timeutil.Clock
} }