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
bfe98501
Commit
bfe98501
authored
Apr 22, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganize dispatch() and handle().
parent
b5f9b2fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
19 deletions
+29
-19
fuse/fuse.go
fuse/fuse.go
+29
-19
No files found.
fuse/fuse.go
View file @
bfe98501
...
...
@@ -250,48 +250,58 @@ func (me *MountState) Loop(threaded bool) {
me
.
mountFile
.
Close
()
}
func
(
me
*
MountState
)
handle
(
req
*
request
)
{
defer
me
.
discardRequest
(
req
)
req
.
dispatchNs
=
time
.
Nanoseconds
()
func
(
me
*
MountState
)
chopMessage
(
req
*
request
)
bool
{
inHSize
:=
unsafe
.
Sizeof
(
InHeader
{})
if
len
(
req
.
inputBuf
)
<
inHSize
{
me
.
Error
(
os
.
NewError
(
fmt
.
Sprintf
(
"Short read for input header: %v"
,
req
.
inputBuf
)))
return
return
false
}
req
.
inHeader
=
(
*
InHeader
)(
unsafe
.
Pointer
(
&
req
.
inputBuf
[
0
]))
req
.
arg
=
req
.
inputBuf
[
inHSize
:
]
me
.
dispatch
(
req
)
// 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]]
// failed, err: writev: no such file or directory
if
req
.
inHeader
.
Opcode
!=
FUSE_FORGET
{
serialize
(
req
,
me
.
Debug
)
req
.
preWriteNs
=
time
.
Nanoseconds
()
me
.
Write
(
req
)
}
}
func
(
me
*
MountState
)
dispatch
(
req
*
request
)
{
argSize
,
ok
:=
inputSize
(
req
.
inHeader
.
Opcode
)
if
!
ok
{
log
.
Println
(
"Unknown opcode %d (input)"
,
req
.
inHeader
.
Opcode
)
req
.
status
=
ENOSYS
return
return
true
}
if
len
(
req
.
arg
)
<
argSize
{
log
.
Println
(
"Short read for %v: %v"
,
req
.
inHeader
.
Opcode
,
req
.
arg
)
req
.
status
=
EIO
return
return
true
}
if
argSize
>
0
{
req
.
inData
=
unsafe
.
Pointer
(
&
req
.
arg
[
0
])
req
.
arg
=
req
.
arg
[
argSize
:
]
}
return
true
}
func
(
me
*
MountState
)
handle
(
req
*
request
)
{
defer
me
.
discardRequest
(
req
)
if
!
me
.
chopMessage
(
req
)
{
return
}
if
req
.
status
==
OK
{
me
.
dispatch
(
req
)
}
// 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]]
// failed, err: writev: no such file or directory
if
req
.
inHeader
.
Opcode
!=
FUSE_FORGET
{
serialize
(
req
,
me
.
Debug
)
req
.
preWriteNs
=
time
.
Nanoseconds
()
me
.
Write
(
req
)
}
}
func
(
me
*
MountState
)
dispatch
(
req
*
request
)
{
req
.
dispatchNs
=
time
.
Nanoseconds
()
f
:=
lookupOperation
(
req
.
inHeader
.
Opcode
)
if
f
==
nil
{
...
...
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