Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
Kirill Smelkov
jacobsa-fuse
Commits
95e4d8b1
Commit
95e4d8b1
authored
Dec 19, 2016
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversions.go: use the new buffer API.
parent
0cd689f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
conversions.go
conversions.go
+18
-18
No files found.
conversions.go
View file @
95e4d8b1
...
...
@@ -279,7 +279,7 @@ func convertInMessage(
o
=
to
readSize
:=
int
(
in
.
Size
)
p
:=
outMsg
.
GrowNoZero
(
uintptr
(
readSize
)
)
p
:=
outMsg
.
GrowNoZero
(
readSize
)
if
p
==
nil
{
err
=
fmt
.
Errorf
(
"Can't grow for %d-byte read"
,
readSize
)
return
...
...
@@ -305,7 +305,7 @@ func convertInMessage(
o
=
to
readSize
:=
int
(
in
.
Size
)
p
:=
outMsg
.
GrowNoZero
(
uintptr
(
readSize
)
)
p
:=
outMsg
.
GrowNoZero
(
readSize
)
if
p
==
nil
{
err
=
fmt
.
Errorf
(
"Can't grow for %d-byte read"
,
readSize
)
return
...
...
@@ -469,7 +469,7 @@ func (c *Connection) kernelResponse(
// the header, because on OS X the kernel otherwise returns EINVAL when we
// attempt to write an error response with a length that extends beyond the
// header.
m
.
ShrinkTo
(
buffer
.
OutMessage
Initial
Size
)
m
.
ShrinkTo
(
buffer
.
OutMessage
Header
Size
)
}
// Otherwise, fill in the rest of the response.
...
...
@@ -489,45 +489,45 @@ func (c *Connection) kernelResponseForOp(
// Create the appropriate output message
switch
o
:=
op
.
(
type
)
{
case
*
fuseops
.
LookUpInodeOp
:
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
size
:=
int
(
fusekernel
.
EntryOutSize
(
c
.
protocol
)
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
case
*
fuseops
.
GetInodeAttributesOp
:
size
:=
fusekernel
.
AttrOutSize
(
c
.
protocol
)
size
:=
int
(
fusekernel
.
AttrOutSize
(
c
.
protocol
)
)
out
:=
(
*
fusekernel
.
AttrOut
)(
m
.
Grow
(
size
))
out
.
AttrValid
,
out
.
AttrValidNsec
=
convertExpirationTime
(
o
.
AttributesExpiration
)
convertAttributes
(
o
.
Inode
,
&
o
.
Attributes
,
&
out
.
Attr
)
case
*
fuseops
.
SetInodeAttributesOp
:
size
:=
fusekernel
.
AttrOutSize
(
c
.
protocol
)
size
:=
int
(
fusekernel
.
AttrOutSize
(
c
.
protocol
)
)
out
:=
(
*
fusekernel
.
AttrOut
)(
m
.
Grow
(
size
))
out
.
AttrValid
,
out
.
AttrValidNsec
=
convertExpirationTime
(
o
.
AttributesExpiration
)
convertAttributes
(
o
.
Inode
,
&
o
.
Attributes
,
&
out
.
Attr
)
case
*
fuseops
.
MkDirOp
:
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
size
:=
int
(
fusekernel
.
EntryOutSize
(
c
.
protocol
)
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
case
*
fuseops
.
MkNodeOp
:
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
size
:=
int
(
fusekernel
.
EntryOutSize
(
c
.
protocol
)
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
case
*
fuseops
.
CreateFileOp
:
eSize
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
eSize
:=
int
(
fusekernel
.
EntryOutSize
(
c
.
protocol
)
)
e
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
eSize
))
convertChildInodeEntry
(
&
o
.
Entry
,
e
)
oo
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{}
)))
oo
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
int
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})
)))
oo
.
Fh
=
uint64
(
o
.
Handle
)
case
*
fuseops
.
CreateSymlinkOp
:
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
size
:=
int
(
fusekernel
.
EntryOutSize
(
c
.
protocol
)
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
...
...
@@ -541,20 +541,20 @@ func (c *Connection) kernelResponseForOp(
// Empty response
case
*
fuseops
.
OpenDirOp
:
out
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{}
)))
out
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
int
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})
)))
out
.
Fh
=
uint64
(
o
.
Handle
)
case
*
fuseops
.
ReadDirOp
:
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m
.
ShrinkTo
(
buffer
.
OutMessage
InitialSize
+
uintptr
(
o
.
BytesRead
)
)
m
.
ShrinkTo
(
buffer
.
OutMessage
HeaderSize
+
o
.
BytesRead
)
case
*
fuseops
.
ReleaseDirHandleOp
:
// Empty response
case
*
fuseops
.
OpenFileOp
:
out
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{}
)))
out
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
int
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})
)))
out
.
Fh
=
uint64
(
o
.
Handle
)
if
o
.
KeepPageCache
{
...
...
@@ -565,10 +565,10 @@ func (c *Connection) kernelResponseForOp(
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m
.
ShrinkTo
(
buffer
.
OutMessage
InitialSize
+
uintptr
(
o
.
BytesRead
)
)
m
.
ShrinkTo
(
buffer
.
OutMessage
HeaderSize
+
o
.
BytesRead
)
case
*
fuseops
.
WriteFileOp
:
out
:=
(
*
fusekernel
.
WriteOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
WriteOut
{}
)))
out
:=
(
*
fusekernel
.
WriteOut
)(
m
.
Grow
(
int
(
unsafe
.
Sizeof
(
fusekernel
.
WriteOut
{})
)))
out
.
Size
=
uint32
(
len
(
o
.
Data
))
case
*
fuseops
.
SyncFileOp
:
...
...
@@ -584,7 +584,7 @@ func (c *Connection) kernelResponseForOp(
m
.
AppendString
(
o
.
Target
)
case
*
fuseops
.
StatFSOp
:
out
:=
(
*
fusekernel
.
StatfsOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
StatfsOut
{}
)))
out
:=
(
*
fusekernel
.
StatfsOut
)(
m
.
Grow
(
int
(
unsafe
.
Sizeof
(
fusekernel
.
StatfsOut
{})
)))
out
.
St
.
Blocks
=
o
.
Blocks
out
.
St
.
Bfree
=
o
.
BlocksFree
out
.
St
.
Bavail
=
o
.
BlocksAvailable
...
...
@@ -620,7 +620,7 @@ func (c *Connection) kernelResponseForOp(
out
.
St
.
Frsize
=
o
.
BlockSize
case
*
initOp
:
out
:=
(
*
fusekernel
.
InitOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
InitOut
{}
)))
out
:=
(
*
fusekernel
.
InitOut
)(
m
.
Grow
(
int
(
unsafe
.
Sizeof
(
fusekernel
.
InitOut
{})
)))
out
.
Major
=
o
.
Library
.
Major
out
.
Minor
=
o
.
Library
.
Minor
...
...
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