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
384f32c2
Commit
384f32c2
authored
Jul 28, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connection.kernelResponseForOp
parent
5238806c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
45 deletions
+44
-45
conversions.go
conversions.go
+44
-45
No files found.
conversions.go
View file @
384f32c2
...
...
@@ -419,29 +419,28 @@ func (c *Connection) kernelResponse(
// Like kernelResponse, but assumes the user replied with a nil error to the
// op. Returns a nil response if no response is required.
func
kernelResponseForOp
(
op
interface
{},
protocol
fusekernel
.
Protocol
)
(
b
buffer
.
OutMessage
)
{
func
(
c
*
Connection
)
kernelResponseForOp
(
op
interface
{})
(
m
*
buffer
.
OutMessage
)
{
// Create the appropriate output message
switch
o
:=
op
.
(
type
)
{
case
*
fuseops
.
LookUpInodeOp
:
size
:=
fusekernel
.
EntryOutSize
(
protocol
)
b
=
buffer
.
NewOutMessage
(
size
)
out
:=
(
*
fusekernel
.
EntryOut
)(
b
.
Grow
(
size
))
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
case
*
fuseops
.
GetInodeAttributesOp
:
size
:=
fusekernel
.
AttrOutSize
(
protocol
)
b
=
buffer
.
NewOutMessage
(
size
)
out
:=
(
*
fusekernel
.
AttrOut
)(
b
.
Grow
(
size
))
size
:=
fusekernel
.
AttrOutSize
(
c
.
protocol
)
m
=
c
.
getOutMessage
(
)
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
(
protocol
)
b
=
buffer
.
NewOutMessage
(
size
)
out
:=
(
*
fusekernel
.
AttrOut
)(
b
.
Grow
(
size
))
size
:=
fusekernel
.
AttrOutSize
(
c
.
protocol
)
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
AttrOut
)(
m
.
Grow
(
size
))
out
.
AttrValid
,
out
.
AttrValidNsec
=
convertExpirationTime
(
o
.
AttributesExpiration
)
convertAttributes
(
o
.
Inode
,
&
o
.
Attributes
,
&
out
.
Attr
)
...
...
@@ -450,85 +449,85 @@ func kernelResponseForOp(
// No response.
case
*
fuseops
.
MkDirOp
:
size
:=
fusekernel
.
EntryOutSize
(
protocol
)
b
=
buffer
.
NewOutMessage
(
size
)
out
:=
(
*
fusekernel
.
EntryOut
)(
b
.
Grow
(
size
))
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
case
*
fuseops
.
CreateFileOp
:
eSize
:=
fusekernel
.
EntryOutSize
(
protocol
)
b
=
buffer
.
NewOutMessage
(
eSize
+
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})
)
eSize
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
m
=
c
.
getOutMessage
(
)
e
:=
(
*
fusekernel
.
EntryOut
)(
b
.
Grow
(
eSize
))
e
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
eSize
))
convertChildInodeEntry
(
&
o
.
Entry
,
e
)
oo
:=
(
*
fusekernel
.
OpenOut
)(
b
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})))
oo
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})))
oo
.
Fh
=
uint64
(
o
.
Handle
)
case
*
fuseops
.
CreateSymlinkOp
:
size
:=
fusekernel
.
EntryOutSize
(
protocol
)
b
=
buffer
.
NewOutMessage
(
size
)
out
:=
(
*
fusekernel
.
EntryOut
)(
b
.
Grow
(
size
))
size
:=
fusekernel
.
EntryOutSize
(
c
.
protocol
)
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
EntryOut
)(
m
.
Grow
(
size
))
convertChildInodeEntry
(
&
o
.
Entry
,
out
)
case
*
fuseops
.
RenameOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
RmDirOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
UnlinkOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
OpenDirOp
:
b
=
buffer
.
NewOutMessage
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})
)
out
:=
(
*
fusekernel
.
OpenOut
)(
b
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})))
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})))
out
.
Fh
=
uint64
(
o
.
Handle
)
case
*
fuseops
.
ReadDirOp
:
b
=
buffer
.
NewOutMessage
(
uintptr
(
len
(
o
.
Data
))
)
b
.
Append
(
o
.
Data
)
m
=
c
.
getOutMessage
(
)
m
.
Append
(
o
.
Data
)
case
*
fuseops
.
ReleaseDirHandleOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
OpenFileOp
:
b
=
buffer
.
NewOutMessage
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})
)
out
:=
(
*
fusekernel
.
OpenOut
)(
b
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})))
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
OpenOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
OpenOut
{})))
out
.
Fh
=
uint64
(
o
.
Handle
)
case
*
fuseops
.
ReadFileOp
:
b
=
buffer
.
NewOutMessage
(
uintptr
(
len
(
o
.
Data
))
)
b
.
Append
(
o
.
Data
)
m
=
c
.
getOutMessage
(
)
m
.
Append
(
o
.
Data
)
case
*
fuseops
.
WriteFileOp
:
b
=
buffer
.
NewOutMessage
(
unsafe
.
Sizeof
(
fusekernel
.
WriteOut
{})
)
out
:=
(
*
fusekernel
.
WriteOut
)(
b
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
WriteOut
{})))
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
WriteOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
WriteOut
{})))
out
.
Size
=
uint32
(
len
(
o
.
Data
))
case
*
fuseops
.
SyncFileOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
FlushFileOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
ReleaseFileHandleOp
:
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
case
*
fuseops
.
ReadSymlinkOp
:
b
=
buffer
.
NewOutMessage
(
uintptr
(
len
(
o
.
Target
))
)
b
.
AppendString
(
o
.
Target
)
m
=
c
.
getOutMessage
(
)
m
.
AppendString
(
o
.
Target
)
case
*
statFSOp
:
b
=
buffer
.
NewOutMessage
(
unsafe
.
Sizeof
(
fusekernel
.
StatfsOut
{})
)
b
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
StatfsOut
{}))
m
=
c
.
getOutMessage
(
)
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
StatfsOut
{}))
case
*
interruptOp
:
// No response.
case
*
initOp
:
b
=
buffer
.
NewOutMessage
(
unsafe
.
Sizeof
(
fusekernel
.
InitOut
{})
)
out
:=
(
*
fusekernel
.
InitOut
)(
b
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
InitOut
{})))
m
=
c
.
getOutMessage
(
)
out
:=
(
*
fusekernel
.
InitOut
)(
m
.
Grow
(
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