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
5c47ca23
Commit
5c47ca23
authored
Apr 21, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename PathFileSystem to FileSystem.
parent
9c3ac0b4
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
215 additions
and
215 deletions
+215
-215
example/autounionfs/main.go
example/autounionfs/main.go
+1
-1
example/loopback/loopback.go
example/loopback/loopback.go
+6
-6
example/unionfs/main.go
example/unionfs/main.go
+1
-1
example/zipfs/main.go
example/zipfs/main.go
+1
-1
fuse/default.go
fuse/default.go
+24
-24
fuse/default_test.go
fuse/default_test.go
+4
-4
fuse/direntry.go
fuse/direntry.go
+1
-1
fuse/lockingfs.go
fuse/lockingfs.go
+28
-28
fuse/loopback.go
fuse/loopback.go
+2
-2
fuse/loopback_test.go
fuse/loopback_test.go
+5
-5
fuse/pathdebug.go
fuse/pathdebug.go
+5
-5
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+57
-57
fuse/timingfs.go
fuse/timingfs.go
+32
-32
fuse/types.go
fuse/types.go
+4
-4
fuse/wrappedfs.go
fuse/wrappedfs.go
+25
-25
fuse/xattr_test.go
fuse/xattr_test.go
+2
-2
unionfs/autounion.go
unionfs/autounion.go
+3
-3
unionfs/cachingfs.go
unionfs/cachingfs.go
+2
-2
unionfs/unionfs.go
unionfs/unionfs.go
+5
-5
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+1
-1
zipfs/multizip.go
zipfs/multizip.go
+4
-4
zipfs/zipfs.go
zipfs/zipfs.go
+1
-1
zipfs/zipfs_test.go
zipfs/zipfs_test.go
+1
-1
No files found.
example/autounionfs/main.go
View file @
5c47ca23
...
...
@@ -33,7 +33,7 @@ func main() {
}
gofs
:=
unionfs
.
NewAutoUnionFs
(
flag
.
Arg
(
1
),
options
)
conn
:=
fuse
.
New
Path
FileSystemConnector
(
gofs
)
conn
:=
fuse
.
NewFileSystemConnector
(
gofs
)
mountState
:=
fuse
.
NewMountState
(
conn
)
mountState
.
Debug
=
*
debug
fmt
.
Printf
(
"Mounting...
\n
"
)
...
...
example/loopback/loopback.go
View file @
5c47ca23
...
...
@@ -16,7 +16,7 @@ var _ = runtime.GOMAXPROCS
var
_
=
log
.
Print
type
PathPrintingFs
struct
{
fuse
.
Wrapping
Path
FileSystem
fuse
.
WrappingFileSystem
}
func
(
me
*
PathPrintingFs
)
GetAttr
(
name
string
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
...
...
@@ -35,22 +35,22 @@ func main() {
os
.
Exit
(
2
)
}
var
fs
fuse
.
Path
FileSystem
var
fs
fuse
.
FileSystem
orig
:=
flag
.
Arg
(
1
)
loopbackfs
:=
fuse
.
NewLoopbackFileSystem
(
orig
)
fs
=
loopbackfs
debugFs
:=
new
(
fuse
.
Path
FileSystemDebug
)
debugFs
:=
new
(
fuse
.
FileSystemDebug
)
debugFs
.
Original
=
fs
fs
=
debugFs
timing
:=
fuse
.
NewTiming
Path
FileSystem
(
fs
)
timing
:=
fuse
.
NewTimingFileSystem
(
fs
)
fs
=
timing
var
opts
fuse
.
Path
FileSystemConnectorOptions
var
opts
fuse
.
FileSystemConnectorOptions
loopbackfs
.
FillOptions
(
&
opts
)
conn
:=
fuse
.
New
Path
FileSystemConnector
(
fs
)
conn
:=
fuse
.
NewFileSystemConnector
(
fs
)
debugFs
.
Connector
=
conn
rawTiming
:=
fuse
.
NewTimingRawFileSystem
(
conn
)
...
...
example/unionfs/main.go
View file @
5c47ca23
...
...
@@ -30,7 +30,7 @@ func main() {
}
ufs
:=
unionfs
.
NewUnionFs
(
flag
.
Args
()[
1
:
],
ufsOptions
)
conn
:=
fuse
.
New
Path
FileSystemConnector
(
ufs
)
conn
:=
fuse
.
NewFileSystemConnector
(
ufs
)
mountState
:=
fuse
.
NewMountState
(
conn
)
mountState
.
Debug
=
*
debug
fmt
.
Printf
(
"Mounting...
\n
"
)
...
...
example/zipfs/main.go
View file @
5c47ca23
...
...
@@ -22,7 +22,7 @@ func main() {
}
fs
:=
zipfs
.
NewZipArchiveFileSystem
(
flag
.
Arg
(
1
))
conn
:=
fuse
.
New
Path
FileSystemConnector
(
fs
)
conn
:=
fuse
.
NewFileSystemConnector
(
fs
)
state
:=
fuse
.
NewMountState
(
conn
)
mountPoint
:=
flag
.
Arg
(
0
)
...
...
fuse/default.go
View file @
5c47ca23
...
...
@@ -159,95 +159,95 @@ func (me *DefaultFile) Fsync(*FsyncIn) (code Status) {
}
////////////////////////////////////////////////////////////////
// Default
Path
FileSystem
// DefaultFileSystem
func
(
me
*
Default
Path
FileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
DefaultFileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
DefaultFileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
DefaultFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
DefaultFileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
DefaultFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
DefaultFileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
return
""
,
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
DefaultFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
DefaultFileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
DefaultFileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
Default
PathFileSystem
)
Mount
(
conn
*
Path
FileSystemConnector
)
Status
{
func
(
me
*
Default
FileSystem
)
Mount
(
conn
*
FileSystemConnector
)
Status
{
return
OK
}
func
(
me
*
Default
Path
FileSystem
)
Unmount
()
{
func
(
me
*
DefaultFileSystem
)
Unmount
()
{
}
func
(
me
*
Default
Path
FileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
Default
Path
FileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
return
ENOSYS
}
fuse/default_test.go
View file @
5c47ca23
...
...
@@ -18,10 +18,10 @@ func TestRawFs(t *testing.T) {
}
func
TestPathFs
(
t
*
testing
.
T
)
{
var
iface
Path
FileSystem
iface
=
new
(
Default
Path
FileSystem
)
iface
=
new
(
Wrapping
Path
FileSystem
)
iface
=
new
(
Timing
Path
FileSystem
)
var
iface
FileSystem
iface
=
new
(
DefaultFileSystem
)
iface
=
new
(
WrappingFileSystem
)
iface
=
new
(
TimingFileSystem
)
_
=
iface
}
...
...
fuse/direntry.go
View file @
5c47ca23
...
...
@@ -9,7 +9,7 @@ import (
)
var
_
=
fmt
.
Print
// For
Path
FileSystemConnector. The connector determines inodes.
// For FileSystemConnector. The connector determines inodes.
type
DirEntry
struct
{
Mode
uint32
Name
string
...
...
fuse/lockingfs.go
View file @
5c47ca23
...
...
@@ -4,153 +4,153 @@ import (
"sync"
)
// This is a wrapper that makes a
Path
FileSystem threadsafe by
// This is a wrapper that makes a FileSystem threadsafe by
// trivially locking all operations. For improved performance, you
// should probably invent do your own locking inside the file system.
type
Locking
Path
FileSystem
struct
{
type
LockingFileSystem
struct
{
// Should be public so people reusing can access the wrapped
// FS.
Wrapping
Path
FileSystem
WrappingFileSystem
lock
sync
.
Mutex
}
func
NewLocking
PathFileSystem
(
pfs
PathFileSystem
)
*
LockingPath
FileSystem
{
l
:=
new
(
Locking
Path
FileSystem
)
func
NewLocking
FileSystem
(
pfs
FileSystem
)
*
Locking
FileSystem
{
l
:=
new
(
LockingFileSystem
)
l
.
Original
=
pfs
return
l
}
func
(
me
*
Locking
Path
FileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
LockingFileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
GetAttr
(
name
)
}
func
(
me
*
Locking
Path
FileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
LockingFileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Readlink
(
name
)
}
func
(
me
*
Locking
Path
FileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
LockingFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
}
func
(
me
*
Locking
Path
FileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
LockingFileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mkdir
(
name
,
mode
)
}
func
(
me
*
Locking
Path
FileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Unlink
(
name
)
}
func
(
me
*
Locking
Path
FileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Rmdir
(
name
)
}
func
(
me
*
Locking
Path
FileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Symlink
(
value
,
linkName
)
}
func
(
me
*
Locking
Path
FileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Rename
(
oldName
,
newName
)
}
func
(
me
*
Locking
Path
FileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Link
(
oldName
,
newName
)
}
func
(
me
*
Locking
Path
FileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Chmod
(
name
,
mode
)
}
func
(
me
*
Locking
Path
FileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
}
func
(
me
*
Locking
Path
FileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Truncate
(
name
,
offset
)
}
func
(
me
*
Locking
Path
FileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
return
me
.
Original
.
Open
(
name
,
flags
)
}
func
(
me
*
Locking
Path
FileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
LockingFileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
OpenDir
(
name
)
}
func
(
me
*
Locking
PathFileSystem
)
Mount
(
conn
*
Path
FileSystemConnector
)
Status
{
func
(
me
*
Locking
FileSystem
)
Mount
(
conn
*
FileSystemConnector
)
Status
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mount
(
conn
)
}
func
(
me
*
Locking
Path
FileSystem
)
Unmount
()
{
func
(
me
*
LockingFileSystem
)
Unmount
()
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
me
.
Original
.
Unmount
()
}
func
(
me
*
Locking
Path
FileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Access
(
name
,
mode
)
}
func
(
me
*
Locking
Path
FileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
}
func
(
me
*
Locking
Path
FileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
LockingFileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
}
func
(
me
*
Locking
Path
FileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
LockingFileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
}
func
(
me
*
Locking
Path
FileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
LockingFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
}
func
(
me
*
Locking
Path
FileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
LockingFileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
ListXAttr
(
name
)
}
func
(
me
*
Locking
Path
FileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
LockingFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
...
...
fuse/loopback.go
View file @
5c47ca23
...
...
@@ -18,7 +18,7 @@ var _ = log.Println
type
LoopbackFileSystem
struct
{
root
string
Default
Path
FileSystem
DefaultFileSystem
}
func
NewLoopbackFileSystem
(
root
string
)
(
out
*
LoopbackFileSystem
)
{
...
...
@@ -162,7 +162,7 @@ func (me *LoopbackFileSystem) RemoveXAttr(name string, attr string) Status {
return
Status
(
Removexattr
(
me
.
GetPath
(
name
),
attr
))
}
func
(
me
*
LoopbackFileSystem
)
FillOptions
(
options
*
Path
FileSystemConnectorOptions
)
{
func
(
me
*
LoopbackFileSystem
)
FillOptions
(
options
*
FileSystemConnectorOptions
)
{
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
options
.
NegativeTimeout
=
1.0
...
...
fuse/loopback_test.go
View file @
5c47ca23
...
...
@@ -34,7 +34,7 @@ type testCase struct {
origSubfile
string
tester
*
testing
.
T
state
*
MountState
connector
*
Path
FileSystemConnector
connector
*
FileSystemConnector
}
// Create and mount filesystem.
...
...
@@ -55,13 +55,13 @@ func (me *testCase) Setup(t *testing.T) {
me
.
origSubdir
=
filepath
.
Join
(
me
.
origDir
,
subdir
)
me
.
origSubfile
=
filepath
.
Join
(
me
.
origSubdir
,
"subfile"
)
var
pfs
Path
FileSystem
var
pfs
FileSystem
pfs
=
NewLoopbackFileSystem
(
me
.
origDir
)
pfs
=
NewTiming
Path
FileSystem
(
pfs
)
pfs
=
NewLocking
Path
FileSystem
(
pfs
)
pfs
=
NewTimingFileSystem
(
pfs
)
pfs
=
NewLockingFileSystem
(
pfs
)
var
rfs
RawFileSystem
me
.
connector
=
New
Path
FileSystemConnector
(
pfs
)
me
.
connector
=
NewFileSystemConnector
(
pfs
)
rfs
=
me
.
connector
rfs
=
NewTimingRawFileSystem
(
rfs
)
rfs
=
NewLockingRawFileSystem
(
rfs
)
...
...
fuse/pathdebug.go
View file @
5c47ca23
...
...
@@ -5,21 +5,21 @@ import (
var
_
=
fmt
.
Println
type
Path
FileSystemDebug
struct
{
type
FileSystemDebug
struct
{
// TODO - use a generic callback system instead.
Connector
*
Path
FileSystemConnector
Connector
*
FileSystemConnector
Wrapping
Path
FileSystem
WrappingFileSystem
}
func
(
me
*
Path
FileSystemDebug
)
Open
(
path
string
,
flags
uint32
)
(
fuseFile
File
,
status
Status
)
{
func
(
me
*
FileSystemDebug
)
Open
(
path
string
,
flags
uint32
)
(
fuseFile
File
,
status
Status
)
{
if
path
==
".debug"
&&
me
.
Connector
!=
nil
{
return
NewReadOnlyFile
([]
byte
(
me
.
Connector
.
DebugString
())),
OK
}
return
me
.
Original
.
Open
(
path
,
flags
)
}
func
(
me
*
Path
FileSystemDebug
)
GetAttr
(
path
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
FileSystemDebug
)
GetAttr
(
path
string
)
(
*
Attr
,
Status
)
{
if
path
==
".debug"
&&
me
.
Connector
!=
nil
{
return
&
Attr
{
Mode
:
S_IFREG
,
...
...
fuse/pathfilesystem.go
View file @
5c47ca23
...
...
@@ -11,7 +11,7 @@ import (
type
mountData
struct
{
// If non-nil the file system mounted here.
fs
Path
FileSystem
fs
FileSystem
// Protects the variables below.
mutex
sync
.
RWMutex
...
...
@@ -20,7 +20,7 @@ type mountData struct {
unmountPending
bool
}
func
newMount
(
fs
Path
FileSystem
)
*
mountData
{
func
newMount
(
fs
FileSystem
)
*
mountData
{
return
&
mountData
{
fs
:
fs
}
}
...
...
@@ -141,14 +141,14 @@ func MakeTimeoutOptions() TimeoutOptions {
}
}
type
Path
FileSystemConnectorOptions
struct
{
type
FileSystemConnectorOptions
struct
{
TimeoutOptions
}
type
Path
FileSystemConnector
struct
{
type
FileSystemConnector
struct
{
DefaultRawFileSystem
options
Path
FileSystemConnectorOptions
options
FileSystemConnectorOptions
Debug
bool
////////////////
...
...
@@ -166,7 +166,7 @@ type PathFileSystemConnector struct {
nextFreeHandle
uint64
}
func
(
me
*
Path
FileSystemConnector
)
DebugString
()
string
{
func
(
me
*
FileSystemConnector
)
DebugString
()
string
{
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
...
...
@@ -179,7 +179,7 @@ func (me *PathFileSystemConnector) DebugString() string {
len
(
me
.
openFiles
),
len
(
me
.
inodeMap
))
}
func
(
me
*
Path
FileSystemConnector
)
unregisterFile
(
node
*
inode
,
handle
uint64
)
interface
{}
{
func
(
me
*
FileSystemConnector
)
unregisterFile
(
node
*
inode
,
handle
uint64
)
interface
{}
{
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
f
,
ok
:=
me
.
openFiles
[
handle
]
...
...
@@ -191,7 +191,7 @@ func (me *PathFileSystemConnector) unregisterFile(node *inode, handle uint64) in
return
f
}
func
(
me
*
Path
FileSystemConnector
)
registerFile
(
node
*
inode
,
f
interface
{})
uint64
{
func
(
me
*
FileSystemConnector
)
registerFile
(
node
*
inode
,
f
interface
{})
uint64
{
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
...
...
@@ -207,19 +207,19 @@ func (me *PathFileSystemConnector) registerFile(node *inode, f interface{}) uint
return
h
}
func
(
me
*
Path
FileSystemConnector
)
getDir
(
h
uint64
)
RawDir
{
func
(
me
*
FileSystemConnector
)
getDir
(
h
uint64
)
RawDir
{
me
.
fileLock
.
RLock
()
defer
me
.
fileLock
.
RUnlock
()
return
me
.
openFiles
[
h
]
.
(
RawDir
)
}
func
(
me
*
Path
FileSystemConnector
)
getFile
(
h
uint64
)
File
{
func
(
me
*
FileSystemConnector
)
getFile
(
h
uint64
)
File
{
me
.
fileLock
.
RLock
()
defer
me
.
fileLock
.
RUnlock
()
return
me
.
openFiles
[
h
]
.
(
File
)
}
func
(
me
*
Path
FileSystemConnector
)
verify
()
{
func
(
me
*
FileSystemConnector
)
verify
()
{
if
!
paranoia
{
return
}
...
...
@@ -249,7 +249,7 @@ func (me *PathFileSystemConnector) verify() {
}
}
func
(
me
*
Path
FileSystemConnector
)
newInode
()
*
inode
{
func
(
me
*
FileSystemConnector
)
newInode
()
*
inode
{
data
:=
new
(
inode
)
data
.
NodeId
=
me
.
nextFreeInode
me
.
nextFreeInode
++
...
...
@@ -259,7 +259,7 @@ func (me *PathFileSystemConnector) newInode() *inode {
return
data
}
func
(
me
*
Path
FileSystemConnector
)
lookupUpdate
(
parent
*
inode
,
name
string
,
isDir
bool
)
*
inode
{
func
(
me
*
FileSystemConnector
)
lookupUpdate
(
parent
*
inode
,
name
string
,
isDir
bool
)
*
inode
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
...
...
@@ -278,7 +278,7 @@ func (me *PathFileSystemConnector) lookupUpdate(parent *inode, name string, isDi
return
data
}
func
(
me
*
Path
FileSystemConnector
)
getInodeData
(
nodeid
uint64
)
*
inode
{
func
(
me
*
FileSystemConnector
)
getInodeData
(
nodeid
uint64
)
*
inode
{
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
...
...
@@ -289,7 +289,7 @@ func (me *PathFileSystemConnector) getInodeData(nodeid uint64) *inode {
return
val
}
func
(
me
*
Path
FileSystemConnector
)
forgetUpdate
(
nodeId
uint64
,
forgetCount
int
)
{
func
(
me
*
FileSystemConnector
)
forgetUpdate
(
nodeId
uint64
,
forgetCount
int
)
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
...
...
@@ -301,7 +301,7 @@ func (me *PathFileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int)
}
}
func
(
me
*
Path
FileSystemConnector
)
considerDropInode
(
n
*
inode
)
{
func
(
me
*
FileSystemConnector
)
considerDropInode
(
n
*
inode
)
{
if
n
.
mount
!=
nil
{
n
.
mount
.
mutex
.
RLock
()
defer
n
.
mount
.
mutex
.
RUnlock
()
...
...
@@ -315,7 +315,7 @@ func (me *PathFileSystemConnector) considerDropInode(n *inode) {
}
}
func
(
me
*
Path
FileSystemConnector
)
renameUpdate
(
oldParent
*
inode
,
oldName
string
,
newParent
*
inode
,
newName
string
)
{
func
(
me
*
FileSystemConnector
)
renameUpdate
(
oldParent
*
inode
,
oldName
string
,
newParent
*
inode
,
newName
string
)
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
...
...
@@ -334,7 +334,7 @@ func (me *PathFileSystemConnector) renameUpdate(oldParent *inode, oldName string
node
.
setParent
(
newParent
)
}
func
(
me
*
Path
FileSystemConnector
)
unlinkUpdate
(
parent
*
inode
,
name
string
)
{
func
(
me
*
FileSystemConnector
)
unlinkUpdate
(
parent
*
inode
,
name
string
)
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
...
...
@@ -344,7 +344,7 @@ func (me *PathFileSystemConnector) unlinkUpdate(parent *inode, name string) {
}
// Walk the file system starting from the root.
func
(
me
*
Path
FileSystemConnector
)
findInode
(
fullPath
string
)
*
inode
{
func
(
me
*
FileSystemConnector
)
findInode
(
fullPath
string
)
*
inode
{
fullPath
=
strings
.
TrimLeft
(
filepath
.
Clean
(
fullPath
),
"/"
)
comps
:=
strings
.
Split
(
fullPath
,
"/"
,
-
1
)
...
...
@@ -369,8 +369,8 @@ func (me *PathFileSystemConnector) findInode(fullPath string) *inode {
// Below routines should not access inodePathMap(ByInode) directly,
// and there need no locking.
func
Empty
PathFileSystemConnector
()
(
out
*
Path
FileSystemConnector
)
{
out
=
new
(
Path
FileSystemConnector
)
func
Empty
FileSystemConnector
()
(
out
*
FileSystemConnector
)
{
out
=
new
(
FileSystemConnector
)
out
.
inodeMap
=
make
(
map
[
uint64
]
*
inode
)
out
.
openFiles
=
make
(
map
[
uint64
]
interface
{})
...
...
@@ -387,8 +387,8 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) {
return
out
;
}
func
New
PathFileSystemConnector
(
fs
PathFileSystem
)
(
out
*
Path
FileSystemConnector
)
{
out
=
Empty
Path
FileSystemConnector
()
func
New
FileSystemConnector
(
fs
FileSystem
)
(
out
*
FileSystemConnector
)
{
out
=
EmptyFileSystemConnector
()
if
code
:=
out
.
Mount
(
"/"
,
fs
);
code
!=
OK
{
panic
(
"root mount failed."
)
}
...
...
@@ -397,11 +397,11 @@ func NewPathFileSystemConnector(fs PathFileSystem) (out *PathFileSystemConnector
return
out
}
func
(
me
*
PathFileSystemConnector
)
SetOptions
(
opts
Path
FileSystemConnectorOptions
)
{
func
(
me
*
FileSystemConnector
)
SetOptions
(
opts
FileSystemConnectorOptions
)
{
me
.
options
=
opts
}
func
(
me
*
PathFileSystemConnector
)
Mount
(
mountPoint
string
,
fs
Path
FileSystem
)
Status
{
func
(
me
*
FileSystemConnector
)
Mount
(
mountPoint
string
,
fs
FileSystem
)
Status
{
var
node
*
inode
if
mountPoint
!=
"/"
{
...
...
@@ -448,7 +448,7 @@ func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFileSystem) S
return
OK
}
func
(
me
*
Path
FileSystemConnector
)
Unmount
(
path
string
)
Status
{
func
(
me
*
FileSystemConnector
)
Unmount
(
path
string
)
Status
{
node
:=
me
.
findInode
(
path
)
if
node
==
nil
{
panic
(
path
)
...
...
@@ -489,32 +489,32 @@ func (me *PathFileSystemConnector) Unmount(path string) Status {
return
OK
}
func
(
me
*
Path
FileSystemConnector
)
GetPath
(
nodeid
uint64
)
(
path
string
,
mount
*
mountData
,
node
*
inode
)
{
func
(
me
*
FileSystemConnector
)
GetPath
(
nodeid
uint64
)
(
path
string
,
mount
*
mountData
,
node
*
inode
)
{
n
:=
me
.
getInodeData
(
nodeid
)
p
,
m
:=
n
.
GetPath
()
return
p
,
m
,
n
}
func
(
me
*
Path
FileSystemConnector
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
func
(
me
*
FileSystemConnector
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
// TODO ?
return
new
(
InitOut
),
OK
}
func
(
me
*
Path
FileSystemConnector
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
func
(
me
*
FileSystemConnector
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
// TODO - umount all.
}
func
(
me
*
Path
FileSystemConnector
)
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
status
Status
)
{
func
(
me
*
FileSystemConnector
)
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
status
Status
)
{
parent
:=
me
.
getInodeData
(
header
.
NodeId
)
return
me
.
internalLookup
(
parent
,
name
,
1
)
}
func
(
me
*
Path
FileSystemConnector
)
internalLookup
(
parent
*
inode
,
name
string
,
lookupCount
int
)
(
out
*
EntryOut
,
status
Status
)
{
func
(
me
*
FileSystemConnector
)
internalLookup
(
parent
*
inode
,
name
string
,
lookupCount
int
)
(
out
*
EntryOut
,
status
Status
)
{
out
,
status
,
_
=
me
.
internalLookupWithNode
(
parent
,
name
,
lookupCount
)
return
out
,
status
}
func
(
me
*
Path
FileSystemConnector
)
internalLookupWithNode
(
parent
*
inode
,
name
string
,
lookupCount
int
)
(
out
*
EntryOut
,
status
Status
,
node
*
inode
)
{
func
(
me
*
FileSystemConnector
)
internalLookupWithNode
(
parent
*
inode
,
name
string
,
lookupCount
int
)
(
out
*
EntryOut
,
status
Status
,
node
*
inode
)
{
// TODO - fuse.c has special case code for name == "." and
// "..", those lookups happen if FUSE_EXPORT_SUPPORT is set in
// Init.
...
...
@@ -549,11 +549,11 @@ func (me *PathFileSystemConnector) internalLookupWithNode(parent *inode, name st
return
out
,
OK
,
data
}
func
(
me
*
Path
FileSystemConnector
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
func
(
me
*
FileSystemConnector
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
me
.
forgetUpdate
(
h
.
NodeId
,
int
(
input
.
Nlookup
))
}
func
(
me
*
Path
FileSystemConnector
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
// TODO - do something intelligent with input.Fh.
fullPath
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
...
...
@@ -572,7 +572,7 @@ func (me *PathFileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (
return
out
,
OK
}
func
(
me
*
Path
FileSystemConnector
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
FileSystemConnector
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
fullPath
,
mount
,
node
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
0
,
0
,
ENOENT
...
...
@@ -591,7 +591,7 @@ func (me *PathFileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (fla
return
0
,
h
,
OK
}
func
(
me
*
Path
FileSystemConnector
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
func
(
me
*
FileSystemConnector
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
d
:=
me
.
getDir
(
input
.
Fh
)
de
,
code
:=
d
.
ReadDir
(
input
)
if
code
!=
OK
{
...
...
@@ -600,7 +600,7 @@ func (me *PathFileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*Di
return
de
,
OK
}
func
(
me
*
Path
FileSystemConnector
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
FileSystemConnector
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
fullPath
,
mount
,
node
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
0
,
0
,
ENOENT
...
...
@@ -616,7 +616,7 @@ func (me *PathFileSystemConnector) Open(header *InHeader, input *OpenIn) (flags
return
0
,
h
,
OK
}
func
(
me
*
Path
FileSystemConnector
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
var
err
Status
=
OK
// TODO - support Fh. (FSetAttr/FGetAttr/FTruncate.)
...
...
@@ -652,7 +652,7 @@ func (me *PathFileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (
return
me
.
GetAttr
(
header
,
new
(
GetAttrIn
))
}
func
(
me
*
Path
FileSystemConnector
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
fullPath
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -661,7 +661,7 @@ func (me *PathFileSystemConnector) Readlink(header *InHeader) (out []byte, code
return
bytes
.
NewBufferString
(
val
)
.
Bytes
(),
err
}
func
(
me
*
Path
FileSystemConnector
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
fullPath
,
mount
,
node
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -674,7 +674,7 @@ func (me *PathFileSystemConnector) Mknod(header *InHeader, input *MknodIn, name
return
me
.
internalLookup
(
node
,
name
,
1
)
}
func
(
me
*
Path
FileSystemConnector
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
fullPath
,
mount
,
parent
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -686,7 +686,7 @@ func (me *PathFileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name
return
out
,
code
}
func
(
me
*
Path
FileSystemConnector
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
fullPath
,
mount
,
parent
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
ENOENT
...
...
@@ -699,7 +699,7 @@ func (me *PathFileSystemConnector) Unlink(header *InHeader, name string) (code S
return
code
}
func
(
me
*
Path
FileSystemConnector
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
fullPath
,
mount
,
parent
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
ENOENT
...
...
@@ -711,7 +711,7 @@ func (me *PathFileSystemConnector) Rmdir(header *InHeader, name string) (code St
return
code
}
func
(
me
*
Path
FileSystemConnector
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
fullPath
,
mount
,
parent
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -725,7 +725,7 @@ func (me *PathFileSystemConnector) Symlink(header *InHeader, pointedTo string, l
return
out
,
code
}
func
(
me
*
Path
FileSystemConnector
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
oldPath
,
oldMount
,
oldParent
:=
me
.
GetPath
(
header
.
NodeId
)
newPath
,
mount
,
newParent
:=
me
.
GetPath
(
input
.
Newdir
)
if
mount
==
nil
||
oldMount
==
nil
{
...
...
@@ -751,7 +751,7 @@ func (me *PathFileSystemConnector) Rename(header *InHeader, input *RenameIn, old
return
code
}
func
(
me
*
Path
FileSystemConnector
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
filename
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
filename
string
)
(
out
*
EntryOut
,
code
Status
)
{
orig
,
mount
,
_
:=
me
.
GetPath
(
input
.
Oldnodeid
)
newName
,
newMount
,
newParent
:=
me
.
GetPath
(
header
.
NodeId
)
...
...
@@ -771,7 +771,7 @@ func (me *PathFileSystemConnector) Link(header *InHeader, input *LinkIn, filenam
return
me
.
internalLookup
(
newParent
,
filename
,
1
)
}
func
(
me
*
Path
FileSystemConnector
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
p
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
ENOENT
...
...
@@ -779,7 +779,7 @@ func (me *PathFileSystemConnector) Access(header *InHeader, input *AccessIn) (co
return
mount
.
fs
.
Access
(
p
,
input
.
Mask
)
}
func
(
me
*
Path
FileSystemConnector
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
h
uint64
,
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
h
uint64
,
out
*
EntryOut
,
code
Status
)
{
directory
,
mount
,
parent
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
0
,
0
,
nil
,
ENOENT
...
...
@@ -795,26 +795,26 @@ func (me *PathFileSystemConnector) Create(header *InHeader, input *CreateIn, nam
return
0
,
me
.
registerFile
(
inode
,
f
),
out
,
code
}
func
(
me
*
Path
FileSystemConnector
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
FileSystemConnector
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
node
:=
me
.
getInodeData
(
header
.
NodeId
)
f
:=
me
.
unregisterFile
(
node
,
input
.
Fh
)
.
(
File
)
f
.
Release
()
me
.
considerDropInode
(
node
)
}
func
(
me
*
Path
FileSystemConnector
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
FileSystemConnector
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
node
:=
me
.
getInodeData
(
header
.
NodeId
)
d
:=
me
.
unregisterFile
(
node
,
input
.
Fh
)
.
(
RawDir
)
d
.
Release
()
me
.
considerDropInode
(
node
)
}
func
(
me
*
Path
FileSystemConnector
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
FileSystemConnector
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
// What the heck is FsyncDir supposed to do?
return
OK
}
func
(
me
*
Path
FileSystemConnector
)
GetXAttr
(
header
*
InHeader
,
attribute
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
GetXAttr
(
header
*
InHeader
,
attribute
string
)
(
data
[]
byte
,
code
Status
)
{
path
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -824,7 +824,7 @@ func (me *PathFileSystemConnector) GetXAttr(header *InHeader, attribute string)
return
data
,
code
}
func
(
me
*
Path
FileSystemConnector
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
func
(
me
*
FileSystemConnector
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
path
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
ENOENT
...
...
@@ -833,7 +833,7 @@ func (me *PathFileSystemConnector) RemoveXAttr(header *InHeader, attr string) St
return
mount
.
fs
.
RemoveXAttr
(
path
,
attr
)
}
func
(
me
*
Path
FileSystemConnector
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
func
(
me
*
FileSystemConnector
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
path
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
ENOENT
...
...
@@ -842,7 +842,7 @@ func (me *PathFileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn,
return
mount
.
fs
.
SetXAttr
(
path
,
attr
,
data
,
int
(
input
.
Flags
))
}
func
(
me
*
Path
FileSystemConnector
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
path
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -862,12 +862,12 @@ func (me *PathFileSystemConnector) ListXAttr(header *InHeader) (data []byte, cod
return
b
.
Bytes
(),
code
}
func
(
me
*
Path
FileSystemConnector
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
f
:=
me
.
getFile
(
input
.
Fh
)
.
(
File
)
return
f
.
Write
(
input
,
data
)
}
func
(
me
*
Path
FileSystemConnector
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
FileSystemConnector
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
f
:=
me
.
getFile
(
input
.
Fh
)
return
f
.
Read
(
input
,
bp
)
}
fuse/timingfs.go
View file @
5c47ca23
...
...
@@ -11,9 +11,9 @@ import (
var
_
=
log
.
Print
var
_
=
fmt
.
Print
// Timing
PathFileSystem is a wrapper to collect timings for a Path
FileSystem
type
Timing
Path
FileSystem
struct
{
Wrapping
Path
FileSystem
// Timing
FileSystem is a wrapper to collect timings for a
FileSystem
type
TimingFileSystem
struct
{
WrappingFileSystem
statisticsLock
sync
.
Mutex
latencies
map
[
string
]
int64
...
...
@@ -21,8 +21,8 @@ type TimingPathFileSystem struct {
pathCounts
map
[
string
]
map
[
string
]
int64
}
func
NewTiming
PathFileSystem
(
fs
PathFileSystem
)
*
TimingPath
FileSystem
{
t
:=
new
(
Timing
Path
FileSystem
)
func
NewTiming
FileSystem
(
fs
FileSystem
)
*
Timing
FileSystem
{
t
:=
new
(
TimingFileSystem
)
t
.
Original
=
fs
t
.
latencies
=
make
(
map
[
string
]
int64
)
t
.
counts
=
make
(
map
[
string
]
int64
)
...
...
@@ -30,7 +30,7 @@ func NewTimingPathFileSystem(fs PathFileSystem) *TimingPathFileSystem {
return
t
}
func
(
me
*
Timing
Path
FileSystem
)
startTimer
(
name
string
,
arg
string
)
(
closure
func
())
{
func
(
me
*
TimingFileSystem
)
startTimer
(
name
string
,
arg
string
)
(
closure
func
())
{
start
:=
time
.
Nanoseconds
()
return
func
()
{
...
...
@@ -50,7 +50,7 @@ func (me *TimingPathFileSystem) startTimer(name string, arg string) (closure fun
}
}
func
(
me
*
Timing
Path
FileSystem
)
OperationCounts
()
map
[
string
]
int64
{
func
(
me
*
TimingFileSystem
)
OperationCounts
()
map
[
string
]
int64
{
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
...
...
@@ -61,7 +61,7 @@ func (me *TimingPathFileSystem) OperationCounts() map[string]int64 {
return
r
}
func
(
me
*
Timing
Path
FileSystem
)
Latencies
()
map
[
string
]
float64
{
func
(
me
*
TimingFileSystem
)
Latencies
()
map
[
string
]
float64
{
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
...
...
@@ -72,7 +72,7 @@ func (me *TimingPathFileSystem) Latencies() map[string]float64 {
return
r
}
func
(
me
*
Timing
Path
FileSystem
)
HotPaths
(
operation
string
)
(
paths
[]
string
,
uniquePaths
int
)
{
func
(
me
*
TimingFileSystem
)
HotPaths
(
operation
string
)
(
paths
[]
string
,
uniquePaths
int
)
{
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
...
...
@@ -86,117 +86,117 @@ func (me *TimingPathFileSystem) HotPaths(operation string) (paths []string, uniq
return
results
,
len
(
counts
)
}
func
(
me
*
Timing
Path
FileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
TimingFileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
defer
me
.
startTimer
(
"GetAttr"
,
name
)()
return
me
.
Original
.
GetAttr
(
name
)
}
func
(
me
*
Timing
Path
FileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
TimingFileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
defer
me
.
startTimer
(
"GetXAttr"
,
name
)()
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
}
func
(
me
*
Timing
Path
FileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
TimingFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
defer
me
.
startTimer
(
"SetXAttr"
,
name
)()
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
}
func
(
me
*
Timing
Path
FileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
TimingFileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
defer
me
.
startTimer
(
"ListXAttr"
,
name
)()
return
me
.
Original
.
ListXAttr
(
name
)
}
func
(
me
*
Timing
Path
FileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
TimingFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
defer
me
.
startTimer
(
"RemoveXAttr"
,
name
)()
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
}
func
(
me
*
Timing
Path
FileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
TimingFileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
defer
me
.
startTimer
(
"Readlink"
,
name
)()
return
me
.
Original
.
Readlink
(
name
)
}
func
(
me
*
Timing
Path
FileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
TimingFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
defer
me
.
startTimer
(
"Mknod"
,
name
)()
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
}
func
(
me
*
Timing
Path
FileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
TimingFileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
defer
me
.
startTimer
(
"Mkdir"
,
name
)()
return
me
.
Original
.
Mkdir
(
name
,
mode
)
}
func
(
me
*
Timing
Path
FileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Unlink"
,
name
)()
return
me
.
Original
.
Unlink
(
name
)
}
func
(
me
*
Timing
Path
FileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Rmdir"
,
name
)()
return
me
.
Original
.
Rmdir
(
name
)
}
func
(
me
*
Timing
Path
FileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Symlink"
,
linkName
)()
return
me
.
Original
.
Symlink
(
value
,
linkName
)
}
func
(
me
*
Timing
Path
FileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Rename"
,
oldName
)()
return
me
.
Original
.
Rename
(
oldName
,
newName
)
}
func
(
me
*
Timing
Path
FileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Link"
,
newName
)()
return
me
.
Original
.
Link
(
oldName
,
newName
)
}
func
(
me
*
Timing
Path
FileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Chmod"
,
name
)()
return
me
.
Original
.
Chmod
(
name
,
mode
)
}
func
(
me
*
Timing
Path
FileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Chown"
,
name
)()
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
}
func
(
me
*
Timing
Path
FileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Truncate"
,
name
)()
return
me
.
Original
.
Truncate
(
name
,
offset
)
}
func
(
me
*
Timing
Path
FileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
defer
me
.
startTimer
(
"Open"
,
name
)()
return
me
.
Original
.
Open
(
name
,
flags
)
}
func
(
me
*
Timing
Path
FileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
TimingFileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
defer
me
.
startTimer
(
"OpenDir"
,
name
)()
return
me
.
Original
.
OpenDir
(
name
)
}
func
(
me
*
Timing
PathFileSystem
)
Mount
(
conn
*
Path
FileSystemConnector
)
Status
{
func
(
me
*
Timing
FileSystem
)
Mount
(
conn
*
FileSystemConnector
)
Status
{
defer
me
.
startTimer
(
"Mount"
,
""
)()
return
me
.
Original
.
Mount
(
conn
)
}
func
(
me
*
Timing
Path
FileSystem
)
Unmount
()
{
func
(
me
*
TimingFileSystem
)
Unmount
()
{
defer
me
.
startTimer
(
"Unmount"
,
""
)()
me
.
Original
.
Unmount
()
}
func
(
me
*
Timing
Path
FileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Access"
,
name
)()
return
me
.
Original
.
Access
(
name
,
mode
)
}
func
(
me
*
Timing
Path
FileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
defer
me
.
startTimer
(
"Create"
,
name
)()
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
}
func
(
me
*
Timing
Path
FileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
TimingFileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Utimens"
,
name
)()
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
}
fuse/types.go
View file @
5c47ca23
...
...
@@ -498,7 +498,7 @@ type NotifyInvalEntryOut struct {
//
// Typically, each call happens in its own goroutine, so any global
// data should be made thread-safe. Unless you really know what you
// are doing, you should not implement this, but
Path
FileSystem below;
// are doing, you should not implement this, but FileSystem below;
// the details of getting interactions with open files, renames, and
// threading right etc. are somewhat tricky and not very interesting.
type
RawFileSystem
interface
{
...
...
@@ -561,7 +561,7 @@ type RawDir interface {
Release
()
}
type
Path
FileSystem
interface
{
type
FileSystem
interface
{
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
Readlink
(
name
string
)
(
string
,
Status
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
...
...
@@ -586,7 +586,7 @@ type PathFileSystem interface {
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
code
Status
)
// TODO - what is a good interface?
Mount
(
connector
*
Path
FileSystemConnector
)
Status
Mount
(
connector
*
FileSystemConnector
)
Status
Unmount
()
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
...
...
@@ -599,6 +599,6 @@ type PathFileSystem interface {
// Include this struct in your implementation to inherit default nop
// implementations.
type
Default
Path
FileSystem
struct
{}
type
DefaultFileSystem
struct
{}
type
DefaultFile
struct
{}
type
DefaultRawFileSystem
struct
{}
fuse/wrappedfs.go
View file @
5c47ca23
package
fuse
type
Wrapping
Path
FileSystem
struct
{
type
WrappingFileSystem
struct
{
// Should be public so people reusing can access the wrapped
// FS.
Original
Path
FileSystem
Original
FileSystem
}
func
(
me
*
Wrapping
Path
FileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
WrappingFileSystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
return
me
.
Original
.
GetAttr
(
name
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
WrappingFileSystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
return
me
.
Original
.
Readlink
(
name
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
WrappingFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
WrappingFileSystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
return
me
.
Original
.
Mkdir
(
name
,
mode
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Unlink
(
name
string
)
(
code
Status
)
{
return
me
.
Original
.
Unlink
(
name
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
return
me
.
Original
.
Rmdir
(
name
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
return
me
.
Original
.
Symlink
(
value
,
linkName
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
me
.
Original
.
Rename
(
oldName
,
newName
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
me
.
Original
.
Link
(
oldName
,
newName
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
me
.
Original
.
Chmod
(
name
,
mode
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
return
me
.
Original
.
Truncate
(
name
,
offset
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
file
File
,
code
Status
)
{
return
me
.
Original
.
Open
(
name
,
flags
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
WrappingFileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
return
me
.
Original
.
OpenDir
(
name
)
}
func
(
me
*
Wrapping
PathFileSystem
)
Mount
(
conn
*
Path
FileSystemConnector
)
Status
{
func
(
me
*
Wrapping
FileSystem
)
Mount
(
conn
*
FileSystemConnector
)
Status
{
return
me
.
Original
.
Mount
(
conn
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Unmount
()
{
func
(
me
*
WrappingFileSystem
)
Unmount
()
{
me
.
Original
.
Unmount
()
}
func
(
me
*
Wrapping
Path
FileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
me
.
Original
.
Access
(
name
,
mode
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
File
,
code
Status
)
{
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
WrappingFileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
WrappingFileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
WrappingFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
WrappingFileSystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
return
me
.
Original
.
ListXAttr
(
name
)
}
func
(
me
*
Wrapping
Path
FileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
WrappingFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
}
...
...
fuse/xattr_test.go
View file @
5c47ca23
...
...
@@ -15,7 +15,7 @@ type XAttrTestFs struct {
filename
string
attrs
map
[
string
][]
byte
Default
Path
FileSystem
DefaultFileSystem
}
func
NewXAttrFs
(
nm
string
,
m
map
[
string
][]
byte
)
*
XAttrTestFs
{
...
...
@@ -93,7 +93,7 @@ func TestXAttrRead(t *testing.T) {
"user.attr2"
:
[]
byte
(
"val2"
)}
xfs
:=
NewXAttrFs
(
nm
,
golden
)
connector
:=
New
PathFileSystemConnector
(
NewLockingPath
FileSystem
(
xfs
))
connector
:=
New
FileSystemConnector
(
NewLocking
FileSystem
(
xfs
))
mountPoint
:=
MakeTempDir
()
state
:=
NewMountState
(
connector
)
...
...
unionfs/autounion.go
View file @
5c47ca23
...
...
@@ -18,13 +18,13 @@ import (
//
// A union for A/B/C will placed under directory A-B-C.
type
AutoUnionFs
struct
{
fuse
.
Default
Path
FileSystem
fuse
.
DefaultFileSystem
lock
sync
.
RWMutex
knownFileSystems
map
[
string
]
*
UnionFs
root
string
connector
*
fuse
.
Path
FileSystemConnector
connector
*
fuse
.
FileSystemConnector
options
*
AutoUnionFsOptions
}
...
...
@@ -41,7 +41,7 @@ func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs {
return
a
}
func
(
me
*
AutoUnionFs
)
Mount
(
connector
*
fuse
.
Path
FileSystemConnector
)
fuse
.
Status
{
func
(
me
*
AutoUnionFs
)
Mount
(
connector
*
fuse
.
FileSystemConnector
)
fuse
.
Status
{
me
.
connector
=
connector
time
.
AfterFunc
(
0.1e9
,
func
()
{
me
.
updateKnownFses
()
})
return
fuse
.
OK
...
...
unionfs/cachingfs.go
View file @
5c47ca23
...
...
@@ -22,7 +22,7 @@ type linkResponse struct {
// Caches readdir and getattr()
type
CachingFileSystem
struct
{
fuse
.
Wrapping
Path
FileSystem
fuse
.
WrappingFileSystem
attributesLock
sync
.
RWMutex
attributes
map
[
string
]
attrResponse
...
...
@@ -34,7 +34,7 @@ type CachingFileSystem struct {
links
map
[
string
]
linkResponse
}
func
NewCachingFileSystem
(
pfs
fuse
.
Path
FileSystem
)
*
CachingFileSystem
{
func
NewCachingFileSystem
(
pfs
fuse
.
FileSystem
)
*
CachingFileSystem
{
c
:=
new
(
CachingFileSystem
)
c
.
Original
=
pfs
c
.
attributes
=
make
(
map
[
string
]
attrResponse
)
...
...
unionfs/unionfs.go
View file @
5c47ca23
...
...
@@ -58,12 +58,12 @@ func filePathHash(path string) string {
*/
type
UnionFs
struct
{
fuse
.
Default
Path
FileSystem
fuse
.
DefaultFileSystem
branches
[]
*
fuse
.
LoopbackFileSystem
// The same, but as interfaces.
fileSystems
[]
fuse
.
Path
FileSystem
fileSystems
[]
fuse
.
FileSystem
// A file-existence cache.
deletionCache
*
DirCache
...
...
@@ -89,7 +89,7 @@ func NewUnionFs(roots []string, options UnionFsOptions) *UnionFs {
g
.
branches
=
append
(
g
.
branches
,
pt
)
// We could use some sort of caching file system here.
g
.
fileSystems
=
append
(
g
.
fileSystems
,
fuse
.
Path
FileSystem
(
pt
))
g
.
fileSystems
=
append
(
g
.
fileSystems
,
fuse
.
FileSystem
(
pt
))
}
deletionDir
:=
g
.
deletionDir
()
...
...
@@ -232,7 +232,7 @@ src *fuse.LoopbackFileSystem) os.Error {
}
////////////////////////////////////////////////////////////////
// Below: implement interface for a
Path
FileSystem.
// Below: implement interface for a FileSystem.
func
(
me
*
UnionFs
)
Mkdir
(
path
string
,
mode
uint32
)
(
code
fuse
.
Status
)
{
code
=
me
.
fileSystems
[
0
]
.
Mkdir
(
path
,
mode
)
...
...
@@ -344,7 +344,7 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
for
i
,
l
:=
range
me
.
fileSystems
{
if
i
>=
dirBranch
{
wg
.
Add
(
1
)
go
func
(
j
int
,
pfs
fuse
.
Path
FileSystem
)
{
go
func
(
j
int
,
pfs
fuse
.
FileSystem
)
{
ch
,
s
:=
pfs
.
OpenDir
(
directory
)
statuses
[
j
]
=
s
for
s
==
fuse
.
OK
{
...
...
unionfs/unionfs_test.go
View file @
5c47ca23
...
...
@@ -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
.
New
Path
FileSystemConnector
(
ufs
)
connector
:=
fuse
.
NewFileSystemConnector
(
ufs
)
state
=
fuse
.
NewMountState
(
connector
)
state
.
Mount
(
wd
+
"/mount"
)
...
...
zipfs/multizip.go
View file @
5c47ca23
...
...
@@ -68,16 +68,16 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f
////////////////////////////////////////////////////////////////
// MultiZipFs is a path filesystem that mounts zipfiles. It needs a
// reference to the
Path
FileSystemConnector to be able to execute
// reference to the FileSystemConnector to be able to execute
// mounts.
type
MultiZipFs
struct
{
Connector
*
fuse
.
Path
FileSystemConnector
Connector
*
fuse
.
FileSystemConnector
lock
sync
.
RWMutex
zips
map
[
string
]
*
ZipArchiveFileSystem
pendingZips
map
[
string
]
bool
zipFileNames
map
[
string
]
string
fuse
.
Default
Path
FileSystem
fuse
.
DefaultFileSystem
}
func
NewMultiZipFs
()
*
MultiZipFs
{
...
...
@@ -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
.
New
Path
FileSystemConnector
(
m
)
m
.
Connector
=
fuse
.
NewFileSystemConnector
(
m
)
return
m
}
...
...
zipfs/zipfs.go
View file @
5c47ca23
...
...
@@ -75,7 +75,7 @@ type ZipArchiveFileSystem struct {
tree
*
ZipDirTree
ZipFileName
string
fuse
.
Default
Path
FileSystem
fuse
.
DefaultFileSystem
}
func
zipFilesToTree
(
files
[]
*
zip
.
File
)
*
ZipDirTree
{
...
...
zipfs/zipfs_test.go
View file @
5c47ca23
...
...
@@ -11,7 +11,7 @@ func TestZipFs(t *testing.T) {
CheckSuccess
(
err
)
zfs
:=
NewZipArchiveFileSystem
(
wd
+
"/test.zip"
)
connector
:=
fuse
.
New
Path
FileSystemConnector
(
zfs
)
connector
:=
fuse
.
NewFileSystemConnector
(
zfs
)
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