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
Kirill Smelkov
go-fuse
Commits
d397cca6
Commit
d397cca6
authored
Apr 30, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move debug into request methods.
parent
01d86c93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
33 deletions
+53
-33
fuse/fuse.go
fuse/fuse.go
+46
-21
fuse/opcode.go
fuse/opcode.go
+7
-12
No files found.
fuse/fuse.go
View file @
d397cca6
...
...
@@ -57,6 +57,50 @@ func (me *request) filenames(count int) []string {
return
nameStrings
}
func
(
me
*
request
)
InputDebug
(
h
*
operationHandler
)
string
{
var
val
interface
{}
if
h
.
DecodeIn
!=
nil
{
val
=
h
.
DecodeIn
(
me
.
inData
)
}
else
{
val
=
""
}
var
names
interface
{}
if
h
.
FileNames
>
0
{
names
=
me
.
filenames
(
h
.
FileNames
)
}
else
{
names
=
""
}
return
fmt
.
Sprintf
(
"Dispatch: %v, NodeId: %v. Data: %v Names: %v"
,
me
.
inHeader
.
opcode
,
me
.
inHeader
.
NodeId
,
val
,
names
)
}
func
(
me
*
request
)
OutputDebug
(
h
*
operationHandler
)
string
{
var
val
interface
{}
if
h
.
DecodeOut
!=
nil
{
val
=
h
.
DecodeOut
(
me
.
outData
)
}
dataStr
:=
""
if
val
!=
nil
{
dataStr
=
fmt
.
Sprintf
(
"%v"
,
val
)
}
max
:=
1024
if
len
(
dataStr
)
>
max
{
dataStr
=
dataStr
[
:
max
]
+
fmt
.
Sprintf
(
" ...trimmed (response size %d)"
,
len
(
me
.
outHeaderBytes
))
}
flatStr
:=
""
if
len
(
me
.
flatData
)
>
0
{
flatStr
=
fmt
.
Sprintf
(
" %d bytes data
\n
"
,
len
(
me
.
flatData
))
}
return
fmt
.
Sprintf
(
"Serialize: %v code: %v value: %v%v"
,
me
.
inHeader
.
opcode
,
me
.
status
,
dataStr
,
flatStr
)
}
////////////////////////////////////////////////////////////////
// State related to this mount point.
type
MountState
struct
{
...
...
@@ -300,15 +344,7 @@ func (me *MountState) handle(req *request) {
func
(
me
*
MountState
)
dispatch
(
req
*
request
,
handler
*
operationHandler
)
{
if
me
.
Debug
{
handler
:=
getHandler
(
req
.
inHeader
.
opcode
)
var
names
interface
{}
if
handler
.
FileNames
>
0
{
names
=
req
.
filenames
(
handler
.
FileNames
)
}
else
{
names
=
""
}
log
.
Printf
(
"Dispatch: %v, NodeId: %v %v
\n
"
,
operationName
(
req
.
inHeader
.
opcode
),
req
.
inHeader
.
NodeId
,
names
)
log
.
Println
(
req
.
InputDebug
(
handler
))
}
handler
.
Func
(
me
,
req
)
}
...
...
@@ -335,17 +371,6 @@ func serialize(req *request, handler *operationHandler, debug bool) {
copy
(
req
.
outHeaderBytes
[
sizeOfOutHeader
:
],
asSlice
(
req
.
outData
,
dataLength
))
if
debug
{
val
:=
fmt
.
Sprintf
(
"%v"
,
replyString
(
req
.
inHeader
.
opcode
,
req
.
outData
))
max
:=
1024
if
len
(
val
)
>
max
{
val
=
val
[
:
max
]
+
fmt
.
Sprintf
(
" ...trimmed (response size %d)"
,
outHeader
.
Length
)
}
msg
:=
""
if
len
(
req
.
flatData
)
>
0
{
msg
=
fmt
.
Sprintf
(
" flat: %d
\n
"
,
len
(
req
.
flatData
))
}
log
.
Printf
(
"Serialize: %v code: %v value: %v%v"
,
operationName
(
req
.
inHeader
.
opcode
),
req
.
status
,
val
,
msg
)
log
.
Println
(
req
.
OutputDebug
(
handler
))
}
}
fuse/opcode.go
View file @
d397cca6
...
...
@@ -8,6 +8,7 @@ import (
)
var
_
=
log
.
Printf
var
_
=
fmt
.
Printf
type
opcode
int
...
...
@@ -54,17 +55,6 @@ const (
OPCODE_COUNT
=
opcode
(
41
)
)
func
replyString
(
op
opcode
,
ptr
unsafe
.
Pointer
)
string
{
h
:=
getHandler
(
op
)
var
val
interface
{}
if
h
.
DecodeOut
!=
nil
{
val
=
h
.
DecodeOut
(
ptr
)
}
if
val
!=
nil
{
return
fmt
.
Sprintf
(
"%v"
,
val
)
}
return
""
}
////////////////////////////////////////////////////////////////
...
...
@@ -474,7 +464,12 @@ func init() {
}
{
operationHandlers
[
op
]
.
DecodeOut
=
f
}
for
op
,
f
:=
range
map
[
opcode
]
castPointerFunc
{
_OP_GETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
GetAttrIn
)(
ptr
)
},
_OP_SETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
SetAttrIn
)(
ptr
)
},
}
{
operationHandlers
[
op
]
.
DecodeIn
=
f
}
for
op
,
count
:=
range
map
[
opcode
]
int
{
_OP_LOOKUP
:
1
,
_OP_RENAME
:
2
,
...
...
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