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
e8c28231
Commit
e8c28231
authored
Apr 21, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Uniformize writing of FileSystem (was: Filesystem as well).
parent
8caf9e25
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
264 additions
and
264 deletions
+264
-264
fuse/default.go
fuse/default.go
+24
-24
fuse/default_test.go
fuse/default_test.go
+7
-7
fuse/lockingfs.go
fuse/lockingfs.go
+65
-65
fuse/loopback.go
fuse/loopback.go
+1
-1
fuse/loopback_test.go
fuse/loopback_test.go
+5
-5
fuse/pathdebug.go
fuse/pathdebug.go
+4
-4
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+4
-4
fuse/timingfs.go
fuse/timingfs.go
+32
-32
fuse/timingrawfs.go
fuse/timingrawfs.go
+40
-40
fuse/types.go
fuse/types.go
+2
-2
fuse/wrappedfs.go
fuse/wrappedfs.go
+59
-59
fuse/xattr_test.go
fuse/xattr_test.go
+2
-2
unionfs/autounion.go
unionfs/autounion.go
+10
-10
unionfs/cachingfs.go
unionfs/cachingfs.go
+2
-2
unionfs/unionfs.go
unionfs/unionfs.go
+5
-5
zipfs/multizip.go
zipfs/multizip.go
+1
-1
zipfs/zipfs.go
zipfs/zipfs.go
+1
-1
No files found.
fuse/default.go
View file @
e8c28231
...
@@ -159,95 +159,95 @@ func (me *DefaultFuseFile) Fsync(*FsyncIn) (code Status) {
...
@@ -159,95 +159,95 @@ func (me *DefaultFuseFile) Fsync(*FsyncIn) (code Status) {
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// DefaultPathFile
s
ystem
// DefaultPathFile
S
ystem
func
(
me
*
DefaultPathFile
s
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
DefaultPathFile
S
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
DefaultPathFile
S
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
return
""
,
ENOSYS
return
""
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
DefaultPathFile
S
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
DefaultPathFile
S
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
func
(
me
*
DefaultPathFile
S
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
return
OK
return
OK
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Unmount
()
{
func
(
me
*
DefaultPathFile
S
ystem
)
Unmount
()
{
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
}
}
func
(
me
*
DefaultPathFile
s
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
DefaultPathFile
S
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
fuse/default_test.go
View file @
e8c28231
package
fuse
package
fuse
// Make sure library supplied File
s
ystems support the
// Make sure library supplied File
S
ystems support the
// required interface.
// required interface.
import
(
import
(
...
@@ -11,17 +11,17 @@ func TestRawFs(t *testing.T) {
...
@@ -11,17 +11,17 @@ func TestRawFs(t *testing.T) {
var
iface
RawFileSystem
var
iface
RawFileSystem
iface
=
new
(
DefaultRawFuseFileSystem
)
iface
=
new
(
DefaultRawFuseFileSystem
)
iface
=
new
(
WrappingRawFile
s
ystem
)
iface
=
new
(
WrappingRawFile
S
ystem
)
iface
=
new
(
TimingRawFile
s
ystem
)
iface
=
new
(
TimingRawFile
S
ystem
)
_
=
iface
_
=
iface
}
}
func
TestPathFs
(
t
*
testing
.
T
)
{
func
TestPathFs
(
t
*
testing
.
T
)
{
var
iface
PathFile
s
ystem
var
iface
PathFile
S
ystem
iface
=
new
(
DefaultPathFile
s
ystem
)
iface
=
new
(
DefaultPathFile
S
ystem
)
iface
=
new
(
WrappingPathFile
s
ystem
)
iface
=
new
(
WrappingPathFile
S
ystem
)
iface
=
new
(
TimingPathFile
s
ystem
)
iface
=
new
(
TimingPathFile
S
ystem
)
_
=
iface
_
=
iface
}
}
...
...
fuse/lockingfs.go
View file @
e8c28231
...
@@ -4,153 +4,153 @@ import (
...
@@ -4,153 +4,153 @@ import (
"sync"
"sync"
)
)
// This is a wrapper that makes a PathFile
s
ystem threadsafe by
// This is a wrapper that makes a PathFile
S
ystem threadsafe by
// trivially locking all operations. For improved performance, you
// trivially locking all operations. For improved performance, you
// should probably invent do your own locking inside the file system.
// should probably invent do your own locking inside the file system.
type
LockingPathFile
s
ystem
struct
{
type
LockingPathFile
S
ystem
struct
{
// Should be public so people reusing can access the wrapped
// Should be public so people reusing can access the wrapped
// FS.
// FS.
WrappingPathFile
s
ystem
WrappingPathFile
S
ystem
lock
sync
.
Mutex
lock
sync
.
Mutex
}
}
func
NewLockingPathFile
system
(
pfs
PathFilesystem
)
*
LockingPathFiles
ystem
{
func
NewLockingPathFile
System
(
pfs
PathFileSystem
)
*
LockingPathFileS
ystem
{
l
:=
new
(
LockingPathFile
s
ystem
)
l
:=
new
(
LockingPathFile
S
ystem
)
l
.
Original
=
pfs
l
.
Original
=
pfs
return
l
return
l
}
}
func
(
me
*
LockingPathFile
s
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
GetAttr
(
name
)
return
me
.
Original
.
GetAttr
(
name
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Readlink
(
name
)
return
me
.
Original
.
Readlink
(
name
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
LockingPathFile
S
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
LockingPathFile
S
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mkdir
(
name
,
mode
)
return
me
.
Original
.
Mkdir
(
name
,
mode
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Unlink
(
name
)
return
me
.
Original
.
Unlink
(
name
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Rmdir
(
name
)
return
me
.
Original
.
Rmdir
(
name
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Symlink
(
value
,
linkName
)
return
me
.
Original
.
Symlink
(
value
,
linkName
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Rename
(
oldName
,
newName
)
return
me
.
Original
.
Rename
(
oldName
,
newName
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Link
(
oldName
,
newName
)
return
me
.
Original
.
Link
(
oldName
,
newName
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Chmod
(
name
,
mode
)
return
me
.
Original
.
Chmod
(
name
,
mode
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Truncate
(
name
,
offset
)
return
me
.
Original
.
Truncate
(
name
,
offset
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
return
me
.
Original
.
Open
(
name
,
flags
)
return
me
.
Original
.
Open
(
name
,
flags
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
OpenDir
(
name
)
return
me
.
Original
.
OpenDir
(
name
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
func
(
me
*
LockingPathFile
S
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mount
(
conn
)
return
me
.
Original
.
Mount
(
conn
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Unmount
()
{
func
(
me
*
LockingPathFile
S
ystem
)
Unmount
()
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
me
.
Original
.
Unmount
()
me
.
Original
.
Unmount
()
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Access
(
name
,
mode
)
return
me
.
Original
.
Access
(
name
,
mode
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
LockingPathFile
S
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
LockingPathFile
S
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
ListXAttr
(
name
)
return
me
.
Original
.
ListXAttr
(
name
)
}
}
func
(
me
*
LockingPathFile
s
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
LockingPathFile
S
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
...
@@ -159,210 +159,210 @@ func (me *LockingPathFilesystem) RemoveXAttr(name string, attr string) Status {
...
@@ -159,210 +159,210 @@ func (me *LockingPathFilesystem) RemoveXAttr(name string, attr string) Status {
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Locking raw FS.
// Locking raw FS.
type
LockingRawFile
s
ystem
struct
{
type
LockingRawFile
S
ystem
struct
{
WrappingRawFile
s
ystem
WrappingRawFile
S
ystem
lock
sync
.
Mutex
lock
sync
.
Mutex
}
}
func
NewLockingRawFile
system
(
rfs
RawFileSystem
)
*
LockingRawFiles
ystem
{
func
NewLockingRawFile
System
(
rfs
RawFileSystem
)
*
LockingRawFileS
ystem
{
l
:=
&
LockingRawFile
s
ystem
{}
l
:=
&
LockingRawFile
S
ystem
{}
l
.
Original
=
rfs
l
.
Original
=
rfs
return
l
return
l
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Init
(
h
,
input
)
return
me
.
Original
.
Init
(
h
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
me
.
Original
.
Destroy
(
h
,
input
)
me
.
Original
.
Destroy
(
h
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Lookup
(
h
,
name
)
return
me
.
Original
.
Lookup
(
h
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
me
.
Original
.
Forget
(
h
,
input
)
me
.
Original
.
Forget
(
h
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
GetAttr
(
header
,
input
)
return
me
.
Original
.
GetAttr
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Open
(
header
,
input
)
return
me
.
Original
.
Open
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
SetAttr
(
header
,
input
)
return
me
.
Original
.
SetAttr
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Readlink
(
header
)
return
me
.
Original
.
Readlink
(
header
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mknod
(
header
,
input
,
name
)
return
me
.
Original
.
Mknod
(
header
,
input
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Mkdir
(
header
,
input
,
name
)
return
me
.
Original
.
Mkdir
(
header
,
input
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Unlink
(
header
,
name
)
return
me
.
Original
.
Unlink
(
header
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Rmdir
(
header
,
name
)
return
me
.
Original
.
Rmdir
(
header
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Symlink
(
header
,
pointedTo
,
linkName
)
return
me
.
Original
.
Symlink
(
header
,
pointedTo
,
linkName
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Rename
(
header
,
input
,
oldName
,
newName
)
return
me
.
Original
.
Rename
(
header
,
input
,
oldName
,
newName
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Link
(
header
,
input
,
name
)
return
me
.
Original
.
Link
(
header
,
input
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
func
(
me
*
LockingRawFile
S
ystem
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
SetXAttr
(
header
,
input
,
attr
,
data
)
return
me
.
Original
.
SetXAttr
(
header
,
input
,
attr
,
data
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
GetXAttr
(
header
,
attr
)
return
me
.
Original
.
GetXAttr
(
header
,
attr
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
ListXAttr
(
header
)
return
me
.
Original
.
ListXAttr
(
header
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
func
(
me
*
LockingRawFile
S
ystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
RemoveXAttr
(
header
,
attr
)
return
me
.
Original
.
RemoveXAttr
(
header
,
attr
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Access
(
header
,
input
)
return
me
.
Original
.
Access
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Create
(
header
,
input
,
name
)
return
me
.
Original
.
Create
(
header
,
input
,
name
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Bmap
(
header
*
InHeader
,
input
*
BmapIn
)
(
out
*
BmapOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Bmap
(
header
*
InHeader
,
input
*
BmapIn
)
(
out
*
BmapOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Bmap
(
header
,
input
)
return
me
.
Original
.
Bmap
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
out
*
IoctlOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
out
*
IoctlOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Ioctl
(
header
,
input
)
return
me
.
Original
.
Ioctl
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Poll
(
header
*
InHeader
,
input
*
PollIn
)
(
out
*
PollOut
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Poll
(
header
*
InHeader
,
input
*
PollIn
)
(
out
*
PollOut
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Poll
(
header
,
input
)
return
me
.
Original
.
Poll
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
h
uint64
,
status
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
h
uint64
,
status
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
OpenDir
(
header
,
input
)
return
me
.
Original
.
OpenDir
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
me
.
Original
.
Release
(
header
,
input
)
me
.
Original
.
Release
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
ReleaseDir
(
header
*
InHeader
,
h
*
ReleaseIn
)
{
func
(
me
*
LockingRawFile
S
ystem
)
ReleaseDir
(
header
*
InHeader
,
h
*
ReleaseIn
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
me
.
Original
.
ReleaseDir
(
header
,
h
)
me
.
Original
.
ReleaseDir
(
header
,
h
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Read
(
input
,
bp
)
return
me
.
Original
.
Read
(
input
,
bp
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Write
(
input
,
data
)
return
me
.
Original
.
Write
(
input
,
data
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Flush
(
input
*
FlushIn
)
Status
{
func
(
me
*
LockingRawFile
S
ystem
)
Flush
(
input
*
FlushIn
)
Status
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Flush
(
input
)
return
me
.
Original
.
Flush
(
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
Fsync
(
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
Fsync
(
input
*
FsyncIn
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
Fsync
(
input
)
return
me
.
Original
.
Fsync
(
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
ReadDir
(
header
,
input
)
return
me
.
Original
.
ReadDir
(
header
,
input
)
}
}
func
(
me
*
LockingRawFile
s
ystem
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
LockingRawFile
S
ystem
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
defer
me
.
lock
.
Unlock
()
return
me
.
Original
.
FsyncDir
(
header
,
input
)
return
me
.
Original
.
FsyncDir
(
header
,
input
)
...
...
fuse/loopback.go
View file @
e8c28231
...
@@ -18,7 +18,7 @@ var _ = log.Println
...
@@ -18,7 +18,7 @@ var _ = log.Println
type
LoopbackFileSystem
struct
{
type
LoopbackFileSystem
struct
{
root
string
root
string
DefaultPathFile
s
ystem
DefaultPathFile
S
ystem
}
}
func
NewLoopbackFileSystem
(
root
string
)
(
out
*
LoopbackFileSystem
)
{
func
NewLoopbackFileSystem
(
root
string
)
(
out
*
LoopbackFileSystem
)
{
...
...
fuse/loopback_test.go
View file @
e8c28231
...
@@ -54,16 +54,16 @@ func (me *testCase) Setup(t *testing.T) {
...
@@ -54,16 +54,16 @@ func (me *testCase) Setup(t *testing.T) {
me
.
origSubdir
=
filepath
.
Join
(
me
.
origDir
,
subdir
)
me
.
origSubdir
=
filepath
.
Join
(
me
.
origDir
,
subdir
)
me
.
origSubfile
=
filepath
.
Join
(
me
.
origSubdir
,
"subfile"
)
me
.
origSubfile
=
filepath
.
Join
(
me
.
origSubdir
,
"subfile"
)
var
pfs
PathFile
s
ystem
var
pfs
PathFile
S
ystem
pfs
=
NewLoopbackFileSystem
(
me
.
origDir
)
pfs
=
NewLoopbackFileSystem
(
me
.
origDir
)
pfs
=
NewTimingPathFile
s
ystem
(
pfs
)
pfs
=
NewTimingPathFile
S
ystem
(
pfs
)
pfs
=
NewLockingPathFile
s
ystem
(
pfs
)
pfs
=
NewLockingPathFile
S
ystem
(
pfs
)
var
rfs
RawFileSystem
var
rfs
RawFileSystem
me
.
connector
=
NewPathFileSystemConnector
(
pfs
)
me
.
connector
=
NewPathFileSystemConnector
(
pfs
)
rfs
=
me
.
connector
rfs
=
me
.
connector
rfs
=
NewTimingRawFile
s
ystem
(
rfs
)
rfs
=
NewTimingRawFile
S
ystem
(
rfs
)
rfs
=
NewLockingRawFile
s
ystem
(
rfs
)
rfs
=
NewLockingRawFile
S
ystem
(
rfs
)
me
.
connector
.
Debug
=
true
me
.
connector
.
Debug
=
true
me
.
state
=
NewMountState
(
rfs
)
me
.
state
=
NewMountState
(
rfs
)
...
...
fuse/pathdebug.go
View file @
e8c28231
...
@@ -5,21 +5,21 @@ import (
...
@@ -5,21 +5,21 @@ import (
var
_
=
fmt
.
Println
var
_
=
fmt
.
Println
type
PathFile
s
ystemDebug
struct
{
type
PathFile
S
ystemDebug
struct
{
// TODO - use a generic callback system instead.
// TODO - use a generic callback system instead.
Connector
*
PathFileSystemConnector
Connector
*
PathFileSystemConnector
WrappingPathFile
s
ystem
WrappingPathFile
S
ystem
}
}
func
(
me
*
PathFile
s
ystemDebug
)
Open
(
path
string
,
flags
uint32
)
(
fuseFile
FuseFile
,
status
Status
)
{
func
(
me
*
PathFile
S
ystemDebug
)
Open
(
path
string
,
flags
uint32
)
(
fuseFile
FuseFile
,
status
Status
)
{
if
path
==
".debug"
&&
me
.
Connector
!=
nil
{
if
path
==
".debug"
&&
me
.
Connector
!=
nil
{
return
NewReadOnlyFile
([]
byte
(
me
.
Connector
.
DebugString
())),
OK
return
NewReadOnlyFile
([]
byte
(
me
.
Connector
.
DebugString
())),
OK
}
}
return
me
.
Original
.
Open
(
path
,
flags
)
return
me
.
Original
.
Open
(
path
,
flags
)
}
}
func
(
me
*
PathFile
s
ystemDebug
)
GetAttr
(
path
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
PathFile
S
ystemDebug
)
GetAttr
(
path
string
)
(
*
Attr
,
Status
)
{
if
path
==
".debug"
&&
me
.
Connector
!=
nil
{
if
path
==
".debug"
&&
me
.
Connector
!=
nil
{
return
&
Attr
{
return
&
Attr
{
Mode
:
S_IFREG
,
Mode
:
S_IFREG
,
...
...
fuse/pathfilesystem.go
View file @
e8c28231
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
type
mountData
struct
{
type
mountData
struct
{
// If non-nil the file system mounted here.
// If non-nil the file system mounted here.
fs
PathFile
s
ystem
fs
PathFile
S
ystem
// Protects the variables below.
// Protects the variables below.
mutex
sync
.
RWMutex
mutex
sync
.
RWMutex
...
@@ -20,7 +20,7 @@ type mountData struct {
...
@@ -20,7 +20,7 @@ type mountData struct {
unmountPending
bool
unmountPending
bool
}
}
func
newMount
(
fs
PathFile
s
ystem
)
*
mountData
{
func
newMount
(
fs
PathFile
S
ystem
)
*
mountData
{
return
&
mountData
{
fs
:
fs
}
return
&
mountData
{
fs
:
fs
}
}
}
...
@@ -378,7 +378,7 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) {
...
@@ -378,7 +378,7 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) {
return
out
;
return
out
;
}
}
func
NewPathFileSystemConnector
(
fs
PathFile
s
ystem
)
(
out
*
PathFileSystemConnector
)
{
func
NewPathFileSystemConnector
(
fs
PathFile
S
ystem
)
(
out
*
PathFileSystemConnector
)
{
out
=
EmptyPathFileSystemConnector
()
out
=
EmptyPathFileSystemConnector
()
if
code
:=
out
.
Mount
(
"/"
,
fs
);
code
!=
OK
{
if
code
:=
out
.
Mount
(
"/"
,
fs
);
code
!=
OK
{
panic
(
"root mount failed."
)
panic
(
"root mount failed."
)
...
@@ -392,7 +392,7 @@ func (me *PathFileSystemConnector) SetOptions(opts PathFileSystemConnectorOption
...
@@ -392,7 +392,7 @@ func (me *PathFileSystemConnector) SetOptions(opts PathFileSystemConnectorOption
me
.
options
=
opts
me
.
options
=
opts
}
}
func
(
me
*
PathFileSystemConnector
)
Mount
(
mountPoint
string
,
fs
PathFile
s
ystem
)
Status
{
func
(
me
*
PathFileSystemConnector
)
Mount
(
mountPoint
string
,
fs
PathFile
S
ystem
)
Status
{
var
node
*
inode
var
node
*
inode
if
mountPoint
!=
"/"
{
if
mountPoint
!=
"/"
{
...
...
fuse/timingfs.go
View file @
e8c28231
...
@@ -11,9 +11,9 @@ import (
...
@@ -11,9 +11,9 @@ import (
var
_
=
log
.
Print
var
_
=
log
.
Print
var
_
=
fmt
.
Print
var
_
=
fmt
.
Print
// TimingPathFile
system is a wrapper to collect timings for a PathFiles
ystem
// TimingPathFile
System is a wrapper to collect timings for a PathFileS
ystem
type
TimingPathFile
s
ystem
struct
{
type
TimingPathFile
S
ystem
struct
{
WrappingPathFile
s
ystem
WrappingPathFile
S
ystem
statisticsLock
sync
.
Mutex
statisticsLock
sync
.
Mutex
latencies
map
[
string
]
int64
latencies
map
[
string
]
int64
...
@@ -21,8 +21,8 @@ type TimingPathFilesystem struct {
...
@@ -21,8 +21,8 @@ type TimingPathFilesystem struct {
pathCounts
map
[
string
]
map
[
string
]
int64
pathCounts
map
[
string
]
map
[
string
]
int64
}
}
func
NewTimingPathFile
system
(
fs
PathFilesystem
)
*
TimingPathFiles
ystem
{
func
NewTimingPathFile
System
(
fs
PathFileSystem
)
*
TimingPathFileS
ystem
{
t
:=
new
(
TimingPathFile
s
ystem
)
t
:=
new
(
TimingPathFile
S
ystem
)
t
.
Original
=
fs
t
.
Original
=
fs
t
.
latencies
=
make
(
map
[
string
]
int64
)
t
.
latencies
=
make
(
map
[
string
]
int64
)
t
.
counts
=
make
(
map
[
string
]
int64
)
t
.
counts
=
make
(
map
[
string
]
int64
)
...
@@ -30,7 +30,7 @@ func NewTimingPathFilesystem(fs PathFilesystem) *TimingPathFilesystem {
...
@@ -30,7 +30,7 @@ func NewTimingPathFilesystem(fs PathFilesystem) *TimingPathFilesystem {
return
t
return
t
}
}
func
(
me
*
TimingPathFile
s
ystem
)
startTimer
(
name
string
,
arg
string
)
(
closure
func
())
{
func
(
me
*
TimingPathFile
S
ystem
)
startTimer
(
name
string
,
arg
string
)
(
closure
func
())
{
start
:=
time
.
Nanoseconds
()
start
:=
time
.
Nanoseconds
()
return
func
()
{
return
func
()
{
...
@@ -50,7 +50,7 @@ func (me *TimingPathFilesystem) startTimer(name string, arg string) (closure fun
...
@@ -50,7 +50,7 @@ func (me *TimingPathFilesystem) startTimer(name string, arg string) (closure fun
}
}
}
}
func
(
me
*
TimingPathFile
s
ystem
)
OperationCounts
()
map
[
string
]
int64
{
func
(
me
*
TimingPathFile
S
ystem
)
OperationCounts
()
map
[
string
]
int64
{
me
.
statisticsLock
.
Lock
()
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
defer
me
.
statisticsLock
.
Unlock
()
...
@@ -61,7 +61,7 @@ func (me *TimingPathFilesystem) OperationCounts() map[string]int64 {
...
@@ -61,7 +61,7 @@ func (me *TimingPathFilesystem) OperationCounts() map[string]int64 {
return
r
return
r
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Latencies
()
map
[
string
]
float64
{
func
(
me
*
TimingPathFile
S
ystem
)
Latencies
()
map
[
string
]
float64
{
me
.
statisticsLock
.
Lock
()
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
defer
me
.
statisticsLock
.
Unlock
()
...
@@ -72,7 +72,7 @@ func (me *TimingPathFilesystem) Latencies() map[string]float64 {
...
@@ -72,7 +72,7 @@ func (me *TimingPathFilesystem) Latencies() map[string]float64 {
return
r
return
r
}
}
func
(
me
*
TimingPathFile
s
ystem
)
HotPaths
(
operation
string
)
(
paths
[]
string
,
uniquePaths
int
)
{
func
(
me
*
TimingPathFile
S
ystem
)
HotPaths
(
operation
string
)
(
paths
[]
string
,
uniquePaths
int
)
{
me
.
statisticsLock
.
Lock
()
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
defer
me
.
statisticsLock
.
Unlock
()
...
@@ -86,117 +86,117 @@ func (me *TimingPathFilesystem) HotPaths(operation string) (paths []string, uniq
...
@@ -86,117 +86,117 @@ func (me *TimingPathFilesystem) HotPaths(operation string) (paths []string, uniq
return
results
,
len
(
counts
)
return
results
,
len
(
counts
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
defer
me
.
startTimer
(
"GetAttr"
,
name
)()
defer
me
.
startTimer
(
"GetAttr"
,
name
)()
return
me
.
Original
.
GetAttr
(
name
)
return
me
.
Original
.
GetAttr
(
name
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
defer
me
.
startTimer
(
"GetXAttr"
,
name
)()
defer
me
.
startTimer
(
"GetXAttr"
,
name
)()
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
TimingPathFile
S
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
defer
me
.
startTimer
(
"SetXAttr"
,
name
)()
defer
me
.
startTimer
(
"SetXAttr"
,
name
)()
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
defer
me
.
startTimer
(
"ListXAttr"
,
name
)()
defer
me
.
startTimer
(
"ListXAttr"
,
name
)()
return
me
.
Original
.
ListXAttr
(
name
)
return
me
.
Original
.
ListXAttr
(
name
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
TimingPathFile
S
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
defer
me
.
startTimer
(
"RemoveXAttr"
,
name
)()
defer
me
.
startTimer
(
"RemoveXAttr"
,
name
)()
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
defer
me
.
startTimer
(
"Readlink"
,
name
)()
defer
me
.
startTimer
(
"Readlink"
,
name
)()
return
me
.
Original
.
Readlink
(
name
)
return
me
.
Original
.
Readlink
(
name
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
TimingPathFile
S
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
defer
me
.
startTimer
(
"Mknod"
,
name
)()
defer
me
.
startTimer
(
"Mknod"
,
name
)()
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
TimingPathFile
S
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
defer
me
.
startTimer
(
"Mkdir"
,
name
)()
defer
me
.
startTimer
(
"Mkdir"
,
name
)()
return
me
.
Original
.
Mkdir
(
name
,
mode
)
return
me
.
Original
.
Mkdir
(
name
,
mode
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Unlink"
,
name
)()
defer
me
.
startTimer
(
"Unlink"
,
name
)()
return
me
.
Original
.
Unlink
(
name
)
return
me
.
Original
.
Unlink
(
name
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Rmdir"
,
name
)()
defer
me
.
startTimer
(
"Rmdir"
,
name
)()
return
me
.
Original
.
Rmdir
(
name
)
return
me
.
Original
.
Rmdir
(
name
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Symlink"
,
linkName
)()
defer
me
.
startTimer
(
"Symlink"
,
linkName
)()
return
me
.
Original
.
Symlink
(
value
,
linkName
)
return
me
.
Original
.
Symlink
(
value
,
linkName
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Rename"
,
oldName
)()
defer
me
.
startTimer
(
"Rename"
,
oldName
)()
return
me
.
Original
.
Rename
(
oldName
,
newName
)
return
me
.
Original
.
Rename
(
oldName
,
newName
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Link"
,
newName
)()
defer
me
.
startTimer
(
"Link"
,
newName
)()
return
me
.
Original
.
Link
(
oldName
,
newName
)
return
me
.
Original
.
Link
(
oldName
,
newName
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Chmod"
,
name
)()
defer
me
.
startTimer
(
"Chmod"
,
name
)()
return
me
.
Original
.
Chmod
(
name
,
mode
)
return
me
.
Original
.
Chmod
(
name
,
mode
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Chown"
,
name
)()
defer
me
.
startTimer
(
"Chown"
,
name
)()
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Truncate"
,
name
)()
defer
me
.
startTimer
(
"Truncate"
,
name
)()
return
me
.
Original
.
Truncate
(
name
,
offset
)
return
me
.
Original
.
Truncate
(
name
,
offset
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
defer
me
.
startTimer
(
"Open"
,
name
)()
defer
me
.
startTimer
(
"Open"
,
name
)()
return
me
.
Original
.
Open
(
name
,
flags
)
return
me
.
Original
.
Open
(
name
,
flags
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
defer
me
.
startTimer
(
"OpenDir"
,
name
)()
defer
me
.
startTimer
(
"OpenDir"
,
name
)()
return
me
.
Original
.
OpenDir
(
name
)
return
me
.
Original
.
OpenDir
(
name
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
func
(
me
*
TimingPathFile
S
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
defer
me
.
startTimer
(
"Mount"
,
""
)()
defer
me
.
startTimer
(
"Mount"
,
""
)()
return
me
.
Original
.
Mount
(
conn
)
return
me
.
Original
.
Mount
(
conn
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Unmount
()
{
func
(
me
*
TimingPathFile
S
ystem
)
Unmount
()
{
defer
me
.
startTimer
(
"Unmount"
,
""
)()
defer
me
.
startTimer
(
"Unmount"
,
""
)()
me
.
Original
.
Unmount
()
me
.
Original
.
Unmount
()
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Access"
,
name
)()
defer
me
.
startTimer
(
"Access"
,
name
)()
return
me
.
Original
.
Access
(
name
,
mode
)
return
me
.
Original
.
Access
(
name
,
mode
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
defer
me
.
startTimer
(
"Create"
,
name
)()
defer
me
.
startTimer
(
"Create"
,
name
)()
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
}
}
func
(
me
*
TimingPathFile
s
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
TimingPathFile
S
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Utimens"
,
name
)()
defer
me
.
startTimer
(
"Utimens"
,
name
)()
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
}
}
fuse/timingrawfs.go
View file @
e8c28231
...
@@ -5,24 +5,24 @@ import (
...
@@ -5,24 +5,24 @@ import (
"time"
"time"
)
)
// TimingRawFile
system is a wrapper to collect timings for a RawFiles
ystem
// TimingRawFile
System is a wrapper to collect timings for a RawFileS
ystem
type
TimingRawFile
s
ystem
struct
{
type
TimingRawFile
S
ystem
struct
{
WrappingRawFile
s
ystem
WrappingRawFile
S
ystem
statisticsLock
sync
.
Mutex
statisticsLock
sync
.
Mutex
latencies
map
[
string
]
int64
latencies
map
[
string
]
int64
counts
map
[
string
]
int64
counts
map
[
string
]
int64
}
}
func
NewTimingRawFile
system
(
fs
RawFileSystem
)
*
TimingRawFiles
ystem
{
func
NewTimingRawFile
System
(
fs
RawFileSystem
)
*
TimingRawFileS
ystem
{
t
:=
new
(
TimingRawFile
s
ystem
)
t
:=
new
(
TimingRawFile
S
ystem
)
t
.
Original
=
fs
t
.
Original
=
fs
t
.
latencies
=
make
(
map
[
string
]
int64
)
t
.
latencies
=
make
(
map
[
string
]
int64
)
t
.
counts
=
make
(
map
[
string
]
int64
)
t
.
counts
=
make
(
map
[
string
]
int64
)
return
t
return
t
}
}
func
(
me
*
TimingRawFile
s
ystem
)
startTimer
(
name
string
)
(
closure
func
())
{
func
(
me
*
TimingRawFile
S
ystem
)
startTimer
(
name
string
)
(
closure
func
())
{
start
:=
time
.
Nanoseconds
()
start
:=
time
.
Nanoseconds
()
return
func
()
{
return
func
()
{
...
@@ -35,7 +35,7 @@ func (me *TimingRawFilesystem) startTimer(name string) (closure func()) {
...
@@ -35,7 +35,7 @@ func (me *TimingRawFilesystem) startTimer(name string) (closure func()) {
}
}
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Latencies
()
map
[
string
]
float64
{
func
(
me
*
TimingRawFile
S
ystem
)
Latencies
()
map
[
string
]
float64
{
me
.
statisticsLock
.
Lock
()
me
.
statisticsLock
.
Lock
()
defer
me
.
statisticsLock
.
Unlock
()
defer
me
.
statisticsLock
.
Unlock
()
...
@@ -46,167 +46,167 @@ func (me *TimingRawFilesystem) Latencies() map[string]float64 {
...
@@ -46,167 +46,167 @@ func (me *TimingRawFilesystem) Latencies() map[string]float64 {
return
r
return
r
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
defer
me
.
startTimer
(
"Init"
)()
defer
me
.
startTimer
(
"Init"
)()
return
me
.
Original
.
Init
(
h
,
input
)
return
me
.
Original
.
Init
(
h
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
defer
me
.
startTimer
(
"Destroy"
)()
defer
me
.
startTimer
(
"Destroy"
)()
me
.
Original
.
Destroy
(
h
,
input
)
me
.
Original
.
Destroy
(
h
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Lookup"
)()
defer
me
.
startTimer
(
"Lookup"
)()
return
me
.
Original
.
Lookup
(
h
,
name
)
return
me
.
Original
.
Lookup
(
h
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
defer
me
.
startTimer
(
"Forget"
)()
defer
me
.
startTimer
(
"Forget"
)()
me
.
Original
.
Forget
(
h
,
input
)
me
.
Original
.
Forget
(
h
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
defer
me
.
startTimer
(
"GetAttr"
)()
defer
me
.
startTimer
(
"GetAttr"
)()
return
me
.
Original
.
GetAttr
(
header
,
input
)
return
me
.
Original
.
GetAttr
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
defer
me
.
startTimer
(
"Open"
)()
defer
me
.
startTimer
(
"Open"
)()
return
me
.
Original
.
Open
(
header
,
input
)
return
me
.
Original
.
Open
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
defer
me
.
startTimer
(
"SetAttr"
)()
defer
me
.
startTimer
(
"SetAttr"
)()
return
me
.
Original
.
SetAttr
(
header
,
input
)
return
me
.
Original
.
SetAttr
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
defer
me
.
startTimer
(
"Readlink"
)()
defer
me
.
startTimer
(
"Readlink"
)()
return
me
.
Original
.
Readlink
(
header
)
return
me
.
Original
.
Readlink
(
header
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Mknod"
)()
defer
me
.
startTimer
(
"Mknod"
)()
return
me
.
Original
.
Mknod
(
header
,
input
,
name
)
return
me
.
Original
.
Mknod
(
header
,
input
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Mkdir"
)()
defer
me
.
startTimer
(
"Mkdir"
)()
return
me
.
Original
.
Mkdir
(
header
,
input
,
name
)
return
me
.
Original
.
Mkdir
(
header
,
input
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Unlink"
)()
defer
me
.
startTimer
(
"Unlink"
)()
return
me
.
Original
.
Unlink
(
header
,
name
)
return
me
.
Original
.
Unlink
(
header
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Rmdir"
)()
defer
me
.
startTimer
(
"Rmdir"
)()
return
me
.
Original
.
Rmdir
(
header
,
name
)
return
me
.
Original
.
Rmdir
(
header
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Symlink"
)()
defer
me
.
startTimer
(
"Symlink"
)()
return
me
.
Original
.
Symlink
(
header
,
pointedTo
,
linkName
)
return
me
.
Original
.
Symlink
(
header
,
pointedTo
,
linkName
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Rename"
)()
defer
me
.
startTimer
(
"Rename"
)()
return
me
.
Original
.
Rename
(
header
,
input
,
oldName
,
newName
)
return
me
.
Original
.
Rename
(
header
,
input
,
oldName
,
newName
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Link"
)()
defer
me
.
startTimer
(
"Link"
)()
return
me
.
Original
.
Link
(
header
,
input
,
name
)
return
me
.
Original
.
Link
(
header
,
input
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
func
(
me
*
TimingRawFile
S
ystem
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
defer
me
.
startTimer
(
"SetXAttr"
)()
defer
me
.
startTimer
(
"SetXAttr"
)()
return
me
.
Original
.
SetXAttr
(
header
,
input
,
attr
,
data
)
return
me
.
Original
.
SetXAttr
(
header
,
input
,
attr
,
data
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
defer
me
.
startTimer
(
"GetXAttr"
)()
defer
me
.
startTimer
(
"GetXAttr"
)()
return
me
.
Original
.
GetXAttr
(
header
,
attr
)
return
me
.
Original
.
GetXAttr
(
header
,
attr
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
defer
me
.
startTimer
(
"ListXAttr"
)()
defer
me
.
startTimer
(
"ListXAttr"
)()
return
me
.
Original
.
ListXAttr
(
header
)
return
me
.
Original
.
ListXAttr
(
header
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
func
(
me
*
TimingRawFile
S
ystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
defer
me
.
startTimer
(
"RemoveXAttr"
)()
defer
me
.
startTimer
(
"RemoveXAttr"
)()
return
me
.
Original
.
RemoveXAttr
(
header
,
attr
)
return
me
.
Original
.
RemoveXAttr
(
header
,
attr
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Access"
)()
defer
me
.
startTimer
(
"Access"
)()
return
me
.
Original
.
Access
(
header
,
input
)
return
me
.
Original
.
Access
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Create"
)()
defer
me
.
startTimer
(
"Create"
)()
return
me
.
Original
.
Create
(
header
,
input
,
name
)
return
me
.
Original
.
Create
(
header
,
input
,
name
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Bmap
(
header
*
InHeader
,
input
*
BmapIn
)
(
out
*
BmapOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Bmap
(
header
*
InHeader
,
input
*
BmapIn
)
(
out
*
BmapOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Bmap"
)()
defer
me
.
startTimer
(
"Bmap"
)()
return
me
.
Original
.
Bmap
(
header
,
input
)
return
me
.
Original
.
Bmap
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
out
*
IoctlOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
out
*
IoctlOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Ioctl"
)()
defer
me
.
startTimer
(
"Ioctl"
)()
return
me
.
Original
.
Ioctl
(
header
,
input
)
return
me
.
Original
.
Ioctl
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Poll
(
header
*
InHeader
,
input
*
PollIn
)
(
out
*
PollOut
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Poll
(
header
*
InHeader
,
input
*
PollIn
)
(
out
*
PollOut
,
code
Status
)
{
defer
me
.
startTimer
(
"Poll"
)()
defer
me
.
startTimer
(
"Poll"
)()
return
me
.
Original
.
Poll
(
header
,
input
)
return
me
.
Original
.
Poll
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
defer
me
.
startTimer
(
"OpenDir"
)()
defer
me
.
startTimer
(
"OpenDir"
)()
return
me
.
Original
.
OpenDir
(
header
,
input
)
return
me
.
Original
.
OpenDir
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
defer
me
.
startTimer
(
"Release"
)()
defer
me
.
startTimer
(
"Release"
)()
me
.
Original
.
Release
(
header
,
input
)
me
.
Original
.
Release
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
defer
me
.
startTimer
(
"Read"
)()
defer
me
.
startTimer
(
"Read"
)()
return
me
.
Original
.
Read
(
input
,
bp
)
return
me
.
Original
.
Read
(
input
,
bp
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
defer
me
.
startTimer
(
"Write"
)()
defer
me
.
startTimer
(
"Write"
)()
return
me
.
Original
.
Write
(
input
,
data
)
return
me
.
Original
.
Write
(
input
,
data
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Flush
(
input
*
FlushIn
)
Status
{
func
(
me
*
TimingRawFile
S
ystem
)
Flush
(
input
*
FlushIn
)
Status
{
defer
me
.
startTimer
(
"Flush"
)()
defer
me
.
startTimer
(
"Flush"
)()
return
me
.
Original
.
Flush
(
input
)
return
me
.
Original
.
Flush
(
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
Fsync
(
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
Fsync
(
input
*
FsyncIn
)
(
code
Status
)
{
defer
me
.
startTimer
(
"Fsync"
)()
defer
me
.
startTimer
(
"Fsync"
)()
return
me
.
Original
.
Fsync
(
input
)
return
me
.
Original
.
Fsync
(
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
defer
me
.
startTimer
(
"ReadDir"
)()
defer
me
.
startTimer
(
"ReadDir"
)()
return
me
.
Original
.
ReadDir
(
header
,
input
)
return
me
.
Original
.
ReadDir
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
TimingRawFile
S
ystem
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
defer
me
.
startTimer
(
"ReleaseDir"
)()
defer
me
.
startTimer
(
"ReleaseDir"
)()
me
.
Original
.
ReleaseDir
(
header
,
input
)
me
.
Original
.
ReleaseDir
(
header
,
input
)
}
}
func
(
me
*
TimingRawFile
s
ystem
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
TimingRawFile
S
ystem
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
defer
me
.
startTimer
(
"FsyncDir"
)()
defer
me
.
startTimer
(
"FsyncDir"
)()
return
me
.
Original
.
FsyncDir
(
header
,
input
)
return
me
.
Original
.
FsyncDir
(
header
,
input
)
}
}
fuse/types.go
View file @
e8c28231
...
@@ -558,7 +558,7 @@ type RawFuseDir interface {
...
@@ -558,7 +558,7 @@ type RawFuseDir interface {
Release
()
Release
()
}
}
type
PathFile
s
ystem
interface
{
type
PathFile
S
ystem
interface
{
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
Readlink
(
name
string
)
(
string
,
Status
)
Readlink
(
name
string
)
(
string
,
Status
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
...
@@ -596,6 +596,6 @@ type PathFilesystem interface {
...
@@ -596,6 +596,6 @@ type PathFilesystem interface {
// Include this struct in your implementation to inherit default nop
// Include this struct in your implementation to inherit default nop
// implementations.
// implementations.
type
DefaultPathFile
s
ystem
struct
{}
type
DefaultPathFile
S
ystem
struct
{}
type
DefaultFuseFile
struct
{}
type
DefaultFuseFile
struct
{}
type
DefaultRawFuseFileSystem
struct
{}
type
DefaultRawFuseFileSystem
struct
{}
fuse/wrappedfs.go
View file @
e8c28231
package
fuse
package
fuse
type
WrappingPathFile
s
ystem
struct
{
type
WrappingPathFile
S
ystem
struct
{
// Should be public so people reusing can access the wrapped
// Should be public so people reusing can access the wrapped
// FS.
// FS.
Original
PathFile
s
ystem
Original
PathFile
S
ystem
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
return
me
.
Original
.
GetAttr
(
name
)
return
me
.
Original
.
GetAttr
(
name
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Readlink
(
name
string
)
(
string
,
Status
)
{
return
me
.
Original
.
Readlink
(
name
)
return
me
.
Original
.
Readlink
(
name
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
func
(
me
*
WrappingPathFile
S
ystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
)
Status
{
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
return
me
.
Original
.
Mknod
(
name
,
mode
,
dev
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
func
(
me
*
WrappingPathFile
S
ystem
)
Mkdir
(
name
string
,
mode
uint32
)
Status
{
return
me
.
Original
.
Mkdir
(
name
,
mode
)
return
me
.
Original
.
Mkdir
(
name
,
mode
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Unlink
(
name
string
)
(
code
Status
)
{
return
me
.
Original
.
Unlink
(
name
)
return
me
.
Original
.
Unlink
(
name
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Rmdir
(
name
string
)
(
code
Status
)
{
return
me
.
Original
.
Rmdir
(
name
)
return
me
.
Original
.
Rmdir
(
name
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
{
return
me
.
Original
.
Symlink
(
value
,
linkName
)
return
me
.
Original
.
Symlink
(
value
,
linkName
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Rename
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
me
.
Original
.
Rename
(
oldName
,
newName
)
return
me
.
Original
.
Rename
(
oldName
,
newName
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Link
(
oldName
string
,
newName
string
)
(
code
Status
)
{
return
me
.
Original
.
Link
(
oldName
,
newName
)
return
me
.
Original
.
Link
(
oldName
,
newName
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Chmod
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
me
.
Original
.
Chmod
(
name
,
mode
)
return
me
.
Original
.
Chmod
(
name
,
mode
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
)
(
code
Status
)
{
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
return
me
.
Original
.
Chown
(
name
,
uid
,
gid
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Truncate
(
name
string
,
offset
uint64
)
(
code
Status
)
{
return
me
.
Original
.
Truncate
(
name
,
offset
)
return
me
.
Original
.
Truncate
(
name
,
offset
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Open
(
name
string
,
flags
uint32
)
(
file
FuseFile
,
code
Status
)
{
return
me
.
Original
.
Open
(
name
,
flags
)
return
me
.
Original
.
Open
(
name
,
flags
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
return
me
.
Original
.
OpenDir
(
name
)
return
me
.
Original
.
OpenDir
(
name
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
func
(
me
*
WrappingPathFile
S
ystem
)
Mount
(
conn
*
PathFileSystemConnector
)
Status
{
return
me
.
Original
.
Mount
(
conn
)
return
me
.
Original
.
Mount
(
conn
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Unmount
()
{
func
(
me
*
WrappingPathFile
S
ystem
)
Unmount
()
{
me
.
Original
.
Unmount
()
me
.
Original
.
Unmount
()
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Access
(
name
string
,
mode
uint32
)
(
code
Status
)
{
return
me
.
Original
.
Access
(
name
,
mode
)
return
me
.
Original
.
Access
(
name
,
mode
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
FuseFile
,
code
Status
)
{
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
return
me
.
Original
.
Create
(
name
,
flags
,
mode
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
return
me
.
Original
.
Utimens
(
name
,
AtimeNs
,
CtimeNs
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
return
me
.
Original
.
GetXAttr
(
name
,
attr
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
func
(
me
*
WrappingPathFile
S
ystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
)
Status
{
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
return
me
.
Original
.
SetXAttr
(
name
,
attr
,
data
,
flags
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
func
(
me
*
WrappingPathFile
S
ystem
)
ListXAttr
(
name
string
)
([]
string
,
Status
)
{
return
me
.
Original
.
ListXAttr
(
name
)
return
me
.
Original
.
ListXAttr
(
name
)
}
}
func
(
me
*
WrappingPathFile
s
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
WrappingPathFile
S
ystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
return
me
.
Original
.
RemoveXAttr
(
name
,
attr
)
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Wrapping raw FS.
// Wrapping raw FS.
type
WrappingRawFile
s
ystem
struct
{
type
WrappingRawFile
S
ystem
struct
{
Original
RawFileSystem
Original
RawFileSystem
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Init
(
h
*
InHeader
,
input
*
InitIn
)
(
*
InitOut
,
Status
)
{
return
me
.
Original
.
Init
(
h
,
input
)
return
me
.
Original
.
Init
(
h
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Destroy
(
h
*
InHeader
,
input
*
InitIn
)
{
me
.
Original
.
Destroy
(
h
,
input
)
me
.
Original
.
Destroy
(
h
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
return
me
.
Original
.
Lookup
(
h
,
name
)
return
me
.
Original
.
Lookup
(
h
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Forget
(
h
*
InHeader
,
input
*
ForgetIn
)
{
me
.
Original
.
Forget
(
h
,
input
)
me
.
Original
.
Forget
(
h
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
return
me
.
Original
.
GetAttr
(
header
,
input
)
return
me
.
Original
.
GetAttr
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
return
me
.
Original
.
Open
(
header
,
input
)
return
me
.
Original
.
Open
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
SetAttr
(
header
*
InHeader
,
input
*
SetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
return
me
.
Original
.
SetAttr
(
header
,
input
)
return
me
.
Original
.
SetAttr
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
return
me
.
Original
.
Readlink
(
header
)
return
me
.
Original
.
Readlink
(
header
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Mknod
(
header
*
InHeader
,
input
*
MknodIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
return
me
.
Original
.
Mknod
(
header
,
input
,
name
)
return
me
.
Original
.
Mknod
(
header
,
input
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Mkdir
(
header
*
InHeader
,
input
*
MkdirIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
return
me
.
Original
.
Mkdir
(
header
,
input
,
name
)
return
me
.
Original
.
Mkdir
(
header
,
input
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
return
me
.
Original
.
Unlink
(
header
,
name
)
return
me
.
Original
.
Unlink
(
header
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
return
me
.
Original
.
Rmdir
(
header
,
name
)
return
me
.
Original
.
Rmdir
(
header
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
EntryOut
,
code
Status
)
{
return
me
.
Original
.
Symlink
(
header
,
pointedTo
,
linkName
)
return
me
.
Original
.
Symlink
(
header
,
pointedTo
,
linkName
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
return
me
.
Original
.
Rename
(
header
,
input
,
oldName
,
newName
)
return
me
.
Original
.
Rename
(
header
,
input
,
oldName
,
newName
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
return
me
.
Original
.
Link
(
header
,
input
,
name
)
return
me
.
Original
.
Link
(
header
,
input
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
func
(
me
*
WrappingRawFile
S
ystem
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
return
me
.
Original
.
SetXAttr
(
header
,
input
,
attr
,
data
)
return
me
.
Original
.
SetXAttr
(
header
,
input
,
attr
,
data
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
return
me
.
Original
.
GetXAttr
(
header
,
attr
)
return
me
.
Original
.
GetXAttr
(
header
,
attr
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
return
me
.
Original
.
ListXAttr
(
header
)
return
me
.
Original
.
ListXAttr
(
header
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
func
(
me
*
WrappingRawFile
S
ystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
return
me
.
Original
.
RemoveXAttr
(
header
,
attr
)
return
me
.
Original
.
RemoveXAttr
(
header
,
attr
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
{
return
me
.
Original
.
Access
(
header
,
input
)
return
me
.
Original
.
Access
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
{
return
me
.
Original
.
Create
(
header
,
input
,
name
)
return
me
.
Original
.
Create
(
header
,
input
,
name
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Bmap
(
header
*
InHeader
,
input
*
BmapIn
)
(
out
*
BmapOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Bmap
(
header
*
InHeader
,
input
*
BmapIn
)
(
out
*
BmapOut
,
code
Status
)
{
return
me
.
Original
.
Bmap
(
header
,
input
)
return
me
.
Original
.
Bmap
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
out
*
IoctlOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
out
*
IoctlOut
,
code
Status
)
{
return
me
.
Original
.
Ioctl
(
header
,
input
)
return
me
.
Original
.
Ioctl
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Poll
(
header
*
InHeader
,
input
*
PollIn
)
(
out
*
PollOut
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Poll
(
header
*
InHeader
,
input
*
PollIn
)
(
out
*
PollOut
,
code
Status
)
{
return
me
.
Original
.
Poll
(
header
,
input
)
return
me
.
Original
.
Poll
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
OpenDir
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
return
me
.
Original
.
OpenDir
(
header
,
input
)
return
me
.
Original
.
OpenDir
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
me
.
Original
.
Release
(
header
,
input
)
me
.
Original
.
Release
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
return
me
.
Original
.
Read
(
input
,
bp
)
return
me
.
Original
.
Read
(
input
,
bp
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
return
me
.
Original
.
Write
(
input
,
data
)
return
me
.
Original
.
Write
(
input
,
data
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Flush
(
input
*
FlushIn
)
Status
{
func
(
me
*
WrappingRawFile
S
ystem
)
Flush
(
input
*
FlushIn
)
Status
{
return
me
.
Original
.
Flush
(
input
)
return
me
.
Original
.
Flush
(
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
Fsync
(
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
Fsync
(
input
*
FsyncIn
)
(
code
Status
)
{
return
me
.
Original
.
Fsync
(
input
)
return
me
.
Original
.
Fsync
(
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
return
me
.
Original
.
ReadDir
(
header
,
input
)
return
me
.
Original
.
ReadDir
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
ReleaseDir
(
header
*
InHeader
,
input
*
ReleaseIn
)
{
me
.
Original
.
ReleaseDir
(
header
,
input
)
me
.
Original
.
ReleaseDir
(
header
,
input
)
}
}
func
(
me
*
WrappingRawFile
s
ystem
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
func
(
me
*
WrappingRawFile
S
ystem
)
FsyncDir
(
header
*
InHeader
,
input
*
FsyncIn
)
(
code
Status
)
{
return
me
.
Original
.
FsyncDir
(
header
,
input
)
return
me
.
Original
.
FsyncDir
(
header
,
input
)
}
}
fuse/xattr_test.go
View file @
e8c28231
...
@@ -15,7 +15,7 @@ type XAttrTestFs struct {
...
@@ -15,7 +15,7 @@ type XAttrTestFs struct {
filename
string
filename
string
attrs
map
[
string
][]
byte
attrs
map
[
string
][]
byte
DefaultPathFile
s
ystem
DefaultPathFile
S
ystem
}
}
func
NewXAttrFs
(
nm
string
,
m
map
[
string
][]
byte
)
*
XAttrTestFs
{
func
NewXAttrFs
(
nm
string
,
m
map
[
string
][]
byte
)
*
XAttrTestFs
{
...
@@ -93,7 +93,7 @@ func TestXAttrRead(t *testing.T) {
...
@@ -93,7 +93,7 @@ func TestXAttrRead(t *testing.T) {
"user.attr2"
:
[]
byte
(
"val2"
)}
"user.attr2"
:
[]
byte
(
"val2"
)}
xfs
:=
NewXAttrFs
(
nm
,
golden
)
xfs
:=
NewXAttrFs
(
nm
,
golden
)
connector
:=
NewPathFileSystemConnector
(
NewLockingPathFile
s
ystem
(
xfs
))
connector
:=
NewPathFileSystemConnector
(
NewLockingPathFile
S
ystem
(
xfs
))
mountPoint
:=
MakeTempDir
()
mountPoint
:=
MakeTempDir
()
state
:=
NewMountState
(
connector
)
state
:=
NewMountState
(
connector
)
...
...
unionfs/autounion.go
View file @
e8c28231
...
@@ -18,10 +18,10 @@ import (
...
@@ -18,10 +18,10 @@ import (
//
//
// A union for A/B/C will placed under directory A-B-C.
// A union for A/B/C will placed under directory A-B-C.
type
AutoUnionFs
struct
{
type
AutoUnionFs
struct
{
fuse
.
DefaultPathFile
s
ystem
fuse
.
DefaultPathFile
S
ystem
lock
sync
.
RWMutex
lock
sync
.
RWMutex
knownFile
s
ystems
map
[
string
]
*
UnionFs
knownFile
S
ystems
map
[
string
]
*
UnionFs
root
string
root
string
connector
*
fuse
.
PathFileSystemConnector
connector
*
fuse
.
PathFileSystemConnector
...
@@ -35,7 +35,7 @@ type AutoUnionFsOptions struct {
...
@@ -35,7 +35,7 @@ type AutoUnionFsOptions struct {
func
NewAutoUnionFs
(
directory
string
,
options
AutoUnionFsOptions
)
*
AutoUnionFs
{
func
NewAutoUnionFs
(
directory
string
,
options
AutoUnionFsOptions
)
*
AutoUnionFs
{
a
:=
new
(
AutoUnionFs
)
a
:=
new
(
AutoUnionFs
)
a
.
knownFile
s
ystems
=
make
(
map
[
string
]
*
UnionFs
)
a
.
knownFile
S
ystems
=
make
(
map
[
string
]
*
UnionFs
)
a
.
options
=
&
options
a
.
options
=
&
options
a
.
root
=
directory
a
.
root
=
directory
return
a
return
a
...
@@ -58,10 +58,10 @@ func (me *AutoUnionFs) addFs(roots []string) {
...
@@ -58,10 +58,10 @@ func (me *AutoUnionFs) addFs(roots []string) {
me
.
lock
.
Lock
()
me
.
lock
.
Lock
()
var
gofs
*
UnionFs
var
gofs
*
UnionFs
if
me
.
knownFile
s
ystems
[
name
]
==
nil
{
if
me
.
knownFile
S
ystems
[
name
]
==
nil
{
log
.
Println
(
"Adding UnionFs for roots"
,
roots
)
log
.
Println
(
"Adding UnionFs for roots"
,
roots
)
gofs
=
NewUnionFs
(
roots
,
me
.
options
.
UnionFsOptions
)
gofs
=
NewUnionFs
(
roots
,
me
.
options
.
UnionFsOptions
)
me
.
knownFile
s
ystems
[
name
]
=
gofs
me
.
knownFile
S
ystems
[
name
]
=
gofs
}
}
me
.
lock
.
Unlock
()
me
.
lock
.
Unlock
()
...
@@ -103,7 +103,7 @@ func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
...
@@ -103,7 +103,7 @@ func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
name
:=
comps
[
1
]
name
:=
comps
[
1
]
me
.
lock
.
RLock
()
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
defer
me
.
lock
.
RUnlock
()
fs
:=
me
.
knownFile
s
ystems
[
name
]
fs
:=
me
.
knownFile
S
ystems
[
name
]
if
fs
==
nil
{
if
fs
==
nil
{
return
""
,
fuse
.
ENOENT
return
""
,
fuse
.
ENOENT
}
}
...
@@ -137,7 +137,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
...
@@ -137,7 +137,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
me
.
lock
.
RLock
()
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
defer
me
.
lock
.
RUnlock
()
if
len
(
comps
)
>
1
&&
comps
[
0
]
==
"config"
{
if
len
(
comps
)
>
1
&&
comps
[
0
]
==
"config"
{
fs
:=
me
.
knownFile
s
ystems
[
comps
[
1
]]
fs
:=
me
.
knownFile
S
ystems
[
comps
[
1
]]
if
fs
==
nil
{
if
fs
==
nil
{
return
nil
,
fuse
.
ENOENT
return
nil
,
fuse
.
ENOENT
...
@@ -149,7 +149,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
...
@@ -149,7 +149,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
return
a
,
fuse
.
OK
return
a
,
fuse
.
OK
}
}
if
me
.
knownFile
s
ystems
[
path
]
!=
nil
{
if
me
.
knownFile
S
ystems
[
path
]
!=
nil
{
return
&
fuse
.
Attr
{
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
0755
,
Mode
:
fuse
.
S_IFDIR
|
0755
,
},
fuse
.
OK
},
fuse
.
OK
...
@@ -189,8 +189,8 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
...
@@ -189,8 +189,8 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
me
.
lock
.
RLock
()
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
defer
me
.
lock
.
RUnlock
()
stream
=
make
(
chan
fuse
.
DirEntry
,
len
(
me
.
knownFile
s
ystems
)
+
5
)
stream
=
make
(
chan
fuse
.
DirEntry
,
len
(
me
.
knownFile
S
ystems
)
+
5
)
for
k
,
_
:=
range
me
.
knownFile
s
ystems
{
for
k
,
_
:=
range
me
.
knownFile
S
ystems
{
mode
:=
fuse
.
S_IFDIR
|
0755
mode
:=
fuse
.
S_IFDIR
|
0755
if
name
==
"config"
{
if
name
==
"config"
{
mode
=
syscall
.
S_IFLNK
|
0644
mode
=
syscall
.
S_IFLNK
|
0644
...
...
unionfs/cachingfs.go
View file @
e8c28231
...
@@ -22,7 +22,7 @@ type linkResponse struct {
...
@@ -22,7 +22,7 @@ type linkResponse struct {
// Caches readdir and getattr()
// Caches readdir and getattr()
type
CachingFileSystem
struct
{
type
CachingFileSystem
struct
{
fuse
.
WrappingPathFile
s
ystem
fuse
.
WrappingPathFile
S
ystem
attributesLock
sync
.
RWMutex
attributesLock
sync
.
RWMutex
attributes
map
[
string
]
attrResponse
attributes
map
[
string
]
attrResponse
...
@@ -34,7 +34,7 @@ type CachingFileSystem struct {
...
@@ -34,7 +34,7 @@ type CachingFileSystem struct {
links
map
[
string
]
linkResponse
links
map
[
string
]
linkResponse
}
}
func
NewCachingFileSystem
(
pfs
fuse
.
PathFile
s
ystem
)
*
CachingFileSystem
{
func
NewCachingFileSystem
(
pfs
fuse
.
PathFile
S
ystem
)
*
CachingFileSystem
{
c
:=
new
(
CachingFileSystem
)
c
:=
new
(
CachingFileSystem
)
c
.
Original
=
pfs
c
.
Original
=
pfs
c
.
attributes
=
make
(
map
[
string
]
attrResponse
)
c
.
attributes
=
make
(
map
[
string
]
attrResponse
)
...
...
unionfs/unionfs.go
View file @
e8c28231
...
@@ -58,12 +58,12 @@ func filePathHash(path string) string {
...
@@ -58,12 +58,12 @@ func filePathHash(path string) string {
*/
*/
type
UnionFs
struct
{
type
UnionFs
struct
{
fuse
.
DefaultPathFile
s
ystem
fuse
.
DefaultPathFile
S
ystem
branches
[]
*
fuse
.
LoopbackFileSystem
branches
[]
*
fuse
.
LoopbackFileSystem
// The same, but as interfaces.
// The same, but as interfaces.
fileSystems
[]
fuse
.
PathFile
s
ystem
fileSystems
[]
fuse
.
PathFile
S
ystem
// A file-existence cache.
// A file-existence cache.
deletionCache
*
DirCache
deletionCache
*
DirCache
...
@@ -89,7 +89,7 @@ func NewUnionFs(roots []string, options UnionFsOptions) *UnionFs {
...
@@ -89,7 +89,7 @@ func NewUnionFs(roots []string, options UnionFsOptions) *UnionFs {
g
.
branches
=
append
(
g
.
branches
,
pt
)
g
.
branches
=
append
(
g
.
branches
,
pt
)
// We could use some sort of caching file system here.
// We could use some sort of caching file system here.
g
.
fileSystems
=
append
(
g
.
fileSystems
,
fuse
.
PathFile
s
ystem
(
pt
))
g
.
fileSystems
=
append
(
g
.
fileSystems
,
fuse
.
PathFile
S
ystem
(
pt
))
}
}
deletionDir
:=
g
.
deletionDir
()
deletionDir
:=
g
.
deletionDir
()
...
@@ -232,7 +232,7 @@ src *fuse.LoopbackFileSystem) os.Error {
...
@@ -232,7 +232,7 @@ src *fuse.LoopbackFileSystem) os.Error {
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Below: implement interface for a PathFile
s
ystem.
// Below: implement interface for a PathFile
S
ystem.
func
(
me
*
UnionFs
)
Mkdir
(
path
string
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
me
*
UnionFs
)
Mkdir
(
path
string
,
mode
uint32
)
(
code
fuse
.
Status
)
{
code
=
me
.
fileSystems
[
0
]
.
Mkdir
(
path
,
mode
)
code
=
me
.
fileSystems
[
0
]
.
Mkdir
(
path
,
mode
)
...
@@ -344,7 +344,7 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
...
@@ -344,7 +344,7 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
for
i
,
l
:=
range
me
.
fileSystems
{
for
i
,
l
:=
range
me
.
fileSystems
{
if
i
>=
dirBranch
{
if
i
>=
dirBranch
{
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
(
j
int
,
pfs
fuse
.
PathFile
s
ystem
)
{
go
func
(
j
int
,
pfs
fuse
.
PathFile
S
ystem
)
{
ch
,
s
:=
pfs
.
OpenDir
(
directory
)
ch
,
s
:=
pfs
.
OpenDir
(
directory
)
statuses
[
j
]
=
s
statuses
[
j
]
=
s
for
s
==
fuse
.
OK
{
for
s
==
fuse
.
OK
{
...
...
zipfs/multizip.go
View file @
e8c28231
...
@@ -77,7 +77,7 @@ type MultiZipFs struct {
...
@@ -77,7 +77,7 @@ type MultiZipFs struct {
pendingZips
map
[
string
]
bool
pendingZips
map
[
string
]
bool
zipFileNames
map
[
string
]
string
zipFileNames
map
[
string
]
string
fuse
.
DefaultPathFile
s
ystem
fuse
.
DefaultPathFile
S
ystem
}
}
func
NewMultiZipFs
()
*
MultiZipFs
{
func
NewMultiZipFs
()
*
MultiZipFs
{
...
...
zipfs/zipfs.go
View file @
e8c28231
...
@@ -75,7 +75,7 @@ type ZipFileFuse struct {
...
@@ -75,7 +75,7 @@ type ZipFileFuse struct {
tree
*
ZipDirTree
tree
*
ZipDirTree
ZipFileName
string
ZipFileName
string
fuse
.
DefaultPathFile
s
ystem
fuse
.
DefaultPathFile
S
ystem
}
}
func
zipFilesToTree
(
files
[]
*
zip
.
File
)
*
ZipDirTree
{
func
zipFilesToTree
(
files
[]
*
zip
.
File
)
*
ZipDirTree
{
...
...
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