Commit 290fbdd1 authored by lch's avatar lch Committed by Han-Wen Nienhuys

fuse: fix print function and add support for FreeBSD

Change-Id: I7caa793f1b7a2c3601094ca46e1a3812e763e813
parent 8cc09240
...@@ -54,19 +54,16 @@ var ( ...@@ -54,19 +54,16 @@ var (
RELEASE_FLUSH: "FLUSH", RELEASE_FLUSH: "FLUSH",
}) })
openFlagNames = newFlagNames(map[int64]string{ openFlagNames = newFlagNames(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",
int64(syscall.O_ASYNC): "ASYNC", int64(syscall.O_ASYNC): "ASYNC",
int64(os.O_CREATE): "CREAT", int64(os.O_CREATE): "CREAT",
int64(os.O_EXCL): "EXCL", int64(os.O_EXCL): "EXCL",
int64(syscall.O_NOCTTY): "NOCTTY", int64(syscall.O_NOCTTY): "NOCTTY",
int64(syscall.O_NONBLOCK): "NONBLOCK", int64(syscall.O_NONBLOCK): "NONBLOCK",
int64(os.O_SYNC): "SYNC", int64(os.O_SYNC): "SYNC",
int64(os.O_TRUNC): "TRUNC", int64(os.O_TRUNC): "TRUNC",
// syscall.O_LARGEFILE is 0x0 on x86_64, but the
// kernel supplies 0x8000 anyway.
0x8000: "LARGEFILE",
int64(syscall.O_CLOEXEC): "CLOEXEC", int64(syscall.O_CLOEXEC): "CLOEXEC",
int64(syscall.O_DIRECTORY): "DIRECTORY", int64(syscall.O_DIRECTORY): "DIRECTORY",
}) })
...@@ -354,3 +351,18 @@ func Print(obj interface{}) string { ...@@ -354,3 +351,18 @@ func Print(obj interface{}) string {
} }
return fmt.Sprintf("%T: %v", obj, obj) return fmt.Sprintf("%T: %v", obj, obj)
} }
func (a *Attr) string() string {
return fmt.Sprintf(
"{M0%o SZ=%d L=%d "+
"%d:%d "+
"B%d*%d i%d:%d "+
"A %f "+
"M %f "+
"C %f}",
a.Mode, a.Size, a.Nlink,
a.Uid, a.Gid,
a.Blocks, a.Blksize,
a.Rdev, a.Ino, ft(a.Atime, a.Atimensec), ft(a.Mtime, a.Mtimensec),
ft(a.Ctime, a.Ctimensec))
}
...@@ -19,21 +19,6 @@ func init() { ...@@ -19,21 +19,6 @@ func init() {
initFlagNames.set(CAP_CASE_INSENSITIVE, "CASE_INSENSITIVE") initFlagNames.set(CAP_CASE_INSENSITIVE, "CASE_INSENSITIVE")
} }
func (a *Attr) string() string {
return fmt.Sprintf(
"{M0%o SZ=%d L=%d "+
"%d:%d "+
"B%d*%d i%d:%d "+
"A %f "+
"M %f "+
"C %f}",
a.Mode, a.Size, a.Nlink,
a.Uid, a.Gid,
a.Blocks, a.Blksize,
a.Rdev, a.Ino, ft(a.Atime, a.Atimensec), ft(a.Mtime, a.Mtimensec),
ft(a.Ctime, a.Ctimensec))
}
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,
......
package fuse
func init() {
initFlagNames.set(CAP_NO_OPENDIR_SUPPORT, "NO_OPENDIR_SUPPORT")
}
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
package fuse package fuse
import ( import (
"fmt"
"syscall" "syscall"
) )
func init() { func init() {
// syscall.O_LARGEFILE is 0x0 on x86_64, but the
// kernel supplies 0x8000 anyway.
openFlagNames.set(0x8000, "LARGEFILE")
openFlagNames.set(syscall.O_DIRECT, "DIRECT") openFlagNames.set(syscall.O_DIRECT, "DIRECT")
openFlagNames.set(syscall_O_NOATIME, "NOATIME") openFlagNames.set(syscall_O_NOATIME, "NOATIME")
initFlagNames.set(CAP_NO_OPENDIR_SUPPORT, "NO_OPENDIR_SUPPORT") initFlagNames.set(CAP_NO_OPENDIR_SUPPORT, "NO_OPENDIR_SUPPORT")
...@@ -21,48 +23,3 @@ func init() { ...@@ -21,48 +23,3 @@ func init() {
initFlagNames.set(CAP_INIT_EXT, "INIT_EXT") initFlagNames.set(CAP_INIT_EXT, "INIT_EXT")
initFlagNames.set(CAP_INIT_RESERVED, "INIT_RESERVED") initFlagNames.set(CAP_INIT_RESERVED, "INIT_RESERVED")
} }
func (a *Attr) string() string {
return fmt.Sprintf(
"{M0%o SZ=%d L=%d "+
"%d:%d "+
"B%d*%d i%d:%d "+
"A %f "+
"M %f "+
"C %f}",
a.Mode, a.Size, a.Nlink,
a.Uid, a.Gid,
a.Blocks, a.Blksize,
a.Rdev, a.Ino, ft(a.Atime, a.Atimensec), ft(a.Mtime, a.Mtimensec),
ft(a.Ctime, a.Ctimensec))
}
func (in *CreateIn) string() string {
return fmt.Sprintf(
"{0%o [%s] (0%o)}", in.Mode,
flagString(openFlagNames, int64(in.Flags), "O_RDONLY"), in.Umask)
}
func (in *GetAttrIn) string() string {
return fmt.Sprintf("{Fh %d %s}", in.Fh_, flagString(getAttrFlagNames, int64(in.Flags_), ""))
}
func (in *MknodIn) string() string {
return fmt.Sprintf("{0%o (0%o), %d}", in.Mode, in.Umask, in.Rdev)
}
func (in *ReadIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}",
in.Fh, in.Offset, in.Size,
flagString(readFlagNames, int64(in.ReadFlags), ""),
in.LockOwner,
flagString(openFlagNames, int64(in.Flags), "RDONLY"))
}
func (in *WriteIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}",
in.Fh, in.Offset, in.Size,
flagString(writeFlagNames, int64(in.WriteFlags), ""),
in.LockOwner,
flagString(openFlagNames, int64(in.Flags), "RDONLY"))
}
//go:build !darwin
package fuse
import "fmt"
func (in *CreateIn) string() string {
return fmt.Sprintf(
"{0%o [%s] (0%o)}", in.Mode,
flagString(openFlagNames, int64(in.Flags), "O_RDONLY"), in.Umask)
}
func (in *GetAttrIn) string() string {
return fmt.Sprintf("{Fh %d %s}", in.Fh_, flagString(getAttrFlagNames, int64(in.Flags_), ""))
}
func (in *MknodIn) string() string {
return fmt.Sprintf("{0%o (0%o), %d}", in.Mode, in.Umask, in.Rdev)
}
func (in *ReadIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}",
in.Fh, in.Offset, in.Size,
flagString(readFlagNames, int64(in.ReadFlags), ""),
in.LockOwner,
flagString(openFlagNames, int64(in.Flags), "RDONLY"))
}
func (in *WriteIn) string() string {
return fmt.Sprintf("{Fh %d [%d +%d) %s L %d %s}",
in.Fh, in.Offset, in.Size,
flagString(writeFlagNames, int64(in.WriteFlags), ""),
in.LockOwner,
flagString(openFlagNames, int64(in.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