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
3b9d2f33
Commit
3b9d2f33
authored
Sep 19, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make clientInode support optional, and switch it off by default.
parent
b04236ac
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
48 additions
and
24 deletions
+48
-24
example/autounionfs/main.go
example/autounionfs/main.go
+5
-1
example/loopback/main.go
example/loopback/main.go
+2
-2
fuse/cache_test.go
fuse/cache_test.go
+1
-1
fuse/fuse.go
fuse/fuse.go
+1
-1
fuse/loopback_test.go
fuse/loopback_test.go
+2
-1
fuse/mount_test.go
fuse/mount_test.go
+4
-4
fuse/notify_test.go
fuse/notify_test.go
+1
-1
fuse/pathfs.go
fuse/pathfs.go
+28
-11
unionfs/autounion.go
unionfs/autounion.go
+1
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+3
-1
No files found.
example/autounionfs/main.go
View file @
3b9d2f33
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
func
main
()
{
func
main
()
{
version
:=
flag
.
Bool
(
"version"
,
false
,
"print version number"
)
version
:=
flag
.
Bool
(
"version"
,
false
,
"print version number"
)
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"debug on"
)
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"debug on"
)
hardlinks
:=
flag
.
Bool
(
"hardlinks"
,
false
,
"support hardlinks"
)
delcache_ttl
:=
flag
.
Float64
(
"deletion_cache_ttl"
,
5.0
,
"Deletion cache TTL in seconds."
)
delcache_ttl
:=
flag
.
Float64
(
"deletion_cache_ttl"
,
5.0
,
"Deletion cache TTL in seconds."
)
branchcache_ttl
:=
flag
.
Float64
(
"branchcache_ttl"
,
5.0
,
"Branch cache TTL in seconds."
)
branchcache_ttl
:=
flag
.
Float64
(
"branchcache_ttl"
,
5.0
,
"Branch cache TTL in seconds."
)
deldirname
:=
flag
.
String
(
deldirname
:=
flag
.
String
(
...
@@ -41,9 +42,12 @@ func main() {
...
@@ -41,9 +42,12 @@ func main() {
},
},
UpdateOnMount
:
true
,
UpdateOnMount
:
true
,
}
}
pathOptions
:=
fuse
.
PathNodeFsOptions
{
ClientInodes
:
*
hardlinks
,
}
gofs
:=
unionfs
.
NewAutoUnionFs
(
flag
.
Arg
(
1
),
options
)
gofs
:=
unionfs
.
NewAutoUnionFs
(
flag
.
Arg
(
1
),
options
)
pathfs
:=
fuse
.
NewPathNodeFs
(
gofs
)
pathfs
:=
fuse
.
NewPathNodeFs
(
gofs
,
&
pathOptions
)
state
,
conn
,
err
:=
fuse
.
MountNodeFileSystem
(
flag
.
Arg
(
0
),
pathfs
,
nil
)
state
,
conn
,
err
:=
fuse
.
MountNodeFileSystem
(
flag
.
Arg
(
0
),
pathfs
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
...
...
example/loopback/main.go
View file @
3b9d2f33
...
@@ -37,8 +37,8 @@ func main() {
...
@@ -37,8 +37,8 @@ func main() {
AttrTimeout
:
1.0
,
AttrTimeout
:
1.0
,
EntryTimeout
:
1.0
,
EntryTimeout
:
1.0
,
}
}
pathFs
:=
fuse
.
NewPathNodeFs
(
finalFs
,
nil
)
conn
:=
fuse
.
NewFileSystemConnector
(
fuse
.
NewPathNodeFs
(
finalFs
)
,
opts
)
conn
:=
fuse
.
NewFileSystemConnector
(
pathFs
,
opts
)
state
:=
fuse
.
NewMountState
(
conn
)
state
:=
fuse
.
NewMountState
(
conn
)
state
.
Debug
=
*
debug
state
.
Debug
=
*
debug
...
...
fuse/cache_test.go
View file @
3b9d2f33
...
@@ -35,7 +35,7 @@ func setupCacheTest() (string, *PathNodeFs, func()) {
...
@@ -35,7 +35,7 @@ func setupCacheTest() (string, *PathNodeFs, func()) {
fs
:=
&
cacheFs
{
fs
:=
&
cacheFs
{
LoopbackFileSystem
:
NewLoopbackFileSystem
(
dir
+
"/orig"
),
LoopbackFileSystem
:
NewLoopbackFileSystem
(
dir
+
"/orig"
),
}
}
pfs
:=
NewPathNodeFs
(
fs
)
pfs
:=
NewPathNodeFs
(
fs
,
nil
)
state
,
conn
,
err
:=
MountNodeFileSystem
(
dir
+
"/mnt"
,
pfs
,
nil
)
state
,
conn
,
err
:=
MountNodeFileSystem
(
dir
+
"/mnt"
,
pfs
,
nil
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
state
.
Debug
=
true
state
.
Debug
=
true
...
...
fuse/fuse.go
View file @
3b9d2f33
...
@@ -21,6 +21,6 @@ func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSys
...
@@ -21,6 +21,6 @@ func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSys
}
}
func
MountPathFileSystem
(
mountpoint
string
,
pathFs
FileSystem
,
opts
*
FileSystemOptions
)
(
*
MountState
,
*
FileSystemConnector
,
os
.
Error
)
{
func
MountPathFileSystem
(
mountpoint
string
,
pathFs
FileSystem
,
opts
*
FileSystemOptions
)
(
*
MountState
,
*
FileSystemConnector
,
os
.
Error
)
{
nfs
:=
NewPathNodeFs
(
pathFs
)
nfs
:=
NewPathNodeFs
(
pathFs
,
nil
)
return
MountNodeFileSystem
(
mountpoint
,
nfs
,
opts
)
return
MountNodeFileSystem
(
mountpoint
,
nfs
,
opts
)
}
}
fuse/loopback_test.go
View file @
3b9d2f33
...
@@ -71,7 +71,8 @@ func NewTestCase(t *testing.T) *testCase {
...
@@ -71,7 +71,8 @@ func NewTestCase(t *testing.T) *testCase {
pfs
=
NewLockingFileSystem
(
pfs
)
pfs
=
NewLockingFileSystem
(
pfs
)
var
rfs
RawFileSystem
var
rfs
RawFileSystem
me
.
pathFs
=
NewPathNodeFs
(
pfs
)
me
.
pathFs
=
NewPathNodeFs
(
pfs
,
&
PathNodeFsOptions
{
ClientInodes
:
true
})
me
.
connector
=
NewFileSystemConnector
(
me
.
pathFs
,
me
.
connector
=
NewFileSystemConnector
(
me
.
pathFs
,
&
FileSystemOptions
{
&
FileSystemOptions
{
EntryTimeout
:
testTtl
,
EntryTimeout
:
testTtl
,
...
...
fuse/mount_test.go
View file @
3b9d2f33
...
@@ -35,7 +35,7 @@ func TestMountRename(t *testing.T) {
...
@@ -35,7 +35,7 @@ func TestMountRename(t *testing.T) {
ts
:=
NewTestCase
(
t
)
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
defer
ts
.
Cleanup
()
fs
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
))
fs
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
)
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
fs
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
fs
,
nil
)
if
!
code
.
Ok
()
{
if
!
code
.
Ok
()
{
t
.
Fatal
(
"mount should succeed"
)
t
.
Fatal
(
"mount should succeed"
)
...
@@ -51,7 +51,7 @@ func TestMountReaddir(t *testing.T) {
...
@@ -51,7 +51,7 @@ func TestMountReaddir(t *testing.T) {
ts
:=
NewTestCase
(
t
)
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
defer
ts
.
Cleanup
()
fs
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
))
fs
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
)
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
fs
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
fs
,
nil
)
if
!
code
.
Ok
()
{
if
!
code
.
Ok
()
{
t
.
Fatal
(
"mount should succeed"
)
t
.
Fatal
(
"mount should succeed"
)
...
@@ -72,7 +72,7 @@ func TestRecursiveMount(t *testing.T) {
...
@@ -72,7 +72,7 @@ func TestRecursiveMount(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
ts
.
orig
+
"/hello.txt"
,
[]
byte
(
"blabla"
),
0644
)
err
:=
ioutil
.
WriteFile
(
ts
.
orig
+
"/hello.txt"
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
fs
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
))
fs
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
)
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
fs
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
fs
,
nil
)
if
!
code
.
Ok
()
{
if
!
code
.
Ok
()
{
t
.
Fatal
(
"mount should succeed"
)
t
.
Fatal
(
"mount should succeed"
)
...
@@ -109,7 +109,7 @@ func TestDeletedUnmount(t *testing.T) {
...
@@ -109,7 +109,7 @@ func TestDeletedUnmount(t *testing.T) {
defer
ts
.
Cleanup
()
defer
ts
.
Cleanup
()
submnt
:=
filepath
.
Join
(
ts
.
mnt
,
"mnt"
)
submnt
:=
filepath
.
Join
(
ts
.
mnt
,
"mnt"
)
pfs2
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
))
pfs2
:=
NewPathNodeFs
(
NewLoopbackFileSystem
(
ts
.
orig
)
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
pfs2
,
nil
)
code
:=
ts
.
connector
.
Mount
(
ts
.
rootNode
(),
"mnt"
,
pfs2
,
nil
)
if
!
code
.
Ok
()
{
if
!
code
.
Ok
()
{
t
.
Fatal
(
"Mount error"
,
code
)
t
.
Fatal
(
"Mount error"
,
code
)
...
...
fuse/notify_test.go
View file @
3b9d2f33
...
@@ -53,7 +53,7 @@ func NewNotifyTest() *NotifyTest {
...
@@ -53,7 +53,7 @@ func NewNotifyTest() *NotifyTest {
NegativeTimeout
:
entryTtl
,
NegativeTimeout
:
entryTtl
,
}
}
me
.
pathfs
=
NewPathNodeFs
(
me
.
fs
)
me
.
pathfs
=
NewPathNodeFs
(
me
.
fs
,
nil
)
me
.
state
,
me
.
connector
,
err
=
MountNodeFileSystem
(
me
.
dir
,
me
.
pathfs
,
opts
)
me
.
state
,
me
.
connector
,
err
=
MountNodeFileSystem
(
me
.
dir
,
me
.
pathfs
,
opts
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
me
.
state
.
Debug
=
true
me
.
state
.
Debug
=
true
...
...
fuse/pathfs.go
View file @
3b9d2f33
...
@@ -37,6 +37,14 @@ type PathNodeFs struct {
...
@@ -37,6 +37,14 @@ type PathNodeFs struct {
// This map lists all the parent links known for a given
// This map lists all the parent links known for a given
// nodeId.
// nodeId.
clientInodeMap
map
[
uint64
][]
*
clientInodePath
clientInodeMap
map
[
uint64
][]
*
clientInodePath
options
*
PathNodeFsOptions
}
type
PathNodeFsOptions
struct
{
// If ClientInodes is set, use Inode returned from GetAttr to
// find hard-linked files.
ClientInodes
bool
}
}
func
(
me
*
PathNodeFs
)
Mount
(
path
string
,
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
Status
{
func
(
me
*
PathNodeFs
)
Mount
(
path
string
,
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
Status
{
...
@@ -139,14 +147,19 @@ func (me *PathNodeFs) AllFiles(name string, mask uint32) []WithFlags {
...
@@ -139,14 +147,19 @@ func (me *PathNodeFs) AllFiles(name string, mask uint32) []WithFlags {
return
n
.
Files
(
mask
)
return
n
.
Files
(
mask
)
}
}
func
NewPathNodeFs
(
fs
FileSystem
)
*
PathNodeFs
{
func
NewPathNodeFs
(
fs
FileSystem
,
opts
*
PathNodeFsOptions
)
*
PathNodeFs
{
root
:=
new
(
pathInode
)
root
:=
new
(
pathInode
)
root
.
fs
=
fs
root
.
fs
=
fs
if
opts
==
nil
{
opts
=
&
PathNodeFsOptions
{}
}
me
:=
&
PathNodeFs
{
me
:=
&
PathNodeFs
{
fs
:
fs
,
fs
:
fs
,
root
:
root
,
root
:
root
,
clientInodeMap
:
map
[
uint64
][]
*
clientInodePath
{},
clientInodeMap
:
map
[
uint64
][]
*
clientInodePath
{},
options
:
opts
,
}
}
root
.
pathFs
=
me
root
.
pathFs
=
me
return
me
return
me
...
@@ -224,7 +237,7 @@ func (me *pathInode) addChild(name string, child *pathInode) {
...
@@ -224,7 +237,7 @@ func (me *pathInode) addChild(name string, child *pathInode) {
child
.
Parent
=
me
child
.
Parent
=
me
child
.
Name
=
name
child
.
Name
=
name
if
child
.
clientInode
>
0
{
if
child
.
clientInode
>
0
&&
me
.
pathFs
.
options
.
ClientInodes
{
defer
me
.
LockTree
()()
defer
me
.
LockTree
()()
m
:=
me
.
pathFs
.
clientInodeMap
[
child
.
clientInode
]
m
:=
me
.
pathFs
.
clientInodeMap
[
child
.
clientInode
]
e
:=
&
clientInodePath
{
e
:=
&
clientInodePath
{
...
@@ -242,7 +255,7 @@ func (me *pathInode) rmChild(name string) *pathInode {
...
@@ -242,7 +255,7 @@ func (me *pathInode) rmChild(name string) *pathInode {
}
}
ch
:=
childInode
.
FsNode
()
.
(
*
pathInode
)
ch
:=
childInode
.
FsNode
()
.
(
*
pathInode
)
if
ch
.
clientInode
>
0
{
if
ch
.
clientInode
>
0
&&
me
.
pathFs
.
options
.
ClientInodes
{
defer
me
.
LockTree
()()
defer
me
.
LockTree
()()
m
:=
me
.
pathFs
.
clientInodeMap
[
ch
.
clientInode
]
m
:=
me
.
pathFs
.
clientInodeMap
[
ch
.
clientInode
]
...
@@ -275,7 +288,7 @@ func (me *pathInode) rmChild(name string) *pathInode {
...
@@ -275,7 +288,7 @@ func (me *pathInode) rmChild(name string) *pathInode {
// Handle a change in clientInode number for an other wise unchanged
// Handle a change in clientInode number for an other wise unchanged
// pathInode.
// pathInode.
func
(
me
*
pathInode
)
setClientInode
(
ino
uint64
)
{
func
(
me
*
pathInode
)
setClientInode
(
ino
uint64
)
{
if
ino
==
me
.
clientInode
{
if
ino
==
me
.
clientInode
||
!
me
.
pathFs
.
options
.
ClientInodes
{
return
return
}
}
defer
me
.
LockTree
()()
defer
me
.
LockTree
()()
...
@@ -293,7 +306,7 @@ func (me *pathInode) setClientInode(ino uint64) {
...
@@ -293,7 +306,7 @@ func (me *pathInode) setClientInode(ino uint64) {
}
}
func
(
me
*
pathInode
)
OnForget
()
{
func
(
me
*
pathInode
)
OnForget
()
{
if
me
.
clientInode
==
0
{
if
me
.
clientInode
==
0
||
!
me
.
pathFs
.
options
.
ClientInodes
{
return
return
}
}
defer
me
.
LockTree
()()
defer
me
.
LockTree
()()
...
@@ -465,25 +478,29 @@ func (me *pathInode) Lookup(name string, context *Context) (fi *os.FileInfo, nod
...
@@ -465,25 +478,29 @@ func (me *pathInode) Lookup(name string, context *Context) (fi *os.FileInfo, nod
fullPath
:=
filepath
.
Join
(
me
.
GetPath
(),
name
)
fullPath
:=
filepath
.
Join
(
me
.
GetPath
(),
name
)
fi
,
code
=
me
.
fs
.
GetAttr
(
fullPath
,
context
)
fi
,
code
=
me
.
fs
.
GetAttr
(
fullPath
,
context
)
if
code
.
Ok
()
{
if
code
.
Ok
()
{
node
=
me
.
findChild
(
fi
.
Ino
,
fi
.
IsDirectory
(),
name
)
node
=
me
.
findChild
(
fi
,
name
,
fullPath
)
}
}
return
return
}
}
func
(
me
*
pathInode
)
findChild
(
ino
uint64
,
isDir
bool
,
name
string
)
(
out
*
pathInode
)
{
func
(
me
*
pathInode
)
findChild
(
fi
*
os
.
FileInfo
,
name
string
,
fullPath
string
)
(
out
*
pathInode
)
{
if
i
no
>
0
{
if
fi
.
I
no
>
0
{
unlock
:=
me
.
RLockTree
()
unlock
:=
me
.
RLockTree
()
v
:=
me
.
pathFs
.
clientInodeMap
[
i
no
]
v
:=
me
.
pathFs
.
clientInodeMap
[
fi
.
I
no
]
if
len
(
v
)
>
0
{
if
len
(
v
)
>
0
{
out
=
v
[
0
]
.
node
out
=
v
[
0
]
.
node
if
fi
.
Nlink
==
1
{
log
.
Println
(
"Found linked inode, but Nlink == 1"
,
fullPath
)
}
}
}
unlock
()
unlock
()
}
}
if
out
==
nil
{
if
out
==
nil
{
out
=
me
.
createChild
(
isDir
)
out
=
me
.
createChild
(
fi
.
IsDirectory
()
)
out
.
clientInode
=
i
no
out
.
clientInode
=
fi
.
I
no
me
.
addChild
(
name
,
out
)
me
.
addChild
(
name
,
out
)
}
}
...
...
unionfs/autounion.go
View file @
3b9d2f33
...
@@ -110,7 +110,7 @@ func (me *AutoUnionFs) createFs(name string, roots []string) fuse.Status {
...
@@ -110,7 +110,7 @@ func (me *AutoUnionFs) createFs(name string, roots []string) fuse.Status {
}
}
log
.
Printf
(
"Adding workspace %v for roots %v"
,
name
,
ufs
.
Name
())
log
.
Printf
(
"Adding workspace %v for roots %v"
,
name
,
ufs
.
Name
())
nfs
:=
fuse
.
NewPathNodeFs
(
ufs
)
nfs
:=
fuse
.
NewPathNodeFs
(
ufs
,
nil
)
code
:=
me
.
nodeFs
.
Mount
(
name
,
nfs
,
&
me
.
options
.
FileSystemOptions
)
code
:=
me
.
nodeFs
.
Mount
(
name
,
nfs
,
&
me
.
options
.
FileSystemOptions
)
if
code
.
Ok
()
{
if
code
.
Ok
()
{
me
.
knownFileSystems
[
name
]
=
knownFs
{
me
.
knownFileSystems
[
name
]
=
knownFs
{
...
...
unionfs/unionfs_test.go
View file @
3b9d2f33
...
@@ -54,7 +54,9 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
...
@@ -54,7 +54,9 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
NegativeTimeout
:
.5
*
entryTtl
,
NegativeTimeout
:
.5
*
entryTtl
,
}
}
state
,
conn
,
err
:=
fuse
.
MountPathFileSystem
(
wd
+
"/mount"
,
ufs
,
opts
)
pathfs
:=
fuse
.
NewPathNodeFs
(
ufs
,
&
fuse
.
PathNodeFsOptions
{
ClientInodes
:
true
})
state
,
conn
,
err
:=
fuse
.
MountNodeFileSystem
(
wd
+
"/mount"
,
pathfs
,
opts
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
conn
.
Debug
=
true
conn
.
Debug
=
true
state
.
Debug
=
true
state
.
Debug
=
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