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
Hide 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 {
...
@@ -37,8 +37,9 @@ type fuseRequest struct {
status
Status
status
Status
flatData
[]
byte
flatData
[]
byte
// The stuff we send back to the kernel.
// Header+data for what we send back to the kernel.
serialized
[][]
byte
// May be followed by flatData.
output
[]
byte
// Start timestamp for timing info.
// Start timestamp for timing info.
startNs
int64
startNs
int64
...
@@ -192,14 +193,21 @@ func (me *MountState) Error(err os.Error) {
...
@@ -192,14 +193,21 @@ func (me *MountState) Error(err os.Error) {
}
}
func
(
me
*
MountState
)
Write
(
req
*
fuseRequest
)
{
func
(
me
*
MountState
)
Write
(
req
*
fuseRequest
)
{
if
req
.
serialized
==
nil
{
if
req
.
output
==
nil
{
return
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
{
if
err
!=
nil
{
me
.
Error
(
os
.
NewError
(
fmt
.
Sprintf
(
"writer: Writev %v failed, err: %v. Opcode: %v"
,
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) {
...
@@ -477,13 +485,11 @@ func (me *MountState) dispatch(req *fuseRequest) {
}
}
func
serialize
(
req
*
fuseRequest
,
debug
bool
)
{
func
serialize
(
req
*
fuseRequest
,
debug
bool
)
{
out_data
:=
make
([]
byte
,
0
)
headerBytes
:=
make
([]
byte
,
SizeOfOutHeader
)
b
:=
new
(
bytes
.
Buffer
)
b
uf
:=
bytes
.
NewBuffer
(
headerBytes
)
if
req
.
data
!=
nil
&&
req
.
status
==
OK
{
if
req
.
data
!=
nil
&&
req
.
status
==
OK
{
err
:=
binary
.
Write
(
b
,
binary
.
LittleEndian
,
req
.
data
)
err
:=
binary
.
Write
(
buf
,
binary
.
LittleEndian
,
req
.
data
)
if
err
==
nil
{
if
err
!=
nil
{
out_data
=
b
.
Bytes
()
}
else
{
panic
(
fmt
.
Sprintf
(
"Can't serialize out: %v, err: %v"
,
req
.
data
,
err
))
panic
(
fmt
.
Sprintf
(
"Can't serialize out: %v, err: %v"
,
req
.
data
,
err
))
}
}
}
}
...
@@ -491,15 +497,17 @@ func serialize(req *fuseRequest, debug bool) {
...
@@ -491,15 +497,17 @@ func serialize(req *fuseRequest, debug bool) {
var
hOut
OutHeader
var
hOut
OutHeader
hOut
.
Unique
=
req
.
inHeader
.
Unique
hOut
.
Unique
=
req
.
inHeader
.
Unique
hOut
.
Status
=
-
req
.
status
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
)
b
uf
=
bytes
.
NewBuffer
(
data
[
:
0
]
)
err
:=
binary
.
Write
(
b
,
binary
.
LittleEndian
,
&
hOut
)
err
:=
binary
.
Write
(
b
uf
,
binary
.
LittleEndian
,
&
hOut
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"Can't serialize OutHeader"
)
panic
(
"Can't serialize OutHeader"
)
}
}
req
.
serialized
=
[][]
byte
{
b
.
Bytes
(),
out_data
,
req
.
flatData
}
req
.
output
=
data
if
debug
{
if
debug
{
val
:=
fmt
.
Sprintf
(
"%v"
,
req
.
data
)
val
:=
fmt
.
Sprintf
(
"%v"
,
req
.
data
)
max
:=
1024
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