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
Kirill Smelkov
go-fuse
Commits
cbed0736
Commit
cbed0736
authored
Mar 24, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: provide Inode.Root rather than Inode.IsRoot
Use this to simplify loopbackNode.
parent
30bc3e19
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
36 deletions
+34
-36
nodefs/inode.go
nodefs/inode.go
+6
-7
nodefs/loopback.go
nodefs/loopback.go
+21
-27
nodefs/loopback_linux.go
nodefs/loopback_linux.go
+7
-2
No files found.
nodefs/inode.go
View file @
cbed0736
...
...
@@ -13,8 +13,6 @@ import (
"sync"
"syscall"
"unsafe"
"github.com/hanwen/go-fuse/fuse"
)
type
parentData
struct
{
...
...
@@ -76,8 +74,9 @@ type Inode struct {
// by calling removeRef.
persistent
bool
// changeCounter increments every time the below mutable state
// (lookupCount, nodeAttr, children, parents) is modified.
// changeCounter increments every time the mutable state
// (lookupCount, persistent, children, parents) protected by
// mu is modified.
//
// This is used in places where we have to relock inode into inode
// group lock, and after locking the group we have to check if inode
...
...
@@ -113,9 +112,9 @@ func (n *Inode) Mode() uint32 {
return
n
.
nodeAttr
.
Mode
}
//
IsRoot returns true if this is the root of the FUSE mount.
func
(
n
*
Inode
)
IsRoot
()
bool
{
return
n
.
nodeAttr
.
Ino
==
fuse
.
FUSE_ROOT_ID
//
Returns the root of the tree
func
(
n
*
Inode
)
Root
()
*
Inode
{
return
n
.
bridge
.
root
}
// debugString is used for debugging. Racy.
...
...
nodefs/loopback.go
View file @
cbed0736
...
...
@@ -16,16 +16,10 @@ import (
type
loopbackRoot
struct
{
loopbackNode
root
string
root
Path
string
rootDev
uint64
}
func
(
n
*
loopbackRoot
)
newLoopbackNode
()
*
loopbackNode
{
return
&
loopbackNode
{
rootNode
:
n
,
}
}
func
(
n
*
loopbackNode
)
StatFs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
{
s
:=
syscall
.
Statfs_t
{}
err
:=
syscall
.
Statfs
(
n
.
path
(),
&
s
)
...
...
@@ -37,9 +31,8 @@ func (n *loopbackNode) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.
}
func
(
n
*
loopbackRoot
)
GetAttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
var
err
error
=
nil
st
:=
syscall
.
Stat_t
{}
err
=
syscall
.
Stat
(
n
.
root
,
&
st
)
err
:=
syscall
.
Stat
(
n
.
rootPath
,
&
st
)
if
err
!=
nil
{
return
ToErrno
(
err
)
}
...
...
@@ -49,13 +42,15 @@ func (n *loopbackRoot) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.E
type
loopbackNode
struct
{
DefaultOperations
}
rootNode
*
loopbackRoot
func
(
n
*
loopbackNode
)
root
()
*
loopbackRoot
{
return
n
.
Inode
()
.
Root
()
.
Operations
()
.
(
*
loopbackRoot
)
}
func
(
n
*
loopbackNode
)
path
()
string
{
path
:=
n
.
Inode
()
.
Path
(
nil
)
return
filepath
.
Join
(
n
.
root
Node
.
root
,
path
)
return
filepath
.
Join
(
n
.
root
()
.
rootPath
,
path
)
}
func
(
n
*
loopbackNode
)
Lookup
(
ctx
context
.
Context
,
name
string
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
syscall
.
Errno
)
{
...
...
@@ -68,8 +63,8 @@ func (n *loopbackNode) Lookup(ctx context.Context, name string, out *fuse.EntryO
}
out
.
Attr
.
FromStat
(
&
st
)
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
Node
.
idFromStat
(
&
st
))
node
:=
&
loopbackNode
{}
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
()
.
idFromStat
(
&
st
))
return
ch
,
0
}
...
...
@@ -87,8 +82,8 @@ func (n *loopbackNode) Mknod(ctx context.Context, name string, mode, rdev uint32
out
.
Attr
.
FromStat
(
&
st
)
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
Node
.
idFromStat
(
&
st
))
node
:=
&
loopbackNode
{}
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
()
.
idFromStat
(
&
st
))
return
ch
,
0
}
...
...
@@ -107,8 +102,8 @@ func (n *loopbackNode) Mkdir(ctx context.Context, name string, mode uint32, out
out
.
Attr
.
FromStat
(
&
st
)
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
Node
.
idFromStat
(
&
st
))
node
:=
&
loopbackNode
{}
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
()
.
idFromStat
(
&
st
))
return
ch
,
0
}
...
...
@@ -178,8 +173,8 @@ func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mo
return
nil
,
nil
,
0
,
ToErrno
(
err
)
}
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
Node
.
idFromStat
(
&
st
))
node
:=
&
loopbackNode
{}
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
()
.
idFromStat
(
&
st
))
lf
:=
NewLoopbackFile
(
fd
)
return
ch
,
lf
,
0
,
0
}
...
...
@@ -195,8 +190,8 @@ func (n *loopbackNode) Symlink(ctx context.Context, target, name string, out *fu
syscall
.
Unlink
(
p
)
return
nil
,
ToErrno
(
err
)
}
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
Node
.
idFromStat
(
&
st
))
node
:=
&
loopbackNode
{}
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
()
.
idFromStat
(
&
st
))
out
.
Attr
.
FromStat
(
&
st
)
return
ch
,
0
...
...
@@ -215,8 +210,8 @@ func (n *loopbackNode) Link(ctx context.Context, target Operations, name string,
syscall
.
Unlink
(
p
)
return
nil
,
ToErrno
(
err
)
}
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
Node
.
idFromStat
(
&
st
))
node
:=
&
loopbackNode
{}
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
root
()
.
idFromStat
(
&
st
))
out
.
Attr
.
FromStat
(
&
st
)
return
ch
,
0
...
...
@@ -288,9 +283,8 @@ func NewLoopbackRoot(root string) (DirOperations, error) {
}
n
:=
&
loopbackRoot
{
root
:
root
,
root
Path
:
root
,
rootDev
:
uint64
(
st
.
Dev
),
}
n
.
rootNode
=
n
return
n
,
nil
}
nodefs/loopback_linux.go
View file @
cbed0736
...
...
@@ -47,13 +47,18 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
if
err
:=
syscall
.
Fstat
(
fd1
,
&
st
);
err
!=
nil
{
return
ToErrno
(
err
)
}
if
!
n
.
Inode
()
.
IsRoot
()
&&
n
.
Inode
()
.
NodeAttr
()
.
Ino
!=
n
.
rootNode
.
idFromStat
(
&
st
)
.
Ino
{
// Double check that nodes didn't change from under us.
inode
:=
n
.
Inode
()
if
inode
.
Root
()
!=
inode
&&
inode
.
NodeAttr
()
.
Ino
!=
n
.
root
()
.
idFromStat
(
&
st
)
.
Ino
{
return
syscall
.
EBUSY
}
if
err
:=
syscall
.
Fstat
(
fd2
,
&
st
);
err
!=
nil
{
return
ToErrno
(
err
)
}
if
!
newparent
.
Inode
()
.
IsRoot
()
&&
newparent
.
Inode
()
.
NodeAttr
()
.
Ino
!=
n
.
rootNode
.
idFromStat
(
&
st
)
.
Ino
{
newinode
:=
newparent
.
Inode
()
if
newinode
.
Root
()
!=
newinode
&&
newinode
.
NodeAttr
()
.
Ino
!=
n
.
root
()
.
idFromStat
(
&
st
)
.
Ino
{
return
syscall
.
EBUSY
}
...
...
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