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
bece857c
Commit
bece857c
authored
Mar 22, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: pass context to OnAdd
parent
5531575a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
27 additions
and
36 deletions
+27
-36
nodefs/README.md
nodefs/README.md
+0
-11
nodefs/api.go
nodefs/api.go
+1
-1
nodefs/bridge.go
nodefs/bridge.go
+4
-3
nodefs/cache_test.go
nodefs/cache_test.go
+3
-3
nodefs/default.go
nodefs/default.go
+2
-2
nodefs/inode.go
nodefs/inode.go
+7
-6
nodefs/interrupt_test.go
nodefs/interrupt_test.go
+1
-1
nodefs/loopback.go
nodefs/loopback.go
+6
-6
nodefs/zip_test.go
nodefs/zip_test.go
+3
-3
No files found.
nodefs/README.md
View file @
bece857c
...
...
@@ -54,8 +54,6 @@ Decisions
To decide
=========
*
Should we provide automatic fileID numbering?
*
function signatures, or types? The latter is easier to remember?
Easier to extend? The latter less efficient (indirections/copies)
...
...
@@ -76,14 +74,5 @@ or
```
*
What to do with semi-unused fields (CreateIn.Umask, OpenIn.Mode, etc.)
*
Readlink return: []byte or string ?
*
Should Operations.Lookup return
*
Inode or Operations ?
*
Merge Fsync/FsyncDir?
*
OnMount in Operations or in Options? Or argument to NewNodeFS? Or
OnAdd() ?
nodefs/api.go
View file @
bece857c
...
...
@@ -104,7 +104,7 @@ type Operations interface {
// OnAdd is called once this Operations object is attached to
// an Inode.
OnAdd
()
OnAdd
(
ctx
context
.
Context
)
}
// XAttrOperations is a collection of methods used to implement extended attributes.
...
...
nodefs/bridge.go
View file @
bece857c
...
...
@@ -5,6 +5,7 @@
package
nodefs
import
(
"context"
"log"
"sync"
"syscall"
...
...
@@ -44,7 +45,7 @@ type rawBridge struct {
}
// newInode creates creates new inode pointing to ops.
func
(
b
*
rawBridge
)
newInode
(
ops
Operations
,
id
NodeAttr
,
persistent
bool
)
*
Inode
{
func
(
b
*
rawBridge
)
newInode
(
ctx
context
.
Context
,
ops
Operations
,
id
NodeAttr
,
persistent
bool
)
*
Inode
{
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
...
...
@@ -104,7 +105,7 @@ func (b *rawBridge) newInode(ops Operations, id NodeAttr, persistent bool) *Inod
newIno
:=
ops
.
inode
()
if
newIno
==
inode
{
newIno
.
ops
.
OnAdd
()
newIno
.
ops
.
OnAdd
(
ctx
)
}
return
newIno
...
...
@@ -188,7 +189,7 @@ func NewNodeFS(root DirOperations, opts *Options) fuse.RawFileSystem {
// Fh 0 means no file handle.
bridge
.
files
=
[]
*
fileEntry
{{}}
root
.
OnAdd
()
root
.
OnAdd
(
context
.
Background
()
)
return
bridge
}
...
...
nodefs/cache_test.go
View file @
bece857c
...
...
@@ -66,20 +66,20 @@ type keepCacheRoot struct {
keep
,
nokeep
*
keepCacheFile
}
func
(
r
*
keepCacheRoot
)
OnAdd
()
{
func
(
r
*
keepCacheRoot
)
OnAdd
(
ctx
context
.
Context
)
{
i
:=
InodeOf
(
r
)
r
.
keep
=
&
keepCacheFile
{
keepCache
:
true
,
}
r
.
keep
.
setContent
(
0
)
i
.
AddChild
(
"keep"
,
i
.
NewInode
(
r
.
keep
,
NodeAttr
{}),
true
)
i
.
AddChild
(
"keep"
,
i
.
NewInode
(
ctx
,
r
.
keep
,
NodeAttr
{}),
true
)
r
.
nokeep
=
&
keepCacheFile
{
keepCache
:
false
,
}
r
.
nokeep
.
setContent
(
0
)
i
.
AddChild
(
"nokeep"
,
i
.
NewInode
(
r
.
nokeep
,
NodeAttr
{}),
true
)
i
.
AddChild
(
"nokeep"
,
i
.
NewInode
(
ctx
,
r
.
nokeep
,
NodeAttr
{}),
true
)
}
func
TestKeepCache
(
t
*
testing
.
T
)
{
...
...
nodefs/default.go
View file @
bece857c
...
...
@@ -63,8 +63,8 @@ func (n *DefaultOperations) StatFs(ctx context.Context, out *fuse.StatfsOut) fus
return
fuse
.
OK
}
func
(
n
*
DefaultOperations
)
OnAdd
()
{
// XXX context?
// The default OnAdd does nothing.
func
(
n
*
DefaultOperations
)
OnAdd
(
ctx
context
.
Context
)
{
}
// GetAttr zeroes out argument and returns OK.
...
...
nodefs/inode.go
View file @
bece857c
...
...
@@ -5,6 +5,7 @@
package
nodefs
import
(
"context"
"fmt"
"log"
"sort"
...
...
@@ -272,8 +273,8 @@ func (iparent *Inode) setEntry(name string, ichild *Inode) {
// NewPersistentInode returns an Inode whose lifetime is not in
// control of the kernel.
func
(
n
*
Inode
)
NewPersistentInode
(
node
Operations
,
id
NodeAttr
)
*
Inode
{
return
n
.
newInode
(
node
,
id
,
true
)
func
(
n
*
Inode
)
NewPersistentInode
(
ctx
context
.
Context
,
node
Operations
,
id
NodeAttr
)
*
Inode
{
return
n
.
newInode
(
ctx
,
node
,
id
,
true
)
}
// ForgetPersistent manually marks the node as no longer important. If
...
...
@@ -288,12 +289,12 @@ func (n *Inode) ForgetPersistent() {
// non-zero, is used to implement hard-links. If opaqueID is given,
// and another node with the same ID is known, that will node will be
// returned, and the passed-in `node` is ignored.
func
(
n
*
Inode
)
NewInode
(
node
Operations
,
id
NodeAttr
)
*
Inode
{
return
n
.
newInode
(
node
,
id
,
false
)
func
(
n
*
Inode
)
NewInode
(
ctx
context
.
Context
,
node
Operations
,
id
NodeAttr
)
*
Inode
{
return
n
.
newInode
(
ctx
,
node
,
id
,
false
)
}
func
(
n
*
Inode
)
newInode
(
node
Operations
,
id
NodeAttr
,
persistent
bool
)
*
Inode
{
return
n
.
bridge
.
newInode
(
node
,
id
,
persistent
)
func
(
n
*
Inode
)
newInode
(
ctx
context
.
Context
,
node
Operations
,
id
NodeAttr
,
persistent
bool
)
*
Inode
{
return
n
.
bridge
.
newInode
(
ctx
,
node
,
id
,
persistent
)
}
// removeRef decreases references. Returns if this operation caused
...
...
nodefs/interrupt_test.go
View file @
bece857c
...
...
@@ -29,7 +29,7 @@ func (r *interruptRoot) Lookup(ctx context.Context, name string, out *fuse.Entry
if
name
!=
"file"
{
return
nil
,
fuse
.
ENOENT
}
ch
:=
InodeOf
(
r
)
.
NewInode
(
&
r
.
child
,
NodeAttr
{
ch
:=
InodeOf
(
r
)
.
NewInode
(
ctx
,
&
r
.
child
,
NodeAttr
{
Ino
:
2
,
Gen
:
1
})
...
...
nodefs/loopback.go
View file @
bece857c
...
...
@@ -70,7 +70,7 @@ func (n *loopbackNode) Lookup(ctx context.Context, name string, out *fuse.EntryO
out
.
Attr
.
FromStat
(
&
st
)
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
return
ch
,
fuse
.
OK
}
...
...
@@ -89,7 +89,7 @@ func (n *loopbackNode) Mknod(ctx context.Context, name string, mode, rdev uint32
out
.
Attr
.
FromStat
(
&
st
)
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
return
ch
,
fuse
.
OK
}
...
...
@@ -109,7 +109,7 @@ func (n *loopbackNode) Mkdir(ctx context.Context, name string, mode uint32, out
out
.
Attr
.
FromStat
(
&
st
)
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
return
ch
,
fuse
.
OK
}
...
...
@@ -180,7 +180,7 @@ func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mo
}
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
lf
:=
NewLoopbackFile
(
fd
)
return
ch
,
lf
,
0
,
fuse
.
OK
}
...
...
@@ -197,7 +197,7 @@ func (n *loopbackNode) Symlink(ctx context.Context, target, name string, out *fu
return
nil
,
fuse
.
ToStatus
(
err
)
}
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
out
.
Attr
.
FromStat
(
&
st
)
return
ch
,
fuse
.
OK
...
...
@@ -217,7 +217,7 @@ func (n *loopbackNode) Link(ctx context.Context, target Operations, name string,
return
nil
,
fuse
.
ToStatus
(
err
)
}
node
:=
n
.
rootNode
.
newLoopbackNode
()
ch
:=
n
.
inode
()
.
NewInode
(
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
ch
:=
n
.
inode
()
.
NewInode
(
ctx
,
node
,
n
.
rootNode
.
idFromStat
(
&
st
))
out
.
Attr
.
FromStat
(
&
st
)
return
ch
,
fuse
.
OK
...
...
nodefs/zip_test.go
View file @
bece857c
...
...
@@ -167,7 +167,7 @@ type zipRoot struct {
r
*
zip
.
Reader
}
func
(
zr
*
zipRoot
)
OnAdd
()
{
func
(
zr
*
zipRoot
)
OnAdd
(
ctx
context
.
Context
)
{
// OnAdd is called once we are attached to an Inode. We can
// then construct a tree. We construct the entire tree, and
// we don't want parts of the tree to disappear when the
...
...
@@ -182,14 +182,14 @@ func (zr *zipRoot) OnAdd() {
}
ch
:=
p
.
GetChild
(
component
)
if
ch
==
nil
{
ch
=
InodeOf
(
zr
)
.
NewPersistentInode
(
&
DefaultOperations
{},
ch
=
InodeOf
(
zr
)
.
NewPersistentInode
(
ctx
,
&
DefaultOperations
{},
NodeAttr
{
Mode
:
fuse
.
S_IFDIR
})
p
.
AddChild
(
component
,
ch
,
true
)
}
p
=
ch
}
ch
:=
InodeOf
(
zr
)
.
NewPersistentInode
(
&
zipFile
{
file
:
f
},
NodeAttr
{})
ch
:=
InodeOf
(
zr
)
.
NewPersistentInode
(
ctx
,
&
zipFile
{
file
:
f
},
NodeAttr
{})
p
.
AddChild
(
base
,
ch
,
true
)
}
}
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