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
ad6f59c6
Commit
ad6f59c6
authored
Sep 17, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement print for most types.
parent
fd636e38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
132 additions
and
27 deletions
+132
-27
fuse/typeprint.go
fuse/typeprint.go
+132
-27
No files found.
fuse/typeprint.go
View file @
ad6f59c6
package
fuse
import
(
"fmt"
"os"
"strings"
"syscall"
)
var
openFlags
map
[
int
]
string
var
openFlagNames
map
[
int
]
string
var
initFlagNames
map
[
int
]
string
var
fuseOpenFlagNames
map
[
int
]
string
var
writeFlagNames
map
[
int
]
string
var
readFlagNames
map
[
int
]
string
func
init
()
{
openFlags
=
map
[
int
]
string
{
os
.
O_WRONLY
:
"O_WRONLY"
,
os
.
O_RDWR
:
"O_RDWR"
,
os
.
O_APPEND
:
"O_APPEND"
,
os
.
O_ASYNC
:
"O_ASYNC"
,
os
.
O_CREATE
:
"O_CREAT"
,
os
.
O_EXCL
:
"O_EXCL"
,
os
.
O_NOCTTY
:
"O_NOCTTY"
,
os
.
O_NONBLOCK
:
"O_NONBLOCK"
,
os
.
O_SYNC
:
"O_SYNC"
,
os
.
O_TRUNC
:
"O_TRUNC"
,
openFlagNames
=
map
[
int
]
string
{
os
.
O_WRONLY
:
"WRONLY"
,
os
.
O_RDWR
:
"RDWR"
,
os
.
O_APPEND
:
"APPEND"
,
os
.
O_ASYNC
:
"ASYNC"
,
os
.
O_CREATE
:
"CREAT"
,
os
.
O_EXCL
:
"EXCL"
,
os
.
O_NOCTTY
:
"NOCTTY"
,
os
.
O_NONBLOCK
:
"NONBLOCK"
,
os
.
O_SYNC
:
"SYNC"
,
os
.
O_TRUNC
:
"TRUNC"
,
syscall
.
O_CLOEXEC
:
"CLOEXEC"
,
syscall
.
O_DIRECT
:
"DIRECT"
,
syscall
.
O_DIRECTORY
:
"DIRECTORY"
,
syscall
.
O_LARGEFILE
:
"LARGEFILE"
,
syscall
.
O_NOATIME
:
"NOATIME"
,
}
initFlagNames
=
map
[
int
]
string
{
CAP_ASYNC_READ
:
"ASYNC_READ"
,
CAP_POSIX_LOCKS
:
"POSIX_LOCKS"
,
CAP_FILE_OPS
:
"FILE_OPS"
,
CAP_ATOMIC_O_TRUNC
:
"ATOMIC_O_TRUNC"
,
CAP_EXPORT_SUPPORT
:
"EXPORT_SUPPORT"
,
CAP_BIG_WRITES
:
"BIG_WRITES"
,
CAP_DONT_MASK
:
"DONT_MASK"
,
CAP_SPLICE_WRITE
:
"SPLICE_WRITE"
,
CAP_SPLICE_MOVE
:
"SPLICE_MOVE"
,
CAP_SPLICE_READ
:
"SPLICE_READ"
,
}
fuseOpenFlagNames
=
map
[
int
]
string
{
FOPEN_DIRECT_IO
:
"DIRECT"
,
FOPEN_KEEP_CACHE
:
"CACHE"
,
FOPEN_NONSEEKABLE
:
"NONSEEK"
,
}
writeFlagNames
=
map
[
int
]
string
{
WRITE_CACHE
:
"CACHE"
,
WRITE_LOCKOWNER
:
"LOCKOWNER"
,
}
readFlagNames
=
map
[
int
]
string
{
READ_LOCKOWNER
:
"LOCKOWNER"
,
}
}
func
(
me
*
OpenIn
)
String
(
)
string
{
func
flagString
(
names
map
[
int
]
string
,
fl
int
,
def
string
)
string
{
s
:=
[]
string
{}
for
k
,
v
:=
range
openFlag
s
{
if
me
.
Flags
&
uint32
(
k
)
!=
0
{
for
k
,
v
:=
range
name
s
{
if
fl
&
k
!=
0
{
s
=
append
(
s
,
v
)
fl
^=
k
}
}
if
len
(
s
)
==
0
{
s
=
[]
string
{
"O_RDONLY"
}
if
len
(
s
)
==
0
&&
def
!=
""
{
s
=
[]
string
{
def
}
}
if
fl
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"0x%x"
,
fl
))
}
return
strings
.
Join
(
s
,
","
)
}
return
fmt
.
Sprintf
(
"[%s]"
,
strings
.
Join
(
s
,
" | "
))
func
(
me
*
OpenIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{%s}"
,
flagString
(
openFlagNames
,
int
(
me
.
Flags
),
"O_RDONLY"
))
}
func
(
me
*
SetAttrIn
)
String
()
string
{
s
:=
[]
string
{}
if
me
.
Valid
&
FATTR_MODE
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"mode %o"
,
me
.
Mode
))
if
me
.
Valid
&
FATTR_MODE
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"mode
0
%o"
,
me
.
Mode
))
}
if
me
.
Valid
&
FATTR_UID
!=
0
{
if
me
.
Valid
&
FATTR_UID
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"uid %d"
,
me
.
Uid
))
}
if
me
.
Valid
&
FATTR_GID
!=
0
{
if
me
.
Valid
&
FATTR_GID
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"uid %d"
,
me
.
Gid
))
}
if
me
.
Valid
&
FATTR_SIZE
!=
0
{
if
me
.
Valid
&
FATTR_SIZE
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"uid %d"
,
me
.
Size
))
}
if
me
.
Valid
&
FATTR_ATIME
!=
0
{
if
me
.
Valid
&
FATTR_ATIME
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"atime %d %d"
,
me
.
Atime
,
me
.
Atimensec
))
}
if
me
.
Valid
&
FATTR_MTIME
!=
0
{
if
me
.
Valid
&
FATTR_MTIME
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"mtime %d %d"
,
me
.
Mtime
,
me
.
Mtimensec
))
}
if
me
.
Valid
&
FATTR_MTIME
!=
0
{
if
me
.
Valid
&
FATTR_MTIME
!=
0
{
s
=
append
(
s
,
fmt
.
Sprintf
(
"fh %d"
,
me
.
Fh
))
}
// TODO - FATTR_ATIME_NOW = (1 << 7), FATTR_MTIME_NOW = (1 << 8), FATTR_LOCKOWNER = (1 << 9)
return
fmt
.
Sprintf
(
"[%s]"
,
strings
.
Join
(
s
,
", "
))
return
fmt
.
Sprintf
(
"{%s}"
,
strings
.
Join
(
s
,
", "
))
}
func
(
me
*
Attr
)
String
()
string
{
return
fmt
.
Sprintf
(
"{0%o S=%d L=%d "
+
"%d:%d "
+
"%d*%d %d:%d "
+
"A %d.%09d "
+
"M %d.%09d "
+
"C %d.%09d}"
,
me
.
Mode
,
me
.
Size
,
me
.
Nlink
,
me
.
Uid
,
me
.
Gid
,
me
.
Blocks
,
me
.
Blksize
,
me
.
Rdev
,
me
.
Ino
,
me
.
Atime
,
me
.
Atimensec
,
me
.
Mtime
,
me
.
Mtimensec
,
me
.
Ctime
,
me
.
Ctimensec
)
}
func
(
me
*
CreateIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{0%o [%s] (0%o)}"
,
me
.
Flags
,
flagString
(
openFlagNames
,
int
(
me
.
Flags
),
"O_RDONLY"
),
me
.
Umask
)
}
func
(
me
*
OpenOut
)
String
()
string
{
return
fmt
.
Sprintf
(
"{Fh %d %s}"
,
me
.
Fh
,
flagString
(
fuseOpenFlagNames
,
int
(
me
.
OpenFlags
),
""
))
}
func
(
me
*
GetAttrIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{Fh %d}"
,
me
.
Fh
)
}
func
(
me
*
InitIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{%d.%d Ra 0x%x %s}"
,
me
.
Major
,
me
.
Minor
,
me
.
MaxReadAhead
,
flagString
(
initFlagNames
,
int
(
me
.
Flags
),
""
))
}
func
(
me
*
InitOut
)
String
()
string
{
return
fmt
.
Sprintf
(
"{%d.%d Ra 0x%x %s %d/%d Wr 0x%x}"
,
me
.
Major
,
me
.
Minor
,
me
.
MaxReadAhead
,
flagString
(
initFlagNames
,
int
(
me
.
Flags
),
""
),
me
.
CongestionThreshold
,
me
.
MaxBackground
,
me
.
MaxWrite
)
}
func
(
me
*
ReadIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{Fh %d off %d sz %d %s L %d %s}"
,
me
.
Fh
,
me
.
Offset
,
me
.
Size
,
flagString
(
readFlagNames
,
int
(
me
.
ReadFlags
),
""
),
me
.
LockOwner
,
flagString
(
openFlagNames
,
int
(
me
.
Flags
),
"RDONLY"
))
}
func
(
me
*
MkdirIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{0%o (0%o)}"
,
me
.
Mode
,
me
.
Umask
)
}
func
(
me
*
ReleaseIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{Fh %d %s 0x%x %d}"
,
me
.
Fh
,
flagString
(
openFlagNames
,
int
(
me
.
Flags
),
""
),
me
.
ReleaseFlags
,
me
.
LockOwner
)
}
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