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
5c05a7c0
Commit
5c05a7c0
authored
Aug 06, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored describeRequest.
parent
41ea2b75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
14 deletions
+30
-14
debug.go
debug.go
+30
-14
No files found.
debug.go
View file @
5c05a7c0
...
...
@@ -17,27 +17,43 @@ package fuse
import
(
"fmt"
"reflect"
"strings"
)
func
describeRequest
(
op
interface
{})
(
s
string
)
{
// Handle special cases with custom formatting.
switch
typed
:=
op
.
(
type
)
{
case
*
interruptOp
:
s
=
fmt
.
Sprintf
(
"interruptOp(fuseid=0x%08x)"
,
typed
.
FuseID
)
return
}
// Decide on the name of the given op.
func
opName
(
op
interface
{})
string
{
// We expect all ops to be pointers.
t
:=
reflect
.
TypeOf
(
op
)
.
Elem
()
// Strip the "Op" from "FooOp".
return
strings
.
TrimSuffix
(
t
.
Name
(),
"Op"
)
}
func
describeRequest
(
op
interface
{})
(
s
string
)
{
v
:=
reflect
.
ValueOf
(
op
)
.
Elem
()
t
:=
v
.
Type
()
// Find the inode number involved, if possible.
var
inodeDesc
string
// We will set up a comma-separated list of components.
var
components
[]
string
addComponent
:=
func
(
format
string
,
v
...
interface
{})
{
components
=
append
(
components
,
fmt
.
Sprintf
(
format
,
v
...
))
}
// Include an inode number, if available.
if
f
:=
v
.
FieldByName
(
"Inode"
);
f
.
IsValid
()
{
inodeDesc
=
fmt
.
Sprintf
(
"(inode=%v)
"
,
f
.
Interface
())
addComponent
(
"inode %v
"
,
f
.
Interface
())
}
// Use the type name.
s
=
fmt
.
Sprintf
(
"%s%s"
,
t
.
Name
(),
inodeDesc
)
// Handle special cases.
switch
typed
:=
op
.
(
type
)
{
case
*
interruptOp
:
addComponent
(
"fuseid 0x%08x"
,
typed
.
FuseID
)
}
// Use just the name if there is no extra info.
if
len
(
components
)
==
0
{
return
opName
(
op
)
}
return
// Otherwise, include the extra info.
return
fmt
.
Sprintf
(
"%s (%s)"
,
opName
(
op
),
strings
.
Join
(
components
,
", "
))
}
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