Commit fcb5b5b5 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add StafsOut.FromStatfsT.

parent e33e399b
......@@ -37,6 +37,17 @@ func NewLoopbackFileSystem(root string) FileSystem {
}
}
func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut {
s := syscall.Statfs_t{}
err := syscall.Statfs(fs.GetPath(name), &s)
if err == nil {
out := &fuse.StatfsOut{}
out.FromStatfsT(&s)
return out
}
return nil
}
func (fs *loopbackFileSystem) OnMount(nodeFs *PathNodeFs) {
}
......
......@@ -11,23 +11,6 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut {
s := syscall.Statfs_t{}
err := syscall.Statfs(fs.GetPath(name), &s)
if err == nil {
return &fuse.StatfsOut{
Blocks: s.Blocks,
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
Bsize: uint32(s.Iosize), // Iosize translates to Bsize: the optimal transfer size.
Frsize: s.Bsize, // Bsize translates to Frsize: the minimum transfer size.
}
}
return nil
}
const _UTIME_NOW = ((1 << 30) - 1)
const _UTIME_OMIT = ((1 << 30) - 2)
......
......@@ -12,24 +12,6 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut {
s := syscall.Statfs_t{}
err := syscall.Statfs(fs.GetPath(name), &s)
if err == nil {
return &fuse.StatfsOut{
Blocks: s.Blocks,
Bsize: uint32(s.Bsize),
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
Frsize: uint32(s.Frsize),
NameLen: uint32(s.Namelen),
}
}
return nil
}
func (fs *loopbackFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) {
data, err := listXAttr(fs.GetPath(name))
......
......@@ -141,3 +141,13 @@ type ExchangeIn struct {
Newdir uint64
Options uint64
}
func (s *StatfsOut) FromStatfsT(statfs *syscall.Statfs_t) {
s.Blocks = statfs.Blocks
s.Bfree = statfs.Bfree
s.Bavail = statfs.Bavail
s.Files = statfs.Files
s.Ffree = statfs.Ffree
s.Bsize = uint32(s.Iosize) // Iosize translates to Bsize: the optimal transfer size.
s.Frsize = s.Bsize // Bsize translates to Frsize: the minimum transfer size.
}
......@@ -108,3 +108,14 @@ type GetXAttrIn struct {
Size uint32
Padding uint32
}
func (s *StatfsOut) FromStatfsT(statfs *syscall.Statfs_t) {
s.Blocks = statfs.Blocks
s.Bsize = uint32(statfs.Bsize)
s.Bfree = statfs.Bfree
s.Bavail = statfs.Bavail
s.Files = statfs.Files
s.Ffree = statfs.Ffree
s.Frsize = uint32(statfs.Frsize)
s.NameLen = uint32(statfs.Namelen)
}
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