From 923b2e69ead5cc45c1c21f867b9f3bd8b09eaac2 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 27 Feb 2015 09:59:51 +1100 Subject: [PATCH] Moved NotImplementedFileSystem to reduce clutter. --- README.md | 8 ++--- file_system.go | 4 +-- fuseutil/doc.go | 5 ++++ fuseutil/not_implemented_file_system.go | 40 +++++++++++++++++++++++++ not_implemented_file_system.go | 37 ----------------------- samples/hello_fs.go | 3 +- 6 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 fuseutil/doc.go create mode 100644 fuseutil/not_implemented_file_system.go delete mode 100644 not_implemented_file_system.go diff --git a/README.md b/README.md index cd2bbf5..f81ea42 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ and contains a decent amount of canned behavior. 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 - about. + * A single interface (`fuse.FileSystem`) for all of the methods that you might + care about. * No surprises in the form of magic/default behaviors. You must provide an implementation for every method in the interface. Embed a - `NotImplementedFileSystem` struct to have default implementations that - return `ENOSYS`. + `fuseutil.NotImplementedFileSystem` struct to have default implementations + that return `ENOSYS`. * 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 diff --git a/file_system.go b/file_system.go index a1f5335..afb355d 100644 --- a/file_system.go +++ b/file_system.go @@ -15,8 +15,8 @@ import ( // FUSE. See also the comments on request and response structs. // // Not all methods need to have interesting implementations. Embed a field of -// type NotImplementedFileSystem to inherit defaults that return ENOSYS to the -// kernel. +// type fuseutil.NotImplementedFileSystem to inherit defaults that return +// ENOSYS to the kernel. // // Must be safe for concurrent access via all methods. type FileSystem interface { diff --git a/fuseutil/doc.go b/fuseutil/doc.go new file mode 100644 index 0000000..9214a07 --- /dev/null +++ b/fuseutil/doc.go @@ -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 diff --git a/fuseutil/not_implemented_file_system.go b/fuseutil/not_implemented_file_system.go new file mode 100644 index 0000000..7a489d0 --- /dev/null +++ b/fuseutil/not_implemented_file_system.go @@ -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 +} diff --git a/not_implemented_file_system.go b/not_implemented_file_system.go deleted file mode 100644 index 4791584..0000000 --- a/not_implemented_file_system.go +++ /dev/null @@ -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 -} diff --git a/samples/hello_fs.go b/samples/hello_fs.go index a15dce2..8f27717 100644 --- a/samples/hello_fs.go +++ b/samples/hello_fs.go @@ -5,6 +5,7 @@ package samples import ( "github.com/jacobsa/fuse" + "github.com/jacobsa/fuse/fuseutil" "github.com/jacobsa/gcsfuse/timeutil" "golang.org/x/net/context" ) @@ -17,7 +18,7 @@ import ( // // Each file contains the string "Hello, world!". type HelloFS struct { - fuse.NotImplementedFileSystem + fuseutil.NotImplementedFileSystem Clock timeutil.Clock }