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
30bc3e19
Commit
30bc3e19
authored
Mar 23, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: drop InodeOf
parent
8ada39b5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
27 deletions
+18
-27
nodefs/api.go
nodefs/api.go
+7
-16
nodefs/cache_test.go
nodefs/cache_test.go
+2
-2
nodefs/default.go
nodefs/default.go
+4
-4
nodefs/interrupt_test.go
nodefs/interrupt_test.go
+1
-1
nodefs/loopback.go
nodefs/loopback.go
+1
-1
nodefs/loopback_linux.go
nodefs/loopback_linux.go
+2
-2
nodefs/zip_test.go
nodefs/zip_test.go
+1
-1
No files found.
nodefs/api.go
View file @
30bc3e19
...
@@ -64,31 +64,22 @@ import (
...
@@ -64,31 +64,22 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
)
)
// InodeOf returns index-node associated with filesystem node.
//
// The identity of the Inode does not change over the lifetime of
// the node object.
func
InodeOf
(
node
Operations
)
*
Inode
{
return
node
.
inode
()
}
// 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 DefaultNode. 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
{
// setInode and inode are used by nodefs internally to link Inode to a Node.
// populateInode and inode are used by nodefs internally to
//
// link Inode to a Node.
// When a new Node instance is created, e.g. on Lookup, it has nil Inode.
// Nodefs infrastructure will notice this and associate created Node with new Inode.
//
//
// See Inode
Of for
public API to retrieve an inode from Node.
// See Inode
() for the
public API to retrieve an inode from Node.
inode
()
*
Inode
inode
()
*
Inode
init
(
ops
Operations
,
attr
NodeAttr
,
bridge
*
rawBridge
,
persistent
bool
)
init
(
ops
Operations
,
attr
NodeAttr
,
bridge
*
rawBridge
,
persistent
bool
)
// Inode() is a convenience method, and is equivalent to
// Inode returns the *Inode associated with this Operations
// InodeOf(ops) It is provided by DefaultOperations, and
// instance. The identity of the Inode does not change over
// should not be reimplemented.
// the lifetime of the node object. Inode() is provided by
// DefaultOperations, 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
...
...
nodefs/cache_test.go
View file @
30bc3e19
...
@@ -68,7 +68,7 @@ type keepCacheRoot struct {
...
@@ -68,7 +68,7 @@ type keepCacheRoot struct {
}
}
func
(
r
*
keepCacheRoot
)
OnAdd
(
ctx
context
.
Context
)
{
func
(
r
*
keepCacheRoot
)
OnAdd
(
ctx
context
.
Context
)
{
i
:=
InodeOf
(
r
)
i
:=
r
.
Inode
(
)
r
.
keep
=
&
keepCacheFile
{
r
.
keep
=
&
keepCacheFile
{
keepCache
:
true
,
keepCache
:
true
,
...
@@ -113,7 +113,7 @@ func TestKeepCache(t *testing.T) {
...
@@ -113,7 +113,7 @@ func TestKeepCache(t *testing.T) {
t
.
Errorf
(
"keep read 2 got %q want read 1 %q"
,
c2
,
c1
)
t
.
Errorf
(
"keep read 2 got %q want read 1 %q"
,
c2
,
c1
)
}
}
if
s
:=
InodeOf
(
root
.
keep
)
.
NotifyContent
(
0
,
100
);
s
!=
OK
{
if
s
:=
root
.
keep
.
Inode
(
)
.
NotifyContent
(
0
,
100
);
s
!=
OK
{
t
.
Errorf
(
"NotifyContent: %v"
,
s
)
t
.
Errorf
(
"NotifyContent: %v"
,
s
)
}
}
...
...
nodefs/default.go
View file @
30bc3e19
...
@@ -43,7 +43,7 @@ func (n *DefaultOperations) init(ops Operations, attr NodeAttr, bridge *rawBridg
...
@@ -43,7 +43,7 @@ func (n *DefaultOperations) init(ops Operations, attr NodeAttr, bridge *rawBridg
}
}
}
}
// Inode
is syntactic sugar for InodeOf(ops).
// Inode
returns the Inode for this Operations
func
(
n
*
DefaultOperations
)
Inode
()
*
Inode
{
func
(
n
*
DefaultOperations
)
Inode
()
*
Inode
{
return
&
n
.
inode_
return
&
n
.
inode_
}
}
...
@@ -79,7 +79,7 @@ func (n *DefaultOperations) Access(ctx context.Context, mask uint32) syscall.Err
...
@@ -79,7 +79,7 @@ func (n *DefaultOperations) Access(ctx context.Context, mask uint32) syscall.Err
}
}
var
out
fuse
.
AttrOut
var
out
fuse
.
AttrOut
if
s
:=
InodeOf
(
n
)
.
Operations
()
.
GetAttr
(
ctx
,
&
out
);
s
!=
0
{
if
s
:=
n
.
inode
(
)
.
Operations
()
.
GetAttr
(
ctx
,
&
out
);
s
!=
0
{
return
s
return
s
}
}
...
@@ -102,7 +102,7 @@ func (n *DefaultOperations) FSetAttr(ctx context.Context, f FileHandle, in *fuse
...
@@ -102,7 +102,7 @@ func (n *DefaultOperations) FSetAttr(ctx context.Context, f FileHandle, in *fuse
// The Lookup method on the DefaultOperations type looks for an
// The Lookup method on the DefaultOperations 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
*
DefaultOperations
)
Lookup
(
ctx
context
.
Context
,
name
string
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
syscall
.
Errno
)
{
ch
:=
InodeOf
(
n
)
.
GetChild
(
name
)
ch
:=
n
.
inode
(
)
.
GetChild
(
name
)
if
ch
==
nil
{
if
ch
==
nil
{
return
nil
,
syscall
.
ENOENT
return
nil
,
syscall
.
ENOENT
}
}
...
@@ -141,7 +141,7 @@ func (n *DefaultOperations) OpenDir(ctx context.Context) syscall.Errno {
...
@@ -141,7 +141,7 @@ func (n *DefaultOperations) OpenDir(ctx context.Context) syscall.Errno {
// 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
*
DefaultOperations
)
ReadDir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
{
r
:=
[]
fuse
.
DirEntry
{}
r
:=
[]
fuse
.
DirEntry
{}
for
k
,
ch
:=
range
InodeOf
(
n
)
.
Children
()
{
for
k
,
ch
:=
range
n
.
inode
(
)
.
Children
()
{
r
=
append
(
r
,
fuse
.
DirEntry
{
Mode
:
ch
.
Mode
(),
r
=
append
(
r
,
fuse
.
DirEntry
{
Mode
:
ch
.
Mode
(),
Name
:
k
,
Name
:
k
,
Ino
:
ch
.
NodeAttr
()
.
Ino
})
Ino
:
ch
.
NodeAttr
()
.
Ino
})
...
...
nodefs/interrupt_test.go
View file @
30bc3e19
...
@@ -30,7 +30,7 @@ func (r *interruptRoot) Lookup(ctx context.Context, name string, out *fuse.Entry
...
@@ -30,7 +30,7 @@ func (r *interruptRoot) Lookup(ctx context.Context, name string, out *fuse.Entry
if
name
!=
"file"
{
if
name
!=
"file"
{
return
nil
,
syscall
.
ENOENT
return
nil
,
syscall
.
ENOENT
}
}
ch
:=
InodeOf
(
r
)
.
NewInode
(
ctx
,
&
r
.
child
,
NodeAttr
{
ch
:=
r
.
Inode
(
)
.
NewInode
(
ctx
,
&
r
.
child
,
NodeAttr
{
Ino
:
2
,
Ino
:
2
,
Gen
:
1
})
Gen
:
1
})
...
...
nodefs/loopback.go
View file @
30bc3e19
...
@@ -54,7 +54,7 @@ type loopbackNode struct {
...
@@ -54,7 +54,7 @@ type loopbackNode struct {
}
}
func
(
n
*
loopbackNode
)
path
()
string
{
func
(
n
*
loopbackNode
)
path
()
string
{
path
:=
InodeOf
(
n
)
.
Path
(
nil
)
path
:=
n
.
Inode
(
)
.
Path
(
nil
)
return
filepath
.
Join
(
n
.
rootNode
.
root
,
path
)
return
filepath
.
Join
(
n
.
rootNode
.
root
,
path
)
}
}
...
...
nodefs/loopback_linux.go
View file @
30bc3e19
...
@@ -47,13 +47,13 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
...
@@ -47,13 +47,13 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
if
err
:=
syscall
.
Fstat
(
fd1
,
&
st
);
err
!=
nil
{
if
err
:=
syscall
.
Fstat
(
fd1
,
&
st
);
err
!=
nil
{
return
ToErrno
(
err
)
return
ToErrno
(
err
)
}
}
if
!
n
.
Inode
()
.
IsRoot
()
&&
InodeOf
(
n
)
.
NodeAttr
()
.
Ino
!=
n
.
rootNode
.
idFromStat
(
&
st
)
.
Ino
{
if
!
n
.
Inode
()
.
IsRoot
()
&&
n
.
Inode
(
)
.
NodeAttr
()
.
Ino
!=
n
.
rootNode
.
idFromStat
(
&
st
)
.
Ino
{
return
syscall
.
EBUSY
return
syscall
.
EBUSY
}
}
if
err
:=
syscall
.
Fstat
(
fd2
,
&
st
);
err
!=
nil
{
if
err
:=
syscall
.
Fstat
(
fd2
,
&
st
);
err
!=
nil
{
return
ToErrno
(
err
)
return
ToErrno
(
err
)
}
}
if
!
newparent
.
Inode
()
.
IsRoot
()
&&
InodeOf
(
newparent
)
.
NodeAttr
()
.
Ino
!=
n
.
rootNode
.
idFromStat
(
&
st
)
.
Ino
{
if
!
newparent
.
Inode
()
.
IsRoot
()
&&
newparent
.
Inode
(
)
.
NodeAttr
()
.
Ino
!=
n
.
rootNode
.
idFromStat
(
&
st
)
.
Ino
{
return
syscall
.
EBUSY
return
syscall
.
EBUSY
}
}
...
...
nodefs/zip_test.go
View file @
30bc3e19
...
@@ -170,7 +170,7 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
...
@@ -170,7 +170,7 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
for
_
,
f
:=
range
zr
.
r
.
File
{
for
_
,
f
:=
range
zr
.
r
.
File
{
dir
,
base
:=
filepath
.
Split
(
f
.
Name
)
dir
,
base
:=
filepath
.
Split
(
f
.
Name
)
p
:=
InodeOf
(
zr
)
p
:=
zr
.
Inode
(
)
for
_
,
component
:=
range
strings
.
Split
(
dir
,
"/"
)
{
for
_
,
component
:=
range
strings
.
Split
(
dir
,
"/"
)
{
if
len
(
component
)
==
0
{
if
len
(
component
)
==
0
{
continue
continue
...
...
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