Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
8c22b3ff
Commit
8c22b3ff
authored
Mar 27, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: split the dual function of OperationStubs
Provide InodeLink/InodeEmbed which implements linking machinery.
parent
e6ec0065
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
21 deletions
+38
-21
nodefs/api.go
nodefs/api.go
+13
-6
nodefs/default.go
nodefs/default.go
+25
-15
No files found.
nodefs/api.go
View file @
8c22b3ff
...
...
@@ -64,12 +64,9 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
// Operations is the interface that implements the filesystem inode.
// Each Operations instance must embed OperationStubs. All error
// reporting must use the syscall.Errno type. The value 0 (`OK`)
// should be used to indicate success. The method names are inspired
// on the system call names, so we have Listxattr rather than ListXAttr.
type
Operations
interface
{
// InodeLink provides the machinery to connect Operations (user
// defined methods) to Inode (a node in the filesystem tree).
type
InodeLink
interface
{
// populateInode and inode are used by nodefs internally to
// link Inode to a Node.
//
...
...
@@ -82,6 +79,16 @@ type Operations interface {
// the lifetime of the node object. Inode() is provided by
// OperationStubs, and should not be reimplemented.
Inode
()
*
Inode
}
// Operations is the interface that implements the filesystem inode.
// Each Operations instance must embed OperationStubs. All error
// reporting must use the syscall.Errno type. The value 0 (`OK`)
// should be used to indicate success. The method names are inspired
// on the system call names, so we have Listxattr rather than
// ListXAttr.
type
Operations
interface
{
InodeLink
// Statfs implements statistics for the filesystem that holds
// this Inode.
...
...
nodefs/default.go
View file @
8c22b3ff
...
...
@@ -12,27 +12,20 @@ import (
"github.com/hanwen/go-fuse/internal"
)
// OperationStubs provides no-operation default implementations for
// all the XxxOperations interfaces. The stubs provide useful defaults
// for implementing a read-only filesystem whose tree is constructed
// beforehand in the OnAdd method of the root. A example is in
// zip_test.go
//
// It must be embedded in any Operations implementation.
type
OperationStubs
struct
{
// InodeEmbed embeds the Inode into a filesystem node. It is the only
// type that implements the InodeLink interface, and hence, it must be
// part of any implementation of Operations.
type
InodeEmbed
struct
{
inode_
Inode
}
// check that we have implemented all interface methods
var
_
DirOperations
=
&
OperationStubs
{}
var
_
FileOperations
=
&
OperationStubs
{}
var
_
LockOperations
=
&
OperationStubs
{}
var
_
=
(
InodeLink
)((
*
InodeEmbed
)(
nil
))
func
(
n
*
OperationStubs
)
inode
()
*
Inode
{
func
(
n
*
InodeEmbed
)
inode
()
*
Inode
{
return
&
n
.
inode_
}
func
(
n
*
OperationStubs
)
init
(
ops
Operations
,
attr
NodeAttr
,
bridge
*
rawBridge
,
persistent
bool
)
{
func
(
n
*
InodeEmbed
)
init
(
ops
Operations
,
attr
NodeAttr
,
bridge
*
rawBridge
,
persistent
bool
)
{
n
.
inode_
=
Inode
{
ops
:
ops
,
nodeAttr
:
attr
,
...
...
@@ -46,10 +39,27 @@ func (n *OperationStubs) init(ops Operations, attr NodeAttr, bridge *rawBridge,
}
// Inode returns the Inode for this Operations
func
(
n
*
OperationStubs
)
Inode
()
*
Inode
{
func
(
n
*
InodeEmbed
)
Inode
()
*
Inode
{
return
&
n
.
inode_
}
// OperationStubs provides no-operation default implementations for
// all the XxxOperations interfaces. The stubs provide useful defaults
// for implementing a read-only filesystem whose tree is constructed
// beforehand in the OnAdd method of the root. A example is in
// zip_test.go
//
// It is recommended to embed this in any Operations implementation,
// as it is the means by new operations are supported.
type
OperationStubs
struct
{
InodeEmbed
}
// check that we have implemented all interface methods
var
_
DirOperations
=
&
OperationStubs
{}
var
_
FileOperations
=
&
OperationStubs
{}
var
_
LockOperations
=
&
OperationStubs
{}
// StatFs zeroes the out argument and returns OK. This is because OSX
// filesystems must define this, or the mount will not work.
func
(
n
*
OperationStubs
)
Statfs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment