Commit 95bb0f93 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: hide FlagString and OpenFlagNames/FuseOpenFlagNames

parent eea9afa9
// Copyright 2016 the Go-FUSE Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package nodefs
import (
"fmt"
"github.com/hanwen/go-fuse/fuse"
)
// String provides a debug string for the given file.
func (f *WithFlags) String() string {
return fmt.Sprintf("File %s (%s) %s %s",
f.File, f.Description, fuse.FlagString(fuse.OpenFlagNames, int64(f.OpenFlags), "O_RDONLY"),
fuse.FlagString(fuse.FuseOpenFlagNames, int64(f.FuseFlags), ""))
}
...@@ -11,15 +11,7 @@ import ( ...@@ -11,15 +11,7 @@ import (
"syscall" "syscall"
) )
var initFlagNames map[int64]string var (
var releaseFlagNames map[int64]string
var OpenFlagNames map[int64]string
var FuseOpenFlagNames map[int64]string
var accessFlagName map[int64]string
var writeFlagNames map[int64]string
var readFlagNames map[int64]string
func init() {
writeFlagNames = map[int64]string{ writeFlagNames = map[int64]string{
WRITE_CACHE: "CACHE", WRITE_CACHE: "CACHE",
WRITE_LOCKOWNER: "LOCKOWNER", WRITE_LOCKOWNER: "LOCKOWNER",
...@@ -57,7 +49,7 @@ func init() { ...@@ -57,7 +49,7 @@ func init() {
releaseFlagNames = map[int64]string{ releaseFlagNames = map[int64]string{
RELEASE_FLUSH: "FLUSH", RELEASE_FLUSH: "FLUSH",
} }
OpenFlagNames = map[int64]string{ openFlagNames = map[int64]string{
int64(os.O_WRONLY): "WRONLY", int64(os.O_WRONLY): "WRONLY",
int64(os.O_RDWR): "RDWR", int64(os.O_RDWR): "RDWR",
int64(os.O_APPEND): "APPEND", int64(os.O_APPEND): "APPEND",
...@@ -72,7 +64,7 @@ func init() { ...@@ -72,7 +64,7 @@ func init() {
int64(syscall.O_CLOEXEC): "CLOEXEC", int64(syscall.O_CLOEXEC): "CLOEXEC",
int64(syscall.O_DIRECTORY): "DIRECTORY", int64(syscall.O_DIRECTORY): "DIRECTORY",
} }
FuseOpenFlagNames = map[int64]string{ fuseOpenFlagNames = map[int64]string{
FOPEN_DIRECT_IO: "DIRECT", FOPEN_DIRECT_IO: "DIRECT",
FOPEN_KEEP_CACHE: "CACHE", FOPEN_KEEP_CACHE: "CACHE",
FOPEN_NONSEEKABLE: "NONSEEK", FOPEN_NONSEEKABLE: "NONSEEK",
...@@ -82,9 +74,9 @@ func init() { ...@@ -82,9 +74,9 @@ func init() {
W_OK: "w", W_OK: "w",
R_OK: "r", R_OK: "r",
} }
} )
func FlagString(names map[int64]string, fl int64, def string) string { func flagString(names map[int64]string, fl int64, def string) string {
s := []string{} s := []string{}
for k, v := range names { for k, v := range names {
if fl&k != 0 { if fl&k != 0 {
...@@ -151,30 +143,30 @@ func (me *SetAttrIn) string() string { ...@@ -151,30 +143,30 @@ func (me *SetAttrIn) string() string {
func (me *ReleaseIn) string() string { func (me *ReleaseIn) string() string {
return fmt.Sprintf("{Fh %d %s %s L%d}", return fmt.Sprintf("{Fh %d %s %s L%d}",
me.Fh, FlagString(OpenFlagNames, int64(me.Flags), ""), me.Fh, flagString(openFlagNames, int64(me.Flags), ""),
FlagString(releaseFlagNames, int64(me.ReleaseFlags), ""), flagString(releaseFlagNames, int64(me.ReleaseFlags), ""),
me.LockOwner) me.LockOwner)
} }
func (me *OpenIn) string() string { func (me *OpenIn) string() string {
return fmt.Sprintf("{%s}", FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY")) return fmt.Sprintf("{%s}", flagString(openFlagNames, int64(me.Flags), "O_RDONLY"))
} }
func (me *OpenOut) string() string { func (me *OpenOut) string() string {
return fmt.Sprintf("{Fh %d %s}", me.Fh, return fmt.Sprintf("{Fh %d %s}", me.Fh,
FlagString(FuseOpenFlagNames, int64(me.OpenFlags), "")) flagString(fuseOpenFlagNames, int64(me.OpenFlags), ""))
} }
func (me *InitIn) string() string { func (me *InitIn) string() string {
return fmt.Sprintf("{%d.%d Ra 0x%x %s}", return fmt.Sprintf("{%d.%d Ra 0x%x %s}",
me.Major, me.Minor, me.MaxReadAhead, me.Major, me.Minor, me.MaxReadAhead,
FlagString(initFlagNames, int64(me.Flags), "")) flagString(initFlagNames, int64(me.Flags), ""))
} }
func (me *InitOut) string() string { func (me *InitOut) string() string {
return fmt.Sprintf("{%d.%d Ra 0x%x %s %d/%d Wr 0x%x Tg 0x%x}", return fmt.Sprintf("{%d.%d Ra 0x%x %s %d/%d Wr 0x%x Tg 0x%x}",
me.Major, me.Minor, me.MaxReadAhead, me.Major, me.Minor, me.MaxReadAhead,
FlagString(initFlagNames, int64(me.Flags), ""), flagString(initFlagNames, int64(me.Flags), ""),
me.CongestionThreshold, me.MaxBackground, me.MaxWrite, me.CongestionThreshold, me.MaxBackground, me.MaxWrite,
me.TimeGran) me.TimeGran)
} }
...@@ -199,7 +191,7 @@ func (me *AccessIn) string() string { ...@@ -199,7 +191,7 @@ func (me *AccessIn) string() string {
return fmt.Sprintf("{u=%d g=%d %s}", return fmt.Sprintf("{u=%d g=%d %s}",
me.Uid, me.Uid,
me.Gid, me.Gid,
FlagString(accessFlagName, int64(me.Mask), "")) flagString(accessFlagName, int64(me.Mask), ""))
} }
func (me *FlushIn) string() string { func (me *FlushIn) string() string {
......
...@@ -32,7 +32,7 @@ func (a *Attr) string() string { ...@@ -32,7 +32,7 @@ func (a *Attr) string() string {
func (me *CreateIn) string() string { func (me *CreateIn) string() string {
return fmt.Sprintf( return fmt.Sprintf(
"{0%o [%s]}", me.Mode, "{0%o [%s]}", me.Mode,
FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY")) flagString(openFlagNames, int64(me.Flags), "O_RDONLY"))
} }
func (me *GetAttrIn) string() string { return "" } func (me *GetAttrIn) string() string { return "" }
...@@ -44,11 +44,11 @@ func (me *MknodIn) string() string { ...@@ -44,11 +44,11 @@ func (me *MknodIn) string() string {
func (me *ReadIn) string() string { func (me *ReadIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s}", return fmt.Sprintf("{Fh %d [%d +%d) %s}",
me.Fh, me.Offset, me.Size, me.Fh, me.Offset, me.Size,
FlagString(readFlagNames, int64(me.ReadFlags), "")) flagString(readFlagNames, int64(me.ReadFlags), ""))
} }
func (me *WriteIn) string() string { func (me *WriteIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s}", return fmt.Sprintf("{Fh %d [%d +%d) %s}",
me.Fh, me.Offset, me.Size, me.Fh, me.Offset, me.Size,
FlagString(writeFlagNames, int64(me.WriteFlags), "")) flagString(writeFlagNames, int64(me.WriteFlags), ""))
} }
...@@ -10,10 +10,9 @@ import ( ...@@ -10,10 +10,9 @@ import (
) )
func init() { func init() {
OpenFlagNames[syscall.O_DIRECT] = "DIRECT" openFlagNames[syscall.O_DIRECT] = "DIRECT"
OpenFlagNames[syscall.O_LARGEFILE] = "LARGEFILE" openFlagNames[syscall.O_LARGEFILE] = "LARGEFILE"
OpenFlagNames[syscall_O_NOATIME] = "NOATIME" openFlagNames[syscall_O_NOATIME] = "NOATIME"
} }
func (a *Attr) string() string { func (a *Attr) string() string {
...@@ -34,7 +33,7 @@ func (a *Attr) string() string { ...@@ -34,7 +33,7 @@ func (a *Attr) string() string {
func (me *CreateIn) string() string { func (me *CreateIn) string() string {
return fmt.Sprintf( return fmt.Sprintf(
"{0%o [%s] (0%o)}", me.Mode, "{0%o [%s] (0%o)}", me.Mode,
FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY"), me.Umask) flagString(openFlagNames, int64(me.Flags), "O_RDONLY"), me.Umask)
} }
func (me *GetAttrIn) string() string { func (me *GetAttrIn) string() string {
...@@ -48,15 +47,15 @@ func (me *MknodIn) string() string { ...@@ -48,15 +47,15 @@ func (me *MknodIn) string() string {
func (me *ReadIn) string() string { func (me *ReadIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}", return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}",
me.Fh, me.Offset, me.Size, me.Fh, me.Offset, me.Size,
FlagString(readFlagNames, int64(me.ReadFlags), ""), flagString(readFlagNames, int64(me.ReadFlags), ""),
me.LockOwner, me.LockOwner,
FlagString(OpenFlagNames, int64(me.Flags), "RDONLY")) flagString(openFlagNames, int64(me.Flags), "RDONLY"))
} }
func (me *WriteIn) string() string { func (me *WriteIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}", return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}",
me.Fh, me.Offset, me.Size, me.Fh, me.Offset, me.Size,
FlagString(writeFlagNames, int64(me.WriteFlags), ""), flagString(writeFlagNames, int64(me.WriteFlags), ""),
me.LockOwner, me.LockOwner,
FlagString(OpenFlagNames, int64(me.Flags), "RDONLY")) flagString(openFlagNames, int64(me.Flags), "RDONLY"))
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment