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
2e0db5ff
Commit
2e0db5ff
authored
Apr 26, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set options per filesystem mount.
parent
124708c4
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
40 additions
and
51 deletions
+40
-51
example/autounionfs/main.go
example/autounionfs/main.go
+1
-1
example/loopback/loopback.go
example/loopback/loopback.go
+8
-5
example/unionfs/main.go
example/unionfs/main.go
+1
-1
example/zipfs/main.go
example/zipfs/main.go
+1
-1
fuse/loopback.go
fuse/loopback.go
+0
-8
fuse/loopback_test.go
fuse/loopback_test.go
+3
-3
fuse/pathdebug_test.go
fuse/pathdebug_test.go
+1
-1
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+11
-13
fuse/pathops.go
fuse/pathops.go
+8
-12
fuse/xattr_test.go
fuse/xattr_test.go
+1
-1
unionfs/autounion.go
unionfs/autounion.go
+1
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+1
-1
zipfs/multizip.go
zipfs/multizip.go
+2
-2
zipfs/zipfs_test.go
zipfs/zipfs_test.go
+1
-1
No files found.
example/autounionfs/main.go
View file @
2e0db5ff
...
...
@@ -33,7 +33,7 @@ func main() {
}
gofs
:=
unionfs
.
NewAutoUnionFs
(
flag
.
Arg
(
1
),
options
)
conn
:=
fuse
.
NewFileSystemConnector
(
gofs
)
conn
:=
fuse
.
NewFileSystemConnector
(
gofs
,
nil
)
mountState
:=
fuse
.
NewMountState
(
conn
)
mountState
.
Debug
=
*
debug
fmt
.
Printf
(
"Mounting...
\n
"
)
...
...
example/loopback/loopback.go
View file @
2e0db5ff
...
...
@@ -48,23 +48,26 @@ func main() {
finalFs
=
timing
}
var
opts
fuse
.
FileSystemConnectorOptions
loopbackfs
.
FillOptions
(
&
opts
)
opts
:=
&
fuse
.
MountOptions
{
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
NegativeTimeout
:
1.0
,
AttrTimeout
:
1.0
,
EntryTimeout
:
1.0
,
}
if
*
latencies
{
debugFs
.
Original
=
finalFs
finalFs
=
debugFs
}
conn
:=
fuse
.
NewFileSystemConnector
(
finalFs
)
conn
:=
fuse
.
NewFileSystemConnector
(
finalFs
,
opts
)
var
finalRawFs
fuse
.
RawFileSystem
=
conn
if
*
latencies
{
rawTiming
:=
fuse
.
NewTimingRawFileSystem
(
conn
)
debugFs
.
AddRawTimingFileSystem
(
rawTiming
)
finalRawFs
=
rawTiming
}
conn
.
SetOptions
(
opts
)
state
:=
fuse
.
NewMountState
(
finalRawFs
)
state
.
Debug
=
*
debug
...
...
example/unionfs/main.go
View file @
2e0db5ff
...
...
@@ -30,7 +30,7 @@ func main() {
}
ufs
:=
unionfs
.
NewUnionFs
(
flag
.
Args
()[
1
:
],
ufsOptions
)
conn
:=
fuse
.
NewFileSystemConnector
(
ufs
)
conn
:=
fuse
.
NewFileSystemConnector
(
ufs
,
nil
)
mountState
:=
fuse
.
NewMountState
(
conn
)
mountState
.
Debug
=
*
debug
fmt
.
Printf
(
"Mounting...
\n
"
)
...
...
example/zipfs/main.go
View file @
2e0db5ff
...
...
@@ -35,7 +35,7 @@ func main() {
fs
=
debugFs
}
conn
:=
fuse
.
NewFileSystemConnector
(
fs
)
conn
:=
fuse
.
NewFileSystemConnector
(
fs
,
nil
)
state
:=
fuse
.
NewMountState
(
conn
)
if
*
latencies
{
...
...
fuse/loopback.go
View file @
2e0db5ff
...
...
@@ -162,14 +162,6 @@ func (me *LoopbackFileSystem) RemoveXAttr(name string, attr string) Status {
return
Status
(
Removexattr
(
me
.
GetPath
(
name
),
attr
))
}
func
(
me
*
LoopbackFileSystem
)
FillOptions
(
options
*
FileSystemConnectorOptions
)
{
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
options
.
NegativeTimeout
=
1.0
options
.
AttrTimeout
=
1.0
options
.
EntryTimeout
=
1.0
}
////////////////////////////////////////////////////////////////
type
LoopbackFile
struct
{
...
...
fuse/loopback_test.go
View file @
2e0db5ff
...
...
@@ -61,7 +61,7 @@ func (me *testCase) Setup(t *testing.T) {
pfs
=
NewLockingFileSystem
(
pfs
)
var
rfs
RawFileSystem
me
.
connector
=
NewFileSystemConnector
(
pfs
)
me
.
connector
=
NewFileSystemConnector
(
pfs
,
nil
)
rfs
=
me
.
connector
rfs
=
NewTimingRawFileSystem
(
rfs
)
rfs
=
NewLockingRawFileSystem
(
rfs
)
...
...
@@ -607,7 +607,7 @@ func TestRecursiveMount(t *testing.T) {
f
.
Close
()
pfs2
:=
NewLoopbackFileSystem
(
ts
.
origDir
)
code
:=
ts
.
connector
.
Mount
(
"/hello.txt"
,
pfs2
)
code
:=
ts
.
connector
.
Mount
(
"/hello.txt"
,
pfs2
,
nil
)
if
code
!=
EINVAL
{
t
.
Error
(
"expect EINVAL"
,
code
)
}
...
...
@@ -615,7 +615,7 @@ func TestRecursiveMount(t *testing.T) {
submnt
:=
filepath
.
Join
(
ts
.
mountPoint
,
"mnt"
)
err
=
os
.
Mkdir
(
submnt
,
0777
)
CheckSuccess
(
err
)
code
=
ts
.
connector
.
Mount
(
"/mnt"
,
pfs2
)
code
=
ts
.
connector
.
Mount
(
"/mnt"
,
pfs2
,
nil
)
if
code
!=
OK
{
t
.
Errorf
(
"mkdir"
)
}
...
...
fuse/pathdebug_test.go
View file @
2e0db5ff
...
...
@@ -12,7 +12,7 @@ func TestPathDebug(t *testing.T) {
debugFs
.
Original
=
&
DefaultFileSystem
{}
debugFs
.
Add
(
"test-entry"
,
func
()
[]
byte
{
return
[]
byte
(
"test-content"
)
})
connector
:=
NewFileSystemConnector
(
debugFs
)
connector
:=
NewFileSystemConnector
(
debugFs
,
nil
)
mountPoint
:=
MakeTempDir
()
state
:=
NewMountState
(
connector
)
...
...
fuse/pathfilesystem.go
View file @
2e0db5ff
...
...
@@ -27,6 +27,8 @@ type mountData struct {
// We could have separate treeLocks per mount; something to
// consider if we can measure significant contention for
// multi-mount filesystems.
options
*
MountOptions
}
func
newMount
(
fs
FileSystem
)
*
mountData
{
...
...
@@ -139,28 +141,24 @@ func (me *inode) setParent(newParent *inode) {
}
}
type
Timeou
tOptions
struct
{
type
Moun
tOptions
struct
{
EntryTimeout
float64
AttrTimeout
float64
NegativeTimeout
float64
}
func
MakeTimeoutOptions
()
TimeoutOptions
{
return
TimeoutOptions
{
func
MakeMountOptions
()
*
MountOptions
{
return
&
MountOptions
{
NegativeTimeout
:
0.0
,
AttrTimeout
:
1.0
,
EntryTimeout
:
1.0
,
}
}
type
FileSystemConnectorOptions
struct
{
TimeoutOptions
}
type
FileSystemConnector
struct
{
DefaultRawFileSystem
options
FileSystemConnectorOptions
Debug
bool
////////////////
...
...
@@ -386,14 +384,11 @@ func EmptyFileSystemConnector() (out *FileSystemConnector) {
rootData
:=
out
.
newInode
(
true
,
true
)
rootData
.
Children
=
make
(
map
[
string
]
*
inode
,
initDirSize
)
out
.
options
.
NegativeTimeout
=
0.0
out
.
options
.
AttrTimeout
=
1.0
out
.
options
.
EntryTimeout
=
1.0
out
.
verify
()
return
out
}
func
(
me
*
FileSystemConnector
)
Mount
(
mountPoint
string
,
fs
FileSystem
)
Status
{
func
(
me
*
FileSystemConnector
)
Mount
(
mountPoint
string
,
fs
FileSystem
,
opts
*
MountOptions
)
Status
{
var
node
*
inode
if
mountPoint
!=
"/"
{
...
...
@@ -433,7 +428,10 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem) Status {
}
node
.
mount
=
newMount
(
fs
)
if
opts
==
nil
{
opts
=
MakeMountOptions
()
}
node
.
mount
.
options
=
opts
return
OK
}
...
...
fuse/pathops.go
View file @
2e0db5ff
...
...
@@ -9,9 +9,9 @@ import (
)
func
NewFileSystemConnector
(
fs
FileSystem
)
(
out
*
FileSystemConnector
)
{
func
NewFileSystemConnector
(
fs
FileSystem
,
opts
*
MountOptions
)
(
out
*
FileSystemConnector
)
{
out
=
EmptyFileSystemConnector
()
if
code
:=
out
.
Mount
(
"/"
,
fs
);
code
!=
OK
{
if
code
:=
out
.
Mount
(
"/"
,
fs
,
opts
);
code
!=
OK
{
panic
(
"root mount failed."
)
}
out
.
verify
()
...
...
@@ -19,10 +19,6 @@ func NewFileSystemConnector(fs FileSystem) (out *FileSystemConnector) {
return
out
}
func
(
me
*
FileSystemConnector
)
SetOptions
(
opts
FileSystemConnectorOptions
)
{
me
.
options
=
opts
}
func
(
me
*
FileSystemConnector
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
// TODO - umount all.
}
...
...
@@ -43,14 +39,14 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
// Init.
fullPath
,
mount
:=
parent
.
GetPath
()
if
mount
==
nil
{
return
NegativeEntry
(
m
e
.
options
.
NegativeTimeout
),
OK
,
nil
return
NegativeEntry
(
m
ount
.
options
.
NegativeTimeout
),
OK
,
nil
}
fullPath
=
filepath
.
Join
(
fullPath
,
name
)
attr
,
err
:=
mount
.
fs
.
GetAttr
(
fullPath
)
if
err
==
ENOENT
&&
m
e
.
options
.
NegativeTimeout
>
0.0
{
return
NegativeEntry
(
m
e
.
options
.
NegativeTimeout
),
OK
,
nil
if
err
==
ENOENT
&&
m
ount
.
options
.
NegativeTimeout
>
0.0
{
return
NegativeEntry
(
m
ount
.
options
.
NegativeTimeout
),
OK
,
nil
}
if
err
!=
OK
{
...
...
@@ -64,8 +60,8 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
NodeId
:
data
.
NodeId
,
Generation
:
1
,
// where to get the generation?
}
SplitNs
(
m
e
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
SplitNs
(
m
e
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
SplitNs
(
m
ount
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
SplitNs
(
m
ount
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
out
.
Attr
=
*
attr
out
.
Attr
.
Ino
=
data
.
NodeId
return
out
,
OK
,
data
...
...
@@ -90,7 +86,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
Attr
:
*
attr
,
}
out
.
Attr
.
Ino
=
header
.
NodeId
SplitNs
(
m
e
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
SplitNs
(
m
ount
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
return
out
,
OK
}
...
...
fuse/xattr_test.go
View file @
2e0db5ff
...
...
@@ -93,7 +93,7 @@ func TestXAttrRead(t *testing.T) {
"user.attr2"
:
[]
byte
(
"val2"
)}
xfs
:=
NewXAttrFs
(
nm
,
golden
)
connector
:=
NewFileSystemConnector
(
NewLockingFileSystem
(
xfs
)
)
connector
:=
NewFileSystemConnector
(
xfs
,
nil
)
mountPoint
:=
MakeTempDir
()
state
:=
NewMountState
(
connector
)
...
...
unionfs/autounion.go
View file @
2e0db5ff
...
...
@@ -74,7 +74,7 @@ func (me *AutoUnionFs) addFs(roots []string) {
me
.
lock
.
Unlock
()
if
gofs
!=
nil
{
me
.
connector
.
Mount
(
"/"
+
name
,
gofs
)
me
.
connector
.
Mount
(
"/"
+
name
,
gofs
,
nil
)
}
}
...
...
unionfs/unionfs_test.go
View file @
2e0db5ff
...
...
@@ -40,7 +40,7 @@ func setup(t *testing.T) (workdir string, state *fuse.MountState) {
roots
=
append
(
roots
,
wd
+
"/ro"
)
ufs
:=
NewUnionFs
(
roots
,
testOpts
)
connector
:=
fuse
.
NewFileSystemConnector
(
ufs
)
connector
:=
fuse
.
NewFileSystemConnector
(
ufs
,
nil
)
state
=
fuse
.
NewMountState
(
connector
)
state
.
Mount
(
wd
+
"/mount"
)
...
...
zipfs/multizip.go
View file @
2e0db5ff
...
...
@@ -50,7 +50,7 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f
return
0
,
fuse
.
ENOSYS
}
code
:=
me
.
zfs
.
Connector
.
Mount
(
"/"
+
filepath
.
Base
(
me
.
Basename
),
fs
)
code
:=
me
.
zfs
.
Connector
.
Mount
(
"/"
+
filepath
.
Base
(
me
.
Basename
),
fs
,
nil
)
if
code
!=
fuse
.
OK
{
return
0
,
code
...
...
@@ -85,7 +85,7 @@ func NewMultiZipFs() *MultiZipFs {
m
.
zips
=
make
(
map
[
string
]
*
ZipArchiveFileSystem
)
m
.
pendingZips
=
make
(
map
[
string
]
bool
)
m
.
zipFileNames
=
make
(
map
[
string
]
string
)
m
.
Connector
=
fuse
.
NewFileSystemConnector
(
m
)
m
.
Connector
=
fuse
.
NewFileSystemConnector
(
m
,
nil
)
return
m
}
...
...
zipfs/zipfs_test.go
View file @
2e0db5ff
...
...
@@ -14,7 +14,7 @@ func TestZipFs(t *testing.T) {
t
.
Error
(
"NewZipArchiveFileSystem failed:"
,
err
)
}
connector
:=
fuse
.
NewFileSystemConnector
(
zfs
)
connector
:=
fuse
.
NewFileSystemConnector
(
zfs
,
nil
)
mountPoint
:=
fuse
.
MakeTempDir
()
state
:=
fuse
.
NewMountState
(
connector
)
...
...
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