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
13419d09
Commit
13419d09
authored
Mar 23, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use file.Write() for returning results, if possible. Simplify
serialization code.
parent
55e582f4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
fuse/fuse.go
fuse/fuse.go
+23
-15
No files found.
fuse/fuse.go
View file @
13419d09
...
...
@@ -37,8 +37,9 @@ type fuseRequest struct {
status
Status
flatData
[]
byte
// The stuff we send back to the kernel.
serialized
[][]
byte
// Header+data for what we send back to the kernel.
// May be followed by flatData.
output
[]
byte
// Start timestamp for timing info.
startNs
int64
...
...
@@ -192,14 +193,21 @@ func (me *MountState) Error(err os.Error) {
}
func
(
me
*
MountState
)
Write
(
req
*
fuseRequest
)
{
if
req
.
serialized
==
nil
{
if
req
.
output
==
nil
{
return
}
_
,
err
:=
Writev
(
me
.
mountFile
.
Fd
(),
req
.
serialized
)
var
err
os
.
Error
if
req
.
flatData
==
nil
{
_
,
err
=
me
.
mountFile
.
Write
(
req
.
output
)
}
else
{
_
,
err
=
Writev
(
me
.
mountFile
.
Fd
(),
[][]
byte
{
req
.
output
,
req
.
flatData
})
}
if
err
!=
nil
{
me
.
Error
(
os
.
NewError
(
fmt
.
Sprintf
(
"writer: Writev %v failed, err: %v. Opcode: %v"
,
req
.
serialized
,
err
,
operationName
(
req
.
inHeader
.
Opcode
))))
req
.
output
,
err
,
operationName
(
req
.
inHeader
.
Opcode
))))
}
}
...
...
@@ -477,13 +485,11 @@ func (me *MountState) dispatch(req *fuseRequest) {
}
func
serialize
(
req
*
fuseRequest
,
debug
bool
)
{
out_data
:=
make
([]
byte
,
0
)
b
:=
new
(
bytes
.
Buffer
)
headerBytes
:=
make
([]
byte
,
SizeOfOutHeader
)
b
uf
:=
bytes
.
NewBuffer
(
headerBytes
)
if
req
.
data
!=
nil
&&
req
.
status
==
OK
{
err
:=
binary
.
Write
(
b
,
binary
.
LittleEndian
,
req
.
data
)
if
err
==
nil
{
out_data
=
b
.
Bytes
()
}
else
{
err
:=
binary
.
Write
(
buf
,
binary
.
LittleEndian
,
req
.
data
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"Can't serialize out: %v, err: %v"
,
req
.
data
,
err
))
}
}
...
...
@@ -491,15 +497,17 @@ func serialize(req *fuseRequest, debug bool) {
var
hOut
OutHeader
hOut
.
Unique
=
req
.
inHeader
.
Unique
hOut
.
Status
=
-
req
.
status
hOut
.
Length
=
uint32
(
len
(
out_data
)
+
SizeOfOutHeader
+
len
(
req
.
flatData
))
hOut
.
Length
=
uint32
(
buf
.
Len
()
+
len
(
req
.
flatData
))
data
:=
buf
.
Bytes
()
b
=
new
(
bytes
.
Buffer
)
err
:=
binary
.
Write
(
b
,
binary
.
LittleEndian
,
&
hOut
)
b
uf
=
bytes
.
NewBuffer
(
data
[
:
0
]
)
err
:=
binary
.
Write
(
b
uf
,
binary
.
LittleEndian
,
&
hOut
)
if
err
!=
nil
{
panic
(
"Can't serialize OutHeader"
)
}
req
.
serialized
=
[][]
byte
{
b
.
Bytes
(),
out_data
,
req
.
flatData
}
req
.
output
=
data
if
debug
{
val
:=
fmt
.
Sprintf
(
"%v"
,
req
.
data
)
max
:=
1024
...
...
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