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
0f2f00b8
Commit
0f2f00b8
authored
Apr 08, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename NodeAttr to StableAttr
parent
4e10c985
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
53 additions
and
53 deletions
+53
-53
benchmark/statfs.go
benchmark/statfs.go
+2
-2
example/hello/main.go
example/hello/main.go
+1
-1
newunionfs/unionfs.go
newunionfs/unionfs.go
+3
-3
nodefs/api.go
nodefs/api.go
+1
-1
nodefs/bridge.go
nodefs/bridge.go
+5
-5
nodefs/cache_test.go
nodefs/cache_test.go
+2
-2
nodefs/directio_test.go
nodefs/directio_test.go
+1
-1
nodefs/inode.go
nodefs/inode.go
+11
-11
nodefs/interrupt_test.go
nodefs/interrupt_test.go
+1
-1
nodefs/loopback.go
nodefs/loopback.go
+2
-2
nodefs/loopback_linux.go
nodefs/loopback_linux.go
+2
-2
nodefs/mem_test.go
nodefs/mem_test.go
+3
-3
nodefs/readonly_test.go
nodefs/readonly_test.go
+2
-2
nodefs/zip_test.go
nodefs/zip_test.go
+5
-5
zipfs/multizip.go
zipfs/multizip.go
+3
-3
zipfs/tarfs.go
zipfs/tarfs.go
+7
-7
zipfs/zipfs.go
zipfs/zipfs.go
+2
-2
No files found.
benchmark/statfs.go
View file @
0f2f00b8
...
@@ -51,7 +51,7 @@ func (r *StatFS) addFile(name string, a fuse.Attr) {
...
@@ -51,7 +51,7 @@ func (r *StatFS) addFile(name string, a fuse.Attr) {
if
ch
==
nil
{
if
ch
==
nil
{
// Create a directory
// Create a directory
ch
=
p
.
NewPersistentInode
(
context
.
Background
(),
&
nodefs
.
Inode
{},
ch
=
p
.
NewPersistentInode
(
context
.
Background
(),
&
nodefs
.
Inode
{},
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
// Add it
// Add it
p
.
AddChild
(
component
,
ch
,
true
)
p
.
AddChild
(
component
,
ch
,
true
)
}
}
...
@@ -63,7 +63,7 @@ func (r *StatFS) addFile(name string, a fuse.Attr) {
...
@@ -63,7 +63,7 @@ func (r *StatFS) addFile(name string, a fuse.Attr) {
child
:=
p
.
NewPersistentInode
(
context
.
Background
(),
&
nodefs
.
MemRegularFile
{
child
:=
p
.
NewPersistentInode
(
context
.
Background
(),
&
nodefs
.
MemRegularFile
{
Data
:
make
([]
byte
,
a
.
Size
),
Data
:
make
([]
byte
,
a
.
Size
),
Attr
:
a
,
Attr
:
a
,
},
nodefs
.
Nod
eAttr
{})
},
nodefs
.
Stabl
eAttr
{})
// And add it
// And add it
p
.
AddChild
(
base
,
child
,
true
)
p
.
AddChild
(
base
,
child
,
true
)
...
...
example/hello/main.go
View file @
0f2f00b8
...
@@ -27,7 +27,7 @@ func (r *HelloRoot) OnAdd(ctx context.Context) {
...
@@ -27,7 +27,7 @@ func (r *HelloRoot) OnAdd(ctx context.Context) {
Attr
:
fuse
.
Attr
{
Attr
:
fuse
.
Attr
{
Mode
:
0644
,
Mode
:
0644
,
},
},
},
nodefs
.
Nod
eAttr
{
Ino
:
2
})
},
nodefs
.
Stabl
eAttr
{
Ino
:
2
})
r
.
AddChild
(
"file.txt"
,
ch
,
false
)
r
.
AddChild
(
"file.txt"
,
ch
,
false
)
}
}
...
...
newunionfs/unionfs.go
View file @
0f2f00b8
...
@@ -188,7 +188,7 @@ func (n *unionFSNode) Create(ctx context.Context, name string, flags uint32, mod
...
@@ -188,7 +188,7 @@ func (n *unionFSNode) Create(ctx context.Context, name string, flags uint32, mod
return
nil
,
nil
,
0
,
err
.
(
syscall
.
Errno
)
return
nil
,
nil
,
0
,
err
.
(
syscall
.
Errno
)
}
}
ch
:=
n
.
NewInode
(
ctx
,
&
unionFSNode
{},
nodefs
.
Nod
eAttr
{
Mode
:
st
.
Mode
,
Ino
:
st
.
Ino
})
ch
:=
n
.
NewInode
(
ctx
,
&
unionFSNode
{},
nodefs
.
Stabl
eAttr
{
Mode
:
st
.
Mode
,
Ino
:
st
.
Ino
})
out
.
FromStat
(
&
st
)
out
.
FromStat
(
&
st
)
return
ch
,
nodefs
.
NewLoopbackFile
(
fd
),
0
,
0
return
ch
,
nodefs
.
NewLoopbackFile
(
fd
),
0
,
0
...
@@ -238,7 +238,7 @@ func (n *unionFSNode) Lookup(ctx context.Context, name string, out *fuse.EntryOu
...
@@ -238,7 +238,7 @@ func (n *unionFSNode) Lookup(ctx context.Context, name string, out *fuse.EntryOu
idx
:=
n
.
root
()
.
getBranch
(
p
,
&
st
)
idx
:=
n
.
root
()
.
getBranch
(
p
,
&
st
)
if
idx
>=
0
{
if
idx
>=
0
{
// XXX use idx in Ino?
// XXX use idx in Ino?
ch
:=
n
.
NewInode
(
ctx
,
&
unionFSNode
{},
nodefs
.
Nod
eAttr
{
Mode
:
st
.
Mode
,
Ino
:
st
.
Ino
})
ch
:=
n
.
NewInode
(
ctx
,
&
unionFSNode
{},
nodefs
.
Stabl
eAttr
{
Mode
:
st
.
Mode
,
Ino
:
st
.
Ino
})
out
.
FromStat
(
&
st
)
out
.
FromStat
(
&
st
)
out
.
Mode
|=
0111
out
.
Mode
|=
0111
return
ch
,
0
return
ch
,
0
...
@@ -276,7 +276,7 @@ func (n *unionFSNode) Symlink(ctx context.Context, target, name string, out *fus
...
@@ -276,7 +276,7 @@ func (n *unionFSNode) Symlink(ctx context.Context, target, name string, out *fus
out
.
FromStat
(
&
st
)
out
.
FromStat
(
&
st
)
ch
:=
n
.
NewInode
(
ctx
,
&
unionFSNode
{},
nodefs
.
Nod
eAttr
{
ch
:=
n
.
NewInode
(
ctx
,
&
unionFSNode
{},
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFLNK
,
Mode
:
syscall
.
S_IFLNK
,
Ino
:
st
.
Ino
,
Ino
:
st
.
Ino
,
})
})
...
...
nodefs/api.go
View file @
0f2f00b8
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
//
//
// func (n *myNode) Lookup(ctx context.Context, name string, ... ) (*Inode, syscall.Errno) {
// func (n *myNode) Lookup(ctx context.Context, name string, ... ) (*Inode, syscall.Errno) {
// child := myNode{}
// child := myNode{}
// return n.NewInode(ctx, &myNode{},
Nod
eAttr{Mode: syscall.S_IFDIR}), 0
// return n.NewInode(ctx, &myNode{},
Stabl
eAttr{Mode: syscall.S_IFDIR}), 0
// }
// }
//
//
// On mounting, the root InodeEmbedder is associated with root of the
// On mounting, the root InodeEmbedder is associated with root of the
...
...
nodefs/bridge.go
View file @
0f2f00b8
...
@@ -51,7 +51,7 @@ type rawBridge struct {
...
@@ -51,7 +51,7 @@ type rawBridge struct {
}
}
// newInode creates creates new inode pointing to ops.
// newInode creates creates new inode pointing to ops.
func
(
b
*
rawBridge
)
newInodeUnlocked
(
ops
InodeEmbedder
,
id
Nod
eAttr
,
persistent
bool
)
*
Inode
{
func
(
b
*
rawBridge
)
newInodeUnlocked
(
ops
InodeEmbedder
,
id
Stabl
eAttr
,
persistent
bool
)
*
Inode
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -84,7 +84,7 @@ func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent
...
@@ -84,7 +84,7 @@ func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent
// file
// file
//
//
// dir1.Lookup("file") and dir2.Lookup("file") are executed
// dir1.Lookup("file") and dir2.Lookup("file") are executed
// simultaneously. The matching
Nod
eAttrs ensure that we return the
// simultaneously. The matching
Stabl
eAttrs ensure that we return the
// same node.
// same node.
old
:=
b
.
nodes
[
id
.
Ino
]
old
:=
b
.
nodes
[
id
.
Ino
]
if
old
!=
nil
{
if
old
!=
nil
{
...
@@ -101,7 +101,7 @@ func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent
...
@@ -101,7 +101,7 @@ func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent
return
ops
.
embed
()
return
ops
.
embed
()
}
}
func
(
b
*
rawBridge
)
newInode
(
ctx
context
.
Context
,
ops
InodeEmbedder
,
id
Nod
eAttr
,
persistent
bool
)
*
Inode
{
func
(
b
*
rawBridge
)
newInode
(
ctx
context
.
Context
,
ops
InodeEmbedder
,
id
Stabl
eAttr
,
persistent
bool
)
*
Inode
{
ch
:=
b
.
newInodeUnlocked
(
ops
,
id
,
persistent
)
ch
:=
b
.
newInodeUnlocked
(
ops
,
id
,
persistent
)
if
ch
!=
ops
.
embed
()
{
if
ch
!=
ops
.
embed
()
{
return
ch
return
ch
...
@@ -183,7 +183,7 @@ func NewNodeFS(root InodeEmbedder, opts *Options) fuse.RawFileSystem {
...
@@ -183,7 +183,7 @@ func NewNodeFS(root InodeEmbedder, opts *Options) fuse.RawFileSystem {
}
}
initInode
(
root
.
embed
(),
root
,
initInode
(
root
.
embed
(),
root
,
Nod
eAttr
{
Stabl
eAttr
{
Ino
:
1
,
Ino
:
1
,
Mode
:
fuse
.
S_IFDIR
,
Mode
:
fuse
.
S_IFDIR
,
},
},
...
@@ -792,7 +792,7 @@ func (b *rawBridge) getStream(ctx context.Context, inode *Inode) (DirStream, sys
...
@@ -792,7 +792,7 @@ func (b *rawBridge) getStream(ctx context.Context, inode *Inode) (DirStream, sys
for
k
,
ch
:=
range
inode
.
Children
()
{
for
k
,
ch
:=
range
inode
.
Children
()
{
r
=
append
(
r
,
fuse
.
DirEntry
{
Mode
:
ch
.
Mode
(),
r
=
append
(
r
,
fuse
.
DirEntry
{
Mode
:
ch
.
Mode
(),
Name
:
k
,
Name
:
k
,
Ino
:
ch
.
Nod
eAttr
()
.
Ino
})
Ino
:
ch
.
Stabl
eAttr
()
.
Ino
})
}
}
return
NewListDirStream
(
r
),
0
return
NewListDirStream
(
r
),
0
}
}
...
...
nodefs/cache_test.go
View file @
0f2f00b8
...
@@ -78,13 +78,13 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
...
@@ -78,13 +78,13 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
keepCache
:
true
,
keepCache
:
true
,
}
}
r
.
keep
.
setContent
(
0
)
r
.
keep
.
setContent
(
0
)
i
.
AddChild
(
"keep"
,
i
.
NewInode
(
ctx
,
r
.
keep
,
Nod
eAttr
{}),
true
)
i
.
AddChild
(
"keep"
,
i
.
NewInode
(
ctx
,
r
.
keep
,
Stabl
eAttr
{}),
true
)
r
.
nokeep
=
&
keepCacheFile
{
r
.
nokeep
=
&
keepCacheFile
{
keepCache
:
false
,
keepCache
:
false
,
}
}
r
.
nokeep
.
setContent
(
0
)
r
.
nokeep
.
setContent
(
0
)
i
.
AddChild
(
"nokeep"
,
i
.
NewInode
(
ctx
,
r
.
nokeep
,
Nod
eAttr
{}),
true
)
i
.
AddChild
(
"nokeep"
,
i
.
NewInode
(
ctx
,
r
.
nokeep
,
Stabl
eAttr
{}),
true
)
}
}
// Test FOPEN_KEEP_CACHE. This is a little subtle: the automatic cache
// Test FOPEN_KEEP_CACHE. This is a little subtle: the automatic cache
...
...
nodefs/directio_test.go
View file @
0f2f00b8
...
@@ -20,7 +20,7 @@ type dioRoot struct {
...
@@ -20,7 +20,7 @@ type dioRoot struct {
}
}
func
(
r
*
dioRoot
)
OnAdd
(
ctx
context
.
Context
)
{
func
(
r
*
dioRoot
)
OnAdd
(
ctx
context
.
Context
)
{
r
.
Inode
.
AddChild
(
"file"
,
r
.
Inode
.
NewInode
(
ctx
,
&
dioFile
{},
Nod
eAttr
{}),
false
)
r
.
Inode
.
AddChild
(
"file"
,
r
.
Inode
.
NewInode
(
ctx
,
&
dioFile
{},
Stabl
eAttr
{}),
false
)
}
}
// A file handle that pretends that every hole/data starts at
// A file handle that pretends that every hole/data starts at
...
...
nodefs/inode.go
View file @
0f2f00b8
...
@@ -22,8 +22,8 @@ type parentData struct {
...
@@ -22,8 +22,8 @@ type parentData struct {
parent
*
Inode
parent
*
Inode
}
}
//
Nod
eAttr holds immutable attributes of a object in the filesystem.
//
Stabl
eAttr holds immutable attributes of a object in the filesystem.
type
Nod
eAttr
struct
{
type
Stabl
eAttr
struct
{
// Each Inode has a type, which does not change over the
// Each Inode has a type, which does not change over the
// lifetime of the inode, for example fuse.S_IFDIR. The default (0)
// lifetime of the inode, for example fuse.S_IFDIR. The default (0)
// is interpreted as S_IFREG (regular file).
// is interpreted as S_IFREG (regular file).
...
@@ -43,8 +43,8 @@ type NodeAttr struct {
...
@@ -43,8 +43,8 @@ type NodeAttr struct {
Gen
uint64
Gen
uint64
}
}
// Reserved returns if the
Nod
eAttr is using reserved Inode numbers.
// Reserved returns if the
Stabl
eAttr is using reserved Inode numbers.
func
(
i
*
Nod
eAttr
)
Reserved
()
bool
{
func
(
i
*
Stabl
eAttr
)
Reserved
()
bool
{
return
i
.
Ino
==
1
||
i
.
Ino
==
^
uint64
(
0
)
return
i
.
Ino
==
1
||
i
.
Ino
==
^
uint64
(
0
)
}
}
...
@@ -57,7 +57,7 @@ func (i *NodeAttr) Reserved() bool {
...
@@ -57,7 +57,7 @@ func (i *NodeAttr) Reserved() bool {
// copied. Inodes should be obtained by calling Inode.NewInode() or
// copied. Inodes should be obtained by calling Inode.NewInode() or
// Inode.NewPersistentInode().
// Inode.NewPersistentInode().
type
Inode
struct
{
type
Inode
struct
{
nodeAttr
Nod
eAttr
nodeAttr
Stabl
eAttr
ops
InodeEmbedder
ops
InodeEmbedder
bridge
*
rawBridge
bridge
*
rawBridge
...
@@ -108,7 +108,7 @@ func (n *Inode) EmbeddedInode() *Inode {
...
@@ -108,7 +108,7 @@ func (n *Inode) EmbeddedInode() *Inode {
return
n
return
n
}
}
func
initInode
(
n
*
Inode
,
ops
InodeEmbedder
,
attr
Nod
eAttr
,
bridge
*
rawBridge
,
persistent
bool
)
{
func
initInode
(
n
*
Inode
,
ops
InodeEmbedder
,
attr
Stabl
eAttr
,
bridge
*
rawBridge
,
persistent
bool
)
{
n
.
ops
=
ops
n
.
ops
=
ops
n
.
nodeAttr
=
attr
n
.
nodeAttr
=
attr
n
.
bridge
=
bridge
n
.
bridge
=
bridge
...
@@ -126,8 +126,8 @@ func (n *Inode) setEntryOut(out *fuse.EntryOut) {
...
@@ -126,8 +126,8 @@ func (n *Inode) setEntryOut(out *fuse.EntryOut) {
out
.
Mode
=
(
out
.
Attr
.
Mode
&
07777
)
|
n
.
nodeAttr
.
Mode
out
.
Mode
=
(
out
.
Attr
.
Mode
&
07777
)
|
n
.
nodeAttr
.
Mode
}
}
//
Nod
eAttr returns the (Ino, Gen) tuple for this node.
//
Stabl
eAttr returns the (Ino, Gen) tuple for this node.
func
(
n
*
Inode
)
Nod
eAttr
()
NodeAttr
{
func
(
n
*
Inode
)
Stabl
eAttr
()
NodeAttr
{
return
n
.
nodeAttr
return
n
.
nodeAttr
}
}
...
@@ -311,7 +311,7 @@ func (iparent *Inode) setEntry(name string, ichild *Inode) {
...
@@ -311,7 +311,7 @@ func (iparent *Inode) setEntry(name string, ichild *Inode) {
// NewPersistentInode returns an Inode whose lifetime is not in
// NewPersistentInode returns an Inode whose lifetime is not in
// control of the kernel.
// control of the kernel.
func
(
n
*
Inode
)
NewPersistentInode
(
ctx
context
.
Context
,
node
InodeEmbedder
,
id
Nod
eAttr
)
*
Inode
{
func
(
n
*
Inode
)
NewPersistentInode
(
ctx
context
.
Context
,
node
InodeEmbedder
,
id
Stabl
eAttr
)
*
Inode
{
return
n
.
newInode
(
ctx
,
node
,
id
,
true
)
return
n
.
newInode
(
ctx
,
node
,
id
,
true
)
}
}
...
@@ -327,11 +327,11 @@ func (n *Inode) ForgetPersistent() {
...
@@ -327,11 +327,11 @@ func (n *Inode) ForgetPersistent() {
// id.Ino argument is used to implement hard-links. If it is given,
// id.Ino argument is used to implement hard-links. If it is given,
// and another node with the same ID is known, that will node will be
// and another node with the same ID is known, that will node will be
// returned, and the passed-in `node` is ignored.
// returned, and the passed-in `node` is ignored.
func
(
n
*
Inode
)
NewInode
(
ctx
context
.
Context
,
node
InodeEmbedder
,
id
Nod
eAttr
)
*
Inode
{
func
(
n
*
Inode
)
NewInode
(
ctx
context
.
Context
,
node
InodeEmbedder
,
id
Stabl
eAttr
)
*
Inode
{
return
n
.
newInode
(
ctx
,
node
,
id
,
false
)
return
n
.
newInode
(
ctx
,
node
,
id
,
false
)
}
}
func
(
n
*
Inode
)
newInode
(
ctx
context
.
Context
,
ops
InodeEmbedder
,
id
Nod
eAttr
,
persistent
bool
)
*
Inode
{
func
(
n
*
Inode
)
newInode
(
ctx
context
.
Context
,
ops
InodeEmbedder
,
id
Stabl
eAttr
,
persistent
bool
)
*
Inode
{
return
n
.
bridge
.
newInode
(
ctx
,
ops
,
id
,
persistent
)
return
n
.
bridge
.
newInode
(
ctx
,
ops
,
id
,
persistent
)
}
}
...
...
nodefs/interrupt_test.go
View file @
0f2f00b8
...
@@ -25,7 +25,7 @@ func (r *interruptRoot) Lookup(ctx context.Context, name string, out *fuse.Entry
...
@@ -25,7 +25,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
:=
r
.
Inode
.
NewInode
(
ctx
,
&
r
.
child
,
Nod
eAttr
{
ch
:=
r
.
Inode
.
NewInode
(
ctx
,
&
r
.
child
,
Stabl
eAttr
{
Ino
:
2
,
Ino
:
2
,
Gen
:
1
})
Gen
:
1
})
...
...
nodefs/loopback.go
View file @
0f2f00b8
...
@@ -162,7 +162,7 @@ func (n *loopbackNode) Rename(ctx context.Context, name string, newParent InodeE
...
@@ -162,7 +162,7 @@ func (n *loopbackNode) Rename(ctx context.Context, name string, newParent InodeE
return
ToErrno
(
err
)
return
ToErrno
(
err
)
}
}
func
(
r
*
loopbackRoot
)
idFromStat
(
st
*
syscall
.
Stat_t
)
Nod
eAttr
{
func
(
r
*
loopbackRoot
)
idFromStat
(
st
*
syscall
.
Stat_t
)
Stabl
eAttr
{
// We compose an inode number by the underlying inode, and
// We compose an inode number by the underlying inode, and
// mixing in the device number. In traditional filesystems,
// mixing in the device number. In traditional filesystems,
// the inode numbers are small. The device numbers are also
// the inode numbers are small. The device numbers are also
...
@@ -172,7 +172,7 @@ func (r *loopbackRoot) idFromStat(st *syscall.Stat_t) NodeAttr {
...
@@ -172,7 +172,7 @@ func (r *loopbackRoot) idFromStat(st *syscall.Stat_t) NodeAttr {
// the underlying filesystem
// the underlying filesystem
swapped
:=
(
uint64
(
st
.
Dev
)
<<
32
)
|
(
uint64
(
st
.
Dev
)
>>
32
)
swapped
:=
(
uint64
(
st
.
Dev
)
<<
32
)
|
(
uint64
(
st
.
Dev
)
>>
32
)
swappedRootDev
:=
(
r
.
rootDev
<<
32
)
|
(
r
.
rootDev
>>
32
)
swappedRootDev
:=
(
r
.
rootDev
<<
32
)
|
(
r
.
rootDev
>>
32
)
return
Nod
eAttr
{
return
Stabl
eAttr
{
Mode
:
uint32
(
st
.
Mode
),
Mode
:
uint32
(
st
.
Mode
),
Gen
:
1
,
Gen
:
1
,
// This should work well for traditional backing FSes,
// This should work well for traditional backing FSes,
...
...
nodefs/loopback_linux.go
View file @
0f2f00b8
...
@@ -52,7 +52,7 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
...
@@ -52,7 +52,7 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
// Double check that nodes didn't change from under us.
// Double check that nodes didn't change from under us.
inode
:=
&
n
.
Inode
inode
:=
&
n
.
Inode
if
inode
.
Root
()
!=
inode
&&
inode
.
Nod
eAttr
()
.
Ino
!=
n
.
root
()
.
idFromStat
(
&
st
)
.
Ino
{
if
inode
.
Root
()
!=
inode
&&
inode
.
Stabl
eAttr
()
.
Ino
!=
n
.
root
()
.
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
{
...
@@ -60,7 +60,7 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
...
@@ -60,7 +60,7 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
}
}
newinode
:=
&
newparent
.
Inode
newinode
:=
&
newparent
.
Inode
if
newinode
.
Root
()
!=
newinode
&&
newinode
.
Nod
eAttr
()
.
Ino
!=
n
.
root
()
.
idFromStat
(
&
st
)
.
Ino
{
if
newinode
.
Root
()
!=
newinode
&&
newinode
.
Stabl
eAttr
()
.
Ino
!=
n
.
root
()
.
idFromStat
(
&
st
)
.
Ino
{
return
syscall
.
EBUSY
return
syscall
.
EBUSY
}
}
...
...
nodefs/mem_test.go
View file @
0f2f00b8
...
@@ -53,7 +53,7 @@ func TestDataFile(t *testing.T) {
...
@@ -53,7 +53,7 @@ func TestDataFile(t *testing.T) {
Mode
:
0464
,
Mode
:
0464
,
},
},
},
},
Nod
eAttr
{})
Stabl
eAttr
{})
n
.
AddChild
(
"file"
,
ch
,
false
)
n
.
AddChild
(
"file"
,
ch
,
false
)
},
},
})
})
...
@@ -106,7 +106,7 @@ func TestDataFileLargeRead(t *testing.T) {
...
@@ -106,7 +106,7 @@ func TestDataFileLargeRead(t *testing.T) {
Mode
:
0464
,
Mode
:
0464
,
},
},
},
},
Nod
eAttr
{})
Stabl
eAttr
{})
n
.
AddChild
(
"file"
,
ch
,
false
)
n
.
AddChild
(
"file"
,
ch
,
false
)
},
},
})
})
...
@@ -130,7 +130,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
...
@@ -130,7 +130,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
Data
:
[]
byte
(
target
),
Data
:
[]
byte
(
target
),
}
}
ch
:=
s
.
NewPersistentInode
(
ctx
,
l
,
Nod
eAttr
{
Mode
:
syscall
.
S_IFLNK
})
ch
:=
s
.
NewPersistentInode
(
ctx
,
l
,
Stabl
eAttr
{
Mode
:
syscall
.
S_IFLNK
})
return
ch
,
0
return
ch
,
0
}
}
...
...
nodefs/readonly_test.go
View file @
0f2f00b8
...
@@ -31,8 +31,8 @@ func TestDefaultPermissions(t *testing.T) {
...
@@ -31,8 +31,8 @@ func TestDefaultPermissions(t *testing.T) {
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
DefaultPermissions
:
true
,
DefaultPermissions
:
true
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
dir
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
dir
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
file
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
Nod
eAttr
{
Mode
:
syscall
.
S_IFREG
})
file
:=
root
.
NewPersistentInode
(
ctx
,
&
Inode
{},
Stabl
eAttr
{
Mode
:
syscall
.
S_IFREG
})
root
.
AddChild
(
"dir"
,
dir
,
false
)
root
.
AddChild
(
"dir"
,
dir
,
false
)
root
.
AddChild
(
"file"
,
file
,
false
)
root
.
AddChild
(
"file"
,
file
,
false
)
...
...
nodefs/zip_test.go
View file @
0f2f00b8
...
@@ -107,7 +107,7 @@ func TestZipFSOnAdd(t *testing.T) {
...
@@ -107,7 +107,7 @@ func TestZipFSOnAdd(t *testing.T) {
mnt
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
mnt
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
OnAdd
:
func
(
ctx
context
.
Context
)
{
root
.
AddChild
(
"sub"
,
root
.
AddChild
(
"sub"
,
root
.
NewPersistentInode
(
ctx
,
zr
,
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
}),
false
)
root
.
NewPersistentInode
(
ctx
,
zr
,
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
}),
false
)
},
},
})
})
defer
clean
()
defer
clean
()
...
@@ -197,13 +197,13 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
...
@@ -197,13 +197,13 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
ch
:=
p
.
GetChild
(
component
)
ch
:=
p
.
GetChild
(
component
)
if
ch
==
nil
{
if
ch
==
nil
{
ch
=
p
.
NewPersistentInode
(
ctx
,
&
Inode
{},
ch
=
p
.
NewPersistentInode
(
ctx
,
&
Inode
{},
Nod
eAttr
{
Mode
:
fuse
.
S_IFDIR
})
Stabl
eAttr
{
Mode
:
fuse
.
S_IFDIR
})
p
.
AddChild
(
component
,
ch
,
true
)
p
.
AddChild
(
component
,
ch
,
true
)
}
}
p
=
ch
p
=
ch
}
}
ch
:=
p
.
NewPersistentInode
(
ctx
,
&
zipFile
{
file
:
f
},
Nod
eAttr
{})
ch
:=
p
.
NewPersistentInode
(
ctx
,
&
zipFile
{
file
:
f
},
Stabl
eAttr
{})
p
.
AddChild
(
base
,
ch
,
true
)
p
.
AddChild
(
base
,
ch
,
true
)
}
}
}
}
...
@@ -235,7 +235,7 @@ func ExampleInode_NewPersistentInode() {
...
@@ -235,7 +235,7 @@ func ExampleInode_NewPersistentInode() {
if
ch
==
nil
{
if
ch
==
nil
{
// Create a directory
// Create a directory
ch
=
p
.
NewPersistentInode
(
ctx
,
&
Inode
{},
ch
=
p
.
NewPersistentInode
(
ctx
,
&
Inode
{},
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
// Add it
// Add it
p
.
AddChild
(
component
,
ch
,
true
)
p
.
AddChild
(
component
,
ch
,
true
)
}
}
...
@@ -246,7 +246,7 @@ func ExampleInode_NewPersistentInode() {
...
@@ -246,7 +246,7 @@ func ExampleInode_NewPersistentInode() {
// Create the file
// Create the file
child
:=
p
.
NewPersistentInode
(
ctx
,
&
MemRegularFile
{
child
:=
p
.
NewPersistentInode
(
ctx
,
&
MemRegularFile
{
Data
:
[]
byte
(
content
),
Data
:
[]
byte
(
content
),
},
Nod
eAttr
{})
},
Stabl
eAttr
{})
// And add it
// And add it
p
.
AddChild
(
base
,
child
,
true
)
p
.
AddChild
(
base
,
child
,
true
)
...
...
zipfs/multizip.go
View file @
0f2f00b8
...
@@ -29,7 +29,7 @@ type MultiZipFs struct {
...
@@ -29,7 +29,7 @@ type MultiZipFs struct {
}
}
func
(
fs
*
MultiZipFs
)
OnAdd
(
ctx
context
.
Context
)
{
func
(
fs
*
MultiZipFs
)
OnAdd
(
ctx
context
.
Context
)
{
n
:=
fs
.
NewPersistentInode
(
ctx
,
&
configRoot
{},
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
n
:=
fs
.
NewPersistentInode
(
ctx
,
&
configRoot
{},
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
fs
.
AddChild
(
"config"
,
n
,
false
)
fs
.
AddChild
(
"config"
,
n
,
false
)
}
}
...
@@ -72,12 +72,12 @@ func (r *configRoot) Symlink(ctx context.Context, target string, base string, ou
...
@@ -72,12 +72,12 @@ func (r *configRoot) Symlink(ctx context.Context, target string, base string, ou
}
}
_
,
parent
:=
r
.
Parent
()
_
,
parent
:=
r
.
Parent
()
ch
:=
r
.
NewPersistentInode
(
ctx
,
root
,
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
ch
:=
r
.
NewPersistentInode
(
ctx
,
root
,
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
parent
.
AddChild
(
base
,
ch
,
false
)
parent
.
AddChild
(
base
,
ch
,
false
)
link
:=
r
.
NewPersistentInode
(
ctx
,
&
nodefs
.
MemSymlink
{
link
:=
r
.
NewPersistentInode
(
ctx
,
&
nodefs
.
MemSymlink
{
Data
:
[]
byte
(
target
),
Data
:
[]
byte
(
target
),
},
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFLNK
})
},
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFLNK
})
r
.
AddChild
(
base
,
link
,
false
)
r
.
AddChild
(
base
,
link
,
false
)
return
link
,
0
return
link
,
0
}
}
zipfs/tarfs.go
View file @
0f2f00b8
...
@@ -78,7 +78,7 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
...
@@ -78,7 +78,7 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
if
ch
==
nil
{
if
ch
==
nil
{
ch
=
p
.
NewPersistentInode
(
ctx
,
ch
=
p
.
NewPersistentInode
(
ctx
,
&
nodefs
.
Inode
{},
&
nodefs
.
Inode
{},
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
})
p
.
AddChild
(
comp
,
ch
,
false
)
p
.
AddChild
(
comp
,
ch
,
false
)
}
}
p
=
ch
p
=
ch
...
@@ -92,7 +92,7 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
...
@@ -92,7 +92,7 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
Data
:
[]
byte
(
hdr
.
Linkname
),
Data
:
[]
byte
(
hdr
.
Linkname
),
}
}
l
.
Attr
=
attr
l
.
Attr
=
attr
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
l
,
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFLNK
}),
false
)
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
l
,
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFLNK
}),
false
)
case
tar
.
TypeLink
:
case
tar
.
TypeLink
:
log
.
Println
(
"don't know how to handle Typelink"
)
log
.
Println
(
"don't know how to handle Typelink"
)
...
@@ -100,25 +100,25 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
...
@@ -100,25 +100,25 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
case
tar
.
TypeChar
:
case
tar
.
TypeChar
:
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
.
Attr
=
attr
rf
.
Attr
=
attr
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFCHR
}),
false
)
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFCHR
}),
false
)
case
tar
.
TypeBlock
:
case
tar
.
TypeBlock
:
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
.
Attr
=
attr
rf
.
Attr
=
attr
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFBLK
}),
false
)
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFBLK
}),
false
)
case
tar
.
TypeDir
:
case
tar
.
TypeDir
:
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
.
Attr
=
attr
rf
.
Attr
=
attr
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFDIR
}),
false
)
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFDIR
}),
false
)
case
tar
.
TypeFifo
:
case
tar
.
TypeFifo
:
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
:=
&
nodefs
.
MemRegularFile
{}
rf
.
Attr
=
attr
rf
.
Attr
=
attr
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Nod
eAttr
{
Mode
:
syscall
.
S_IFIFO
}),
false
)
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
rf
,
nodefs
.
Stabl
eAttr
{
Mode
:
syscall
.
S_IFIFO
}),
false
)
case
tar
.
TypeReg
,
tar
.
TypeRegA
:
case
tar
.
TypeReg
,
tar
.
TypeRegA
:
df
:=
&
nodefs
.
MemRegularFile
{
df
:=
&
nodefs
.
MemRegularFile
{
Data
:
buf
.
Bytes
(),
Data
:
buf
.
Bytes
(),
}
}
df
.
Attr
=
attr
df
.
Attr
=
attr
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
df
,
nodefs
.
Nod
eAttr
{}),
false
)
p
.
AddChild
(
base
,
r
.
NewPersistentInode
(
ctx
,
df
,
nodefs
.
Stabl
eAttr
{}),
false
)
default
:
default
:
log
.
Printf
(
"entry %q: unsupported type '%c'"
,
hdr
.
Name
,
hdr
.
Typeflag
)
log
.
Printf
(
"entry %q: unsupported type '%c'"
,
hdr
.
Name
,
hdr
.
Typeflag
)
}
}
...
...
zipfs/zipfs.go
View file @
0f2f00b8
...
@@ -66,13 +66,13 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
...
@@ -66,13 +66,13 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
ch
:=
p
.
GetChild
(
component
)
ch
:=
p
.
GetChild
(
component
)
if
ch
==
nil
{
if
ch
==
nil
{
ch
=
p
.
NewPersistentInode
(
ctx
,
&
nodefs
.
Inode
{},
ch
=
p
.
NewPersistentInode
(
ctx
,
&
nodefs
.
Inode
{},
nodefs
.
Nod
eAttr
{
Mode
:
fuse
.
S_IFDIR
})
nodefs
.
Stabl
eAttr
{
Mode
:
fuse
.
S_IFDIR
})
p
.
AddChild
(
component
,
ch
,
true
)
p
.
AddChild
(
component
,
ch
,
true
)
}
}
p
=
ch
p
=
ch
}
}
ch
:=
p
.
NewPersistentInode
(
ctx
,
&
zipFile
{
file
:
f
},
nodefs
.
Nod
eAttr
{})
ch
:=
p
.
NewPersistentInode
(
ctx
,
&
zipFile
{
file
:
f
},
nodefs
.
Stabl
eAttr
{})
p
.
AddChild
(
base
,
ch
,
true
)
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