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
7c991e45
Commit
7c991e45
authored
Apr 24, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt.
parent
29d35b93
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
87 additions
and
88 deletions
+87
-88
fuse/bufferpool.go
fuse/bufferpool.go
+1
-1
fuse/fuse.go
fuse/fuse.go
+8
-8
fuse/latencymap.go
fuse/latencymap.go
+5
-5
fuse/latencymap_test.go
fuse/latencymap_test.go
+1
-0
fuse/opcode.go
fuse/opcode.go
+45
-45
fuse/pathdebug.go
fuse/pathdebug.go
+5
-6
fuse/pathdebug_test.go
fuse/pathdebug_test.go
+2
-2
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+11
-11
fuse/pathops.go
fuse/pathops.go
+5
-6
fuse/types.go
fuse/types.go
+4
-4
No files found.
fuse/bufferpool.go
View file @
7c991e45
...
@@ -115,7 +115,7 @@ func (me *BufferPool) AllocBuffer(size uint32) []byte {
...
@@ -115,7 +115,7 @@ func (me *BufferPool) AllocBuffer(size uint32) []byte {
if
len
(
me
.
outstandingBuffers
)
>
200
{
if
len
(
me
.
outstandingBuffers
)
>
200
{
panic
(
"Leaking buffers"
)
panic
(
"Leaking buffers"
)
}
}
return
b
return
b
}
}
...
...
fuse/fuse.go
View file @
7c991e45
...
@@ -31,7 +31,7 @@ type request struct {
...
@@ -31,7 +31,7 @@ type request struct {
arg
[]
byte
// flat data.
arg
[]
byte
// flat data.
// Unstructured data, a pointer to the relevant XxxxOut struct.
// Unstructured data, a pointer to the relevant XxxxOut struct.
outData
unsafe
.
Pointer
outData
unsafe
.
Pointer
status
Status
status
Status
flatData
[]
byte
flatData
[]
byte
...
@@ -99,7 +99,7 @@ func (me *MountState) Write(req *request) {
...
@@ -99,7 +99,7 @@ func (me *MountState) Write(req *request) {
if
me
.
RecordStatistics
{
if
me
.
RecordStatistics
{
req
.
preWriteNs
=
time
.
Nanoseconds
()
req
.
preWriteNs
=
time
.
Nanoseconds
()
}
}
if
req
.
outHeaderBytes
==
nil
{
if
req
.
outHeaderBytes
==
nil
{
return
return
}
}
...
@@ -169,9 +169,9 @@ func (me *MountState) discardRequest(req *request) {
...
@@ -169,9 +169,9 @@ func (me *MountState) discardRequest(req *request) {
opname
:=
operationName
(
req
.
inHeader
.
Opcode
)
opname
:=
operationName
(
req
.
inHeader
.
Opcode
)
me
.
LatencyMap
.
AddMany
(
me
.
LatencyMap
.
AddMany
(
[]
LatencyArg
{
[]
LatencyArg
{
{
opname
,
""
,
dt
},
{
opname
,
""
,
dt
},
{
opname
+
"-dispatch"
,
""
,
req
.
dispatchNs
-
req
.
startNs
},
{
opname
+
"-dispatch"
,
""
,
req
.
dispatchNs
-
req
.
startNs
},
{
opname
+
"-write"
,
""
,
endNs
-
req
.
preWriteNs
}})
{
opname
+
"-write"
,
""
,
endNs
-
req
.
preWriteNs
}})
}
}
me
.
buffers
.
FreeBuffer
(
req
.
inputBuf
)
me
.
buffers
.
FreeBuffer
(
req
.
inputBuf
)
...
@@ -228,7 +228,7 @@ func (me *MountState) chopMessage(req *request) *operationHandler {
...
@@ -228,7 +228,7 @@ func (me *MountState) chopMessage(req *request) *operationHandler {
log
.
Printf
(
"Short read for input header: %v"
,
req
.
inputBuf
)
log
.
Printf
(
"Short read for input header: %v"
,
req
.
inputBuf
)
return
nil
return
nil
}
}
req
.
inHeader
=
(
*
InHeader
)(
unsafe
.
Pointer
(
&
req
.
inputBuf
[
0
]))
req
.
inHeader
=
(
*
InHeader
)(
unsafe
.
Pointer
(
&
req
.
inputBuf
[
0
]))
req
.
arg
=
req
.
inputBuf
[
inHSize
:
]
req
.
arg
=
req
.
inputBuf
[
inHSize
:
]
...
@@ -263,7 +263,7 @@ func (me *MountState) handle(req *request) {
...
@@ -263,7 +263,7 @@ func (me *MountState) handle(req *request) {
if
req
.
status
==
OK
{
if
req
.
status
==
OK
{
me
.
dispatch
(
req
,
handler
)
me
.
dispatch
(
req
,
handler
)
}
}
// If we try to write OK, nil, we will get
// If we try to write OK, nil, we will get
// error: writer: Writev [[16 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0]]
// error: writer: Writev [[16 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0]]
// failed, err: writev: no such file or directory
// failed, err: writev: no such file or directory
...
@@ -277,7 +277,7 @@ func (me *MountState) dispatch(req *request, handler *operationHandler) {
...
@@ -277,7 +277,7 @@ func (me *MountState) dispatch(req *request, handler *operationHandler) {
if
me
.
RecordStatistics
{
if
me
.
RecordStatistics
{
req
.
dispatchNs
=
time
.
Nanoseconds
()
req
.
dispatchNs
=
time
.
Nanoseconds
()
}
}
if
me
.
Debug
{
if
me
.
Debug
{
nm
:=
""
nm
:=
""
// TODO - reinstate filename printing.
// TODO - reinstate filename printing.
...
...
fuse/latencymap.go
View file @
7c991e45
...
@@ -8,18 +8,18 @@ import (
...
@@ -8,18 +8,18 @@ import (
type
latencyMapEntry
struct
{
type
latencyMapEntry
struct
{
count
int
count
int
ns
int64
ns
int64
}
}
type
LatencyArg
struct
{
type
LatencyArg
struct
{
Name
string
Name
string
Arg
string
Arg
string
DtNs
int64
DtNs
int64
}
}
type
LatencyMap
struct
{
type
LatencyMap
struct
{
sync
.
Mutex
sync
.
Mutex
stats
map
[
string
]
*
latencyMapEntry
stats
map
[
string
]
*
latencyMapEntry
secondaryStats
map
[
string
]
map
[
string
]
int64
secondaryStats
map
[
string
]
map
[
string
]
int64
}
}
...
@@ -50,7 +50,7 @@ func (me *LatencyMap) add(name string, arg string, dtNs int64) {
...
@@ -50,7 +50,7 @@ func (me *LatencyMap) add(name string, arg string, dtNs int64) {
me
.
stats
[
name
]
=
e
me
.
stats
[
name
]
=
e
}
}
e
.
count
++
e
.
count
++
e
.
ns
+=
dtNs
e
.
ns
+=
dtNs
if
arg
!=
""
{
if
arg
!=
""
{
m
,
ok
:=
me
.
secondaryStats
[
name
]
m
,
ok
:=
me
.
secondaryStats
[
name
]
...
...
fuse/latencymap_test.go
View file @
7c991e45
package
fuse
package
fuse
import
(
import
(
"fmt"
"fmt"
"testing"
"testing"
...
...
fuse/opcode.go
View file @
7c991e45
...
@@ -253,62 +253,62 @@ func init() {
...
@@ -253,62 +253,62 @@ func init() {
for
i
,
_
:=
range
operationHandlers
{
for
i
,
_
:=
range
operationHandlers
{
operationHandlers
[
i
]
=
&
operationHandler
{
Name
:
"UNKNOWN"
}
operationHandlers
[
i
]
=
&
operationHandler
{
Name
:
"UNKNOWN"
}
}
}
for
op
,
sz
:=
range
map
[
int
]
int
{
for
op
,
sz
:=
range
map
[
int
]
int
{
FUSE_FORGET
:
unsafe
.
Sizeof
(
ForgetIn
{}),
FUSE_FORGET
:
unsafe
.
Sizeof
(
ForgetIn
{}),
FUSE_GETATTR
:
unsafe
.
Sizeof
(
GetAttrIn
{}),
FUSE_GETATTR
:
unsafe
.
Sizeof
(
GetAttrIn
{}),
FUSE_SETATTR
:
unsafe
.
Sizeof
(
SetAttrIn
{}),
FUSE_SETATTR
:
unsafe
.
Sizeof
(
SetAttrIn
{}),
FUSE_MKNOD
:
unsafe
.
Sizeof
(
MknodIn
{}),
FUSE_MKNOD
:
unsafe
.
Sizeof
(
MknodIn
{}),
FUSE_MKDIR
:
unsafe
.
Sizeof
(
MkdirIn
{}),
FUSE_MKDIR
:
unsafe
.
Sizeof
(
MkdirIn
{}),
FUSE_RENAME
:
unsafe
.
Sizeof
(
RenameIn
{}),
FUSE_RENAME
:
unsafe
.
Sizeof
(
RenameIn
{}),
FUSE_LINK
:
unsafe
.
Sizeof
(
LinkIn
{}),
FUSE_LINK
:
unsafe
.
Sizeof
(
LinkIn
{}),
FUSE_OPEN
:
unsafe
.
Sizeof
(
OpenIn
{}),
FUSE_OPEN
:
unsafe
.
Sizeof
(
OpenIn
{}),
FUSE_READ
:
unsafe
.
Sizeof
(
ReadIn
{}),
FUSE_READ
:
unsafe
.
Sizeof
(
ReadIn
{}),
FUSE_WRITE
:
unsafe
.
Sizeof
(
WriteIn
{}),
FUSE_WRITE
:
unsafe
.
Sizeof
(
WriteIn
{}),
FUSE_RELEASE
:
unsafe
.
Sizeof
(
ReleaseIn
{}),
FUSE_RELEASE
:
unsafe
.
Sizeof
(
ReleaseIn
{}),
FUSE_FSYNC
:
unsafe
.
Sizeof
(
FsyncIn
{}),
FUSE_FSYNC
:
unsafe
.
Sizeof
(
FsyncIn
{}),
FUSE_SETXATTR
:
unsafe
.
Sizeof
(
SetXAttrIn
{}),
FUSE_SETXATTR
:
unsafe
.
Sizeof
(
SetXAttrIn
{}),
FUSE_GETXATTR
:
unsafe
.
Sizeof
(
GetXAttrIn
{}),
FUSE_GETXATTR
:
unsafe
.
Sizeof
(
GetXAttrIn
{}),
FUSE_LISTXATTR
:
unsafe
.
Sizeof
(
GetXAttrIn
{}),
FUSE_LISTXATTR
:
unsafe
.
Sizeof
(
GetXAttrIn
{}),
FUSE_FLUSH
:
unsafe
.
Sizeof
(
FlushIn
{}),
FUSE_FLUSH
:
unsafe
.
Sizeof
(
FlushIn
{}),
FUSE_INIT
:
unsafe
.
Sizeof
(
InitIn
{}),
FUSE_INIT
:
unsafe
.
Sizeof
(
InitIn
{}),
FUSE_OPENDIR
:
unsafe
.
Sizeof
(
OpenIn
{}),
FUSE_OPENDIR
:
unsafe
.
Sizeof
(
OpenIn
{}),
FUSE_READDIR
:
unsafe
.
Sizeof
(
ReadIn
{}),
FUSE_READDIR
:
unsafe
.
Sizeof
(
ReadIn
{}),
FUSE_RELEASEDIR
:
unsafe
.
Sizeof
(
ReleaseIn
{}),
FUSE_RELEASEDIR
:
unsafe
.
Sizeof
(
ReleaseIn
{}),
FUSE_FSYNCDIR
:
unsafe
.
Sizeof
(
FsyncIn
{}),
FUSE_FSYNCDIR
:
unsafe
.
Sizeof
(
FsyncIn
{}),
FUSE_ACCESS
:
unsafe
.
Sizeof
(
AccessIn
{}),
FUSE_ACCESS
:
unsafe
.
Sizeof
(
AccessIn
{}),
FUSE_CREATE
:
unsafe
.
Sizeof
(
CreateIn
{}),
FUSE_CREATE
:
unsafe
.
Sizeof
(
CreateIn
{}),
FUSE_INTERRUPT
:
unsafe
.
Sizeof
(
InterruptIn
{}),
FUSE_INTERRUPT
:
unsafe
.
Sizeof
(
InterruptIn
{}),
FUSE_BMAP
:
unsafe
.
Sizeof
(
BmapIn
{}),
FUSE_BMAP
:
unsafe
.
Sizeof
(
BmapIn
{}),
FUSE_IOCTL
:
unsafe
.
Sizeof
(
IoctlIn
{}),
FUSE_IOCTL
:
unsafe
.
Sizeof
(
IoctlIn
{}),
FUSE_POLL
:
unsafe
.
Sizeof
(
PollIn
{}),
FUSE_POLL
:
unsafe
.
Sizeof
(
PollIn
{}),
}
{
}
{
operationHandlers
[
op
]
.
InputSize
=
sz
operationHandlers
[
op
]
.
InputSize
=
sz
}
}
for
op
,
sz
:=
range
map
[
int
]
int
{
for
op
,
sz
:=
range
map
[
int
]
int
{
FUSE_LOOKUP
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_LOOKUP
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_GETATTR
:
unsafe
.
Sizeof
(
AttrOut
{}),
FUSE_GETATTR
:
unsafe
.
Sizeof
(
AttrOut
{}),
FUSE_SETATTR
:
unsafe
.
Sizeof
(
AttrOut
{}),
FUSE_SETATTR
:
unsafe
.
Sizeof
(
AttrOut
{}),
FUSE_SYMLINK
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_SYMLINK
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_MKNOD
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_MKNOD
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_MKDIR
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_MKDIR
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_LINK
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_LINK
:
unsafe
.
Sizeof
(
EntryOut
{}),
FUSE_OPEN
:
unsafe
.
Sizeof
(
OpenOut
{}),
FUSE_OPEN
:
unsafe
.
Sizeof
(
OpenOut
{}),
FUSE_WRITE
:
unsafe
.
Sizeof
(
WriteOut
{}),
FUSE_WRITE
:
unsafe
.
Sizeof
(
WriteOut
{}),
FUSE_STATFS
:
unsafe
.
Sizeof
(
StatfsOut
{}),
FUSE_STATFS
:
unsafe
.
Sizeof
(
StatfsOut
{}),
FUSE_GETXATTR
:
unsafe
.
Sizeof
(
GetXAttrOut
{}),
FUSE_GETXATTR
:
unsafe
.
Sizeof
(
GetXAttrOut
{}),
FUSE_LISTXATTR
:
unsafe
.
Sizeof
(
GetXAttrOut
{}),
FUSE_LISTXATTR
:
unsafe
.
Sizeof
(
GetXAttrOut
{}),
FUSE_INIT
:
unsafe
.
Sizeof
(
InitOut
{}),
FUSE_INIT
:
unsafe
.
Sizeof
(
InitOut
{}),
FUSE_OPENDIR
:
unsafe
.
Sizeof
(
OpenOut
{}),
FUSE_OPENDIR
:
unsafe
.
Sizeof
(
OpenOut
{}),
FUSE_CREATE
:
unsafe
.
Sizeof
(
CreateOut
{}),
FUSE_CREATE
:
unsafe
.
Sizeof
(
CreateOut
{}),
FUSE_BMAP
:
unsafe
.
Sizeof
(
BmapOut
{}),
FUSE_BMAP
:
unsafe
.
Sizeof
(
BmapOut
{}),
FUSE_IOCTL
:
unsafe
.
Sizeof
(
IoctlOut
{}),
FUSE_IOCTL
:
unsafe
.
Sizeof
(
IoctlOut
{}),
FUSE_POLL
:
unsafe
.
Sizeof
(
PollOut
{}),
FUSE_POLL
:
unsafe
.
Sizeof
(
PollOut
{}),
}
{
}
{
operationHandlers
[
op
]
.
OutputSize
=
sz
operationHandlers
[
op
]
.
OutputSize
=
sz
}
}
for
op
,
v
:=
range
map
[
int
]
string
{
for
op
,
v
:=
range
map
[
int
]
string
{
FUSE_LOOKUP
:
"FUSE_LOOKUP"
,
FUSE_LOOKUP
:
"FUSE_LOOKUP"
,
FUSE_FORGET
:
"FUSE_FORGET"
,
FUSE_FORGET
:
"FUSE_FORGET"
,
...
...
fuse/pathdebug.go
View file @
7c991e45
...
@@ -41,7 +41,7 @@ func (me *FileSystemDebug) Add(name string, callback getter) {
...
@@ -41,7 +41,7 @@ func (me *FileSystemDebug) Add(name string, callback getter) {
}
}
func
(
me
*
FileSystemDebug
)
Open
(
path
string
,
flags
uint32
)
(
fuseFile
File
,
status
Status
)
{
func
(
me
*
FileSystemDebug
)
Open
(
path
string
,
flags
uint32
)
(
fuseFile
File
,
status
Status
)
{
content
:=
me
.
getContent
(
path
)
content
:=
me
.
getContent
(
path
)
if
content
!=
nil
{
if
content
!=
nil
{
return
NewReadOnlyFile
(
content
),
OK
return
NewReadOnlyFile
(
content
),
OK
...
@@ -72,11 +72,11 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) {
...
@@ -72,11 +72,11 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) {
func
(
me
*
FileSystemDebug
)
GetAttr
(
path
string
)
(
*
Attr
,
Status
)
{
func
(
me
*
FileSystemDebug
)
GetAttr
(
path
string
)
(
*
Attr
,
Status
)
{
if
!
strings
.
HasPrefix
(
path
,
DebugDir
)
{
if
!
strings
.
HasPrefix
(
path
,
DebugDir
)
{
return
me
.
Original
.
GetAttr
(
path
)
return
me
.
Original
.
GetAttr
(
path
)
}
}
if
path
==
DebugDir
{
if
path
==
DebugDir
{
return
&
Attr
{
return
&
Attr
{
Mode
:
S_IFDIR
|
0755
,
Mode
:
S_IFDIR
|
0755
,
},
OK
},
OK
}
}
c
:=
me
.
getContent
(
path
)
c
:=
me
.
getContent
(
path
)
if
c
!=
nil
{
if
c
!=
nil
{
...
@@ -123,17 +123,16 @@ func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status St
...
@@ -123,17 +123,16 @@ func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status St
if
name
==
DebugDir
{
if
name
==
DebugDir
{
me
.
RWMutex
.
RLock
()
me
.
RWMutex
.
RLock
()
defer
me
.
RWMutex
.
RUnlock
()
defer
me
.
RWMutex
.
RUnlock
()
stream
=
make
(
chan
DirEntry
,
len
(
me
.
callbacks
))
stream
=
make
(
chan
DirEntry
,
len
(
me
.
callbacks
))
for
k
,
_
:=
range
me
.
callbacks
{
for
k
,
_
:=
range
me
.
callbacks
{
stream
<-
DirEntry
{
stream
<-
DirEntry
{
Name
:
k
,
Name
:
k
,
Mode
:
S_IFREG
,
Mode
:
S_IFREG
,
}
}
}
}
close
(
stream
)
close
(
stream
)
return
stream
,
OK
return
stream
,
OK
}
}
return
me
.
Original
.
OpenDir
(
name
)
return
me
.
Original
.
OpenDir
(
name
)
}
}
...
...
fuse/pathdebug_test.go
View file @
7c991e45
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
func
TestPathDebug
(
t
*
testing
.
T
)
{
func
TestPathDebug
(
t
*
testing
.
T
)
{
debugFs
:=
NewFileSystemDebug
()
debugFs
:=
NewFileSystemDebug
()
debugFs
.
Original
=
&
DefaultFileSystem
{}
debugFs
.
Original
=
&
DefaultFileSystem
{}
debugFs
.
Add
(
"test-entry"
,
func
()
[]
byte
{
return
[]
byte
(
"test-content"
);
})
debugFs
.
Add
(
"test-entry"
,
func
()
[]
byte
{
return
[]
byte
(
"test-content"
)
})
connector
:=
NewFileSystemConnector
(
debugFs
)
connector
:=
NewFileSystemConnector
(
debugFs
)
mountPoint
:=
MakeTempDir
()
mountPoint
:=
MakeTempDir
()
...
@@ -30,7 +30,7 @@ func TestPathDebug(t *testing.T) {
...
@@ -30,7 +30,7 @@ func TestPathDebug(t *testing.T) {
CheckSuccess
(
err
)
CheckSuccess
(
err
)
if
len
(
names
)
!=
1
||
names
[
0
]
.
Name
!=
"test-entry"
{
if
len
(
names
)
!=
1
||
names
[
0
]
.
Name
!=
"test-entry"
{
t
.
Error
(
"unexpected readdir out:"
,
names
)
t
.
Error
(
"unexpected readdir out:"
,
names
)
}
}
c
,
err
:=
ioutil
.
ReadFile
(
filepath
.
Join
(
dir
,
"test-entry"
))
c
,
err
:=
ioutil
.
ReadFile
(
filepath
.
Join
(
dir
,
"test-entry"
))
...
...
fuse/pathfilesystem.go
View file @
7c991e45
...
@@ -135,7 +135,7 @@ func (me *inode) setParent(newParent *inode) {
...
@@ -135,7 +135,7 @@ func (me *inode) setParent(newParent *inode) {
panic
(
fmt
.
Sprintf
(
"Already have an inode with same name: %v: %v"
,
me
.
Name
,
ch
))
panic
(
fmt
.
Sprintf
(
"Already have an inode with same name: %v: %v"
,
me
.
Name
,
ch
))
}
}
}
}
me
.
Parent
.
Children
[
me
.
Name
]
=
me
me
.
Parent
.
Children
[
me
.
Name
]
=
me
}
}
}
}
...
@@ -171,14 +171,14 @@ type FileSystemConnector struct {
...
@@ -171,14 +171,14 @@ type FileSystemConnector struct {
treeLock
sync
.
RWMutex
treeLock
sync
.
RWMutex
// Invariants: see the verify() method.
// Invariants: see the verify() method.
inodeMap
map
[
uint64
]
*
inode
inodeMap
map
[
uint64
]
*
inode
rootNode
*
inode
rootNode
*
inode
// Open files/directories.
// Open files/directories.
openFiles
map
[
uint64
]
*
interfaceBridge
openFiles
map
[
uint64
]
*
interfaceBridge
// Protects openFiles and OpenCount in all of the nodes.
// Protects openFiles and OpenCount in all of the nodes.
fileLock
sync
.
RWMutex
fileLock
sync
.
RWMutex
}
}
type
interfaceBridge
struct
{
type
interfaceBridge
struct
{
...
@@ -215,7 +215,7 @@ func (me *FileSystemConnector) registerFile(node *inode, f interface{}) uint64 {
...
@@ -215,7 +215,7 @@ func (me *FileSystemConnector) registerFile(node *inode, f interface{}) uint64 {
defer
me
.
fileLock
.
Unlock
()
defer
me
.
fileLock
.
Unlock
()
b
:=
&
interfaceBridge
{
b
:=
&
interfaceBridge
{
Iface
:
f
,
Iface
:
f
,
}
}
h
:=
uint64
(
uintptr
(
unsafe
.
Pointer
(
b
)))
h
:=
uint64
(
uintptr
(
unsafe
.
Pointer
(
b
)))
_
,
ok
:=
me
.
openFiles
[
h
]
_
,
ok
:=
me
.
openFiles
[
h
]
...
@@ -279,7 +279,7 @@ func (me *FileSystemConnector) newInode(root bool, isDir bool) *inode {
...
@@ -279,7 +279,7 @@ func (me *FileSystemConnector) newInode(root bool, isDir bool) *inode {
if
isDir
{
if
isDir
{
data
.
Children
=
make
(
map
[
string
]
*
inode
,
initDirSize
)
data
.
Children
=
make
(
map
[
string
]
*
inode
,
initDirSize
)
}
}
return
data
return
data
}
}
...
@@ -449,12 +449,12 @@ func (me *FileSystemConnector) Unmount(path string) Status {
...
@@ -449,12 +449,12 @@ func (me *FileSystemConnector) Unmount(path string) Status {
me
.
fileLock
.
Lock
()
me
.
fileLock
.
Lock
()
unmountError
:=
OK
unmountError
:=
OK
mount
:=
node
.
mount
mount
:=
node
.
mount
if
mount
==
nil
||
mount
.
unmountPending
{
if
mount
==
nil
||
mount
.
unmountPending
{
unmountError
=
EINVAL
unmountError
=
EINVAL
}
}
// don't use defer: we don't want to call out to
// don't use defer: we don't want to call out to
// mount.fs.Unmount() with lock held.
// mount.fs.Unmount() with lock held.
if
unmountError
==
OK
&&
(
node
.
totalOpenCount
()
>
0
||
node
.
totalMountCount
()
>
1
)
{
if
unmountError
==
OK
&&
(
node
.
totalOpenCount
()
>
0
||
node
.
totalMountCount
()
>
1
)
{
...
@@ -472,7 +472,7 @@ func (me *FileSystemConnector) Unmount(path string) Status {
...
@@ -472,7 +472,7 @@ func (me *FileSystemConnector) Unmount(path string) Status {
if
me
.
Debug
{
if
me
.
Debug
{
log
.
Println
(
"Unmount: "
,
mount
)
log
.
Println
(
"Unmount: "
,
mount
)
}
}
mount
.
fs
.
Unmount
()
mount
.
fs
.
Unmount
()
}
}
return
unmountError
return
unmountError
...
@@ -484,7 +484,7 @@ func (me *FileSystemConnector) GetPath(nodeid uint64) (path string, mount *mount
...
@@ -484,7 +484,7 @@ func (me *FileSystemConnector) GetPath(nodeid uint64) (path string, mount *mount
// Need to lock because renames create invalid states.
// Need to lock because renames create invalid states.
me
.
treeLock
.
RLock
()
me
.
treeLock
.
RLock
()
defer
me
.
treeLock
.
RUnlock
()
defer
me
.
treeLock
.
RUnlock
()
p
,
m
:=
n
.
GetPath
()
p
,
m
:=
n
.
GetPath
()
return
p
,
m
,
n
return
p
,
m
,
n
}
}
fuse/pathops.go
View file @
7c991e45
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"path/filepath"
"path/filepath"
"time"
"time"
)
)
func
NewFileSystemConnector
(
fs
FileSystem
)
(
out
*
FileSystemConnector
)
{
func
NewFileSystemConnector
(
fs
FileSystem
)
(
out
*
FileSystemConnector
)
{
out
=
EmptyFileSystemConnector
()
out
=
EmptyFileSystemConnector
()
...
@@ -66,7 +66,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
...
@@ -66,7 +66,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
data
.
LookupCount
+=
lookupCount
data
.
LookupCount
+=
lookupCount
out
=
&
EntryOut
{
out
=
&
EntryOut
{
NodeId
:
data
.
NodeId
,
NodeId
:
data
.
NodeId
,
Generation
:
1
,
// where to get the generation?
Generation
:
1
,
// where to get the generation?
}
}
SplitNs
(
me
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
SplitNs
(
me
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
...
@@ -92,7 +92,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
...
@@ -92,7 +92,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
}
}
out
=
&
AttrOut
{
out
=
&
AttrOut
{
Attr
:
*
attr
,
Attr
:
*
attr
,
}
}
out
.
Attr
.
Ino
=
header
.
NodeId
out
.
Attr
.
Ino
=
header
.
NodeId
SplitNs
(
me
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
SplitNs
(
me
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
...
@@ -112,7 +112,7 @@ func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags u
...
@@ -112,7 +112,7 @@ func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags u
}
}
de
:=
&
Dir
{
de
:=
&
Dir
{
stream
:
stream
,
stream
:
stream
,
}
}
h
:=
me
.
registerFile
(
node
,
de
)
h
:=
me
.
registerFile
(
node
,
de
)
...
@@ -164,7 +164,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
...
@@ -164,7 +164,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
mount
.
fs
.
Truncate
(
fullPath
,
input
.
Size
)
mount
.
fs
.
Truncate
(
fullPath
,
input
.
Size
)
}
}
if
err
==
OK
&&
(
input
.
Valid
&
FATTR_ATIME
!=
0
||
input
.
Valid
&
FATTR_MTIME
!=
0
)
{
if
err
==
OK
&&
(
input
.
Valid
&
FATTR_ATIME
!=
0
||
input
.
Valid
&
FATTR_MTIME
!=
0
)
{
err
=
mount
.
fs
.
Utimens
(
fullPath
,
err
=
mount
.
fs
.
Utimens
(
fullPath
,
uint64
(
input
.
Atime
*
1e9
)
+
uint64
(
input
.
Atimensec
),
uint64
(
input
.
Atime
*
1e9
)
+
uint64
(
input
.
Atimensec
),
uint64
(
input
.
Mtime
*
1e9
)
+
uint64
(
input
.
Mtimensec
))
uint64
(
input
.
Mtime
*
1e9
)
+
uint64
(
input
.
Mtimensec
))
...
@@ -393,4 +393,3 @@ func (me *FileSystemConnector) Read(input *ReadIn, bp *BufferPool) ([]byte, Stat
...
@@ -393,4 +393,3 @@ func (me *FileSystemConnector) Read(input *ReadIn, bp *BufferPool) ([]byte, Stat
f
:=
me
.
getFile
(
input
.
Fh
)
f
:=
me
.
getFile
(
input
.
Fh
)
return
f
.
Read
(
input
,
bp
)
return
f
.
Read
(
input
,
bp
)
}
}
fuse/types.go
View file @
7c991e45
...
@@ -532,10 +532,10 @@ type RawFileSystem interface {
...
@@ -532,10 +532,10 @@ type RawFileSystem interface {
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
/*
/*
// unimplemented.
// unimplemented.
Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status)
Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status)
Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status)
Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status)
Poll(header *InHeader, input *PollIn) (out *PollOut, code Status)
Poll(header *InHeader, input *PollIn) (out *PollOut, code Status)
*/
*/
// File handling.
// File handling.
...
...
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