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

Use os.FileInfo iso. fuse.Attr for GetAttr results.

This conveniently puts all timestamps in one int64 variable.
parent 13584d14
...@@ -15,15 +15,6 @@ import ( ...@@ -15,15 +15,6 @@ import (
var _ = runtime.GOMAXPROCS var _ = runtime.GOMAXPROCS
var _ = log.Print var _ = log.Print
type PathPrintingFs struct {
fuse.FileSystem
}
func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) {
log.Println(name)
return me.FileSystem.GetAttr(name)
}
func main() { func main() {
// Scans the arg list and sets up flags // Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.") debug := flag.Bool("debug", false, "print debugging messages.")
......
// The fuse package provides APIs to implement filesystems in // The fuse package provides APIs to implement filesystems in
// userspace, using libfuse on Linux. // userspace, using libfuse on Linux.
package fuse package fuse
import (
"os"
)
// Types for users to implement. // Types for users to implement.
...@@ -14,7 +17,7 @@ package fuse ...@@ -14,7 +17,7 @@ package fuse
// required methods. // required methods.
type FileSystem interface { type FileSystem interface {
// Attributes // Attributes
GetAttr(name string) (*Attr, Status) GetAttr(name string) (*os.FileInfo, Status)
Chmod(name string, mode uint32) (code Status) Chmod(name string, mode uint32) (code Status)
Chown(name string, uid uint32, gid uint32) (code Status) Chown(name string, uid uint32, gid uint32) (code Status)
Utimens(name string, AtimeNs uint64, MtimeNs uint64) (code Status) Utimens(name string, AtimeNs uint64, MtimeNs uint64) (code Status)
...@@ -68,7 +71,7 @@ type File interface { ...@@ -68,7 +71,7 @@ type File interface {
Release() Release()
Fsync(*FsyncIn) (code Status) Fsync(*FsyncIn) (code Status)
GetAttr() (*Attr, Status) GetAttr() (*os.FileInfo, Status)
Chown(uid uint32, gid uint32) Status Chown(uid uint32, gid uint32) Status
Chmod(perms uint32) Status Chmod(perms uint32) Status
......
...@@ -3,6 +3,7 @@ package fuse ...@@ -3,6 +3,7 @@ package fuse
import ( import (
"fmt" "fmt"
"log" "log"
"os"
) )
var _ = log.Println var _ = log.Println
...@@ -152,7 +153,7 @@ func (me *DefaultFile) Release() { ...@@ -152,7 +153,7 @@ func (me *DefaultFile) Release() {
} }
func (me *DefaultFile) GetAttr() (*Attr, Status) { func (me *DefaultFile) GetAttr() (*os.FileInfo, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
...@@ -183,7 +184,7 @@ func (me *DefaultFile) Ioctl(input *IoctlIn) (output *IoctlOut, data []byte, cod ...@@ -183,7 +184,7 @@ func (me *DefaultFile) Ioctl(input *IoctlIn) (output *IoctlOut, data []byte, cod
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// DefaultFileSystem // DefaultFileSystem
func (me *DefaultFileSystem) GetAttr(name string) (*Attr, Status) { func (me *DefaultFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
......
...@@ -101,13 +101,11 @@ func (me *LoopbackFile) Chown(uid uint32, gid uint32) Status { ...@@ -101,13 +101,11 @@ func (me *LoopbackFile) Chown(uid uint32, gid uint32) Status {
return OsErrorToErrno(me.file.Chown(int(uid), int(gid))) return OsErrorToErrno(me.file.Chown(int(uid), int(gid)))
} }
func (me *LoopbackFile) GetAttr() (*Attr, Status) { func (me *LoopbackFile) GetAttr() (*os.FileInfo, Status) {
fi, err := me.file.Stat() fi, err := me.file.Stat()
if err != nil { if err != nil {
return nil, OsErrorToErrno(err) return nil, OsErrorToErrno(err)
} }
a := &Attr{} return fi, OK
CopyFileInfo(fi, a)
return a, OK
} }
...@@ -40,15 +40,13 @@ func (me *MutableDataFile) Release() { ...@@ -40,15 +40,13 @@ func (me *MutableDataFile) Release() {
} }
func (me *MutableDataFile) getAttr() *Attr { func (me *MutableDataFile) getAttr() *os.FileInfo {
a := &Attr{} f := me.FileInfo
CopyFileInfo(&me.FileInfo, a) f.Size = int64(len(me.data))
a.Size = uint64(len(me.data)) return &f
return a
} }
func (me *MutableDataFile) GetAttr() (*Attr, Status) { func (me *MutableDataFile) GetAttr() (*os.FileInfo, Status) {
me.GetAttrCalled = true me.GetAttrCalled = true
return me.getAttr(), OK return me.getAttr(), OK
} }
...@@ -90,9 +88,9 @@ func (me *FSetAttrFs) GetXAttr(name string, attr string) ([]byte, Status) { ...@@ -90,9 +88,9 @@ func (me *FSetAttrFs) GetXAttr(name string, attr string) ([]byte, Status) {
return nil, syscall.ENODATA return nil, syscall.ENODATA
} }
func (me *FSetAttrFs) GetAttr(name string) (*Attr, Status) { func (me *FSetAttrFs) GetAttr(name string) (*os.FileInfo, Status) {
if name == "" { if name == "" {
return &Attr{Mode: S_IFDIR | 0700}, OK return &os.FileInfo{Mode: S_IFDIR | 0700}, OK
} }
if name == "file" && me.file != nil { if name == "file" && me.file != nil {
a := me.file.getAttr() a := me.file.getAttr()
......
package fuse package fuse
import ( import (
"os"
"sync" "sync"
) )
...@@ -25,7 +26,7 @@ func (me *LockingFileSystem) locked() func() { ...@@ -25,7 +26,7 @@ func (me *LockingFileSystem) locked() func() {
return func() { me.lock.Unlock() } return func() { me.lock.Unlock() }
} }
func (me *LockingFileSystem) GetAttr(name string) (*Attr, Status) { func (me *LockingFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
defer me.locked()() defer me.locked()()
return me.FileSystem.GetAttr(name) return me.FileSystem.GetAttr(name)
} }
......
...@@ -32,16 +32,13 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string { ...@@ -32,16 +32,13 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string {
return filepath.Join(me.root, relPath) return filepath.Join(me.root, relPath)
} }
func (me *LoopbackFileSystem) GetAttr(name string) (*Attr, Status) { func (me *LoopbackFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
fullPath := me.GetPath(name) fullPath := me.GetPath(name)
fi, err := os.Lstat(fullPath) fi, err := os.Lstat(fullPath)
if err != nil { if err != nil {
return nil, ENOENT return nil, OsErrorToErrno(err)
} }
out := new(Attr) return fi, OK
CopyFileInfo(fi, out)
return out, OK
} }
func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
......
...@@ -3,6 +3,7 @@ package fuse ...@@ -3,6 +3,7 @@ package fuse
import ( import (
"fmt" "fmt"
"log" "log"
"os"
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
...@@ -71,20 +72,20 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) { ...@@ -71,20 +72,20 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) {
return me.FileSystem.GetXAttr(name, attr) return me.FileSystem.GetXAttr(name, attr)
} }
func (me *FileSystemDebug) GetAttr(path string) (*Attr, Status) { func (me *FileSystemDebug) GetAttr(path string) (*os.FileInfo, Status) {
if !strings.HasPrefix(path, DebugDir) { if !strings.HasPrefix(path, DebugDir) {
return me.FileSystem.GetAttr(path) return me.FileSystem.GetAttr(path)
} }
if path == DebugDir { if path == DebugDir {
return &Attr{ return &os.FileInfo{
Mode: S_IFDIR | 0755, Mode: S_IFDIR | 0755,
},OK },OK
} }
c := me.getContent(path) c := me.getContent(path)
if c != nil { if c != nil {
return &Attr{ return &os.FileInfo{
Mode: S_IFREG | 0644, Mode: S_IFREG | 0644,
Size: uint64(len(c)), Size: int64(len(c)),
},OK },OK
} }
return nil, ENOENT return nil, ENOENT
......
...@@ -46,7 +46,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string ...@@ -46,7 +46,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
} }
fullPath = filepath.Join(fullPath, name) fullPath = filepath.Join(fullPath, name)
attr, err := mount.fs.GetAttr(fullPath) fi, err := mount.fs.GetAttr(fullPath)
if err == ENOENT && mount.options.NegativeTimeout > 0.0 { if err == ENOENT && mount.options.NegativeTimeout > 0.0 {
return NegativeEntry(mount.options.NegativeTimeout), OK, nil return NegativeEntry(mount.options.NegativeTimeout), OK, nil
...@@ -56,7 +56,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string ...@@ -56,7 +56,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
return nil, err, nil return nil, err, nil
} }
data := me.lookupUpdate(parent, name, attr.Mode&S_IFDIR != 0) data := me.lookupUpdate(parent, name, fi.Mode&S_IFDIR != 0)
data.LookupCount += lookupCount data.LookupCount += lookupCount
out = &EntryOut{ out = &EntryOut{
...@@ -65,7 +65,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string ...@@ -65,7 +65,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
} }
SplitNs(mount.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec) SplitNs(mount.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec)
SplitNs(mount.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) SplitNs(mount.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
out.Attr = *attr CopyFileInfo(fi, &out.Attr)
out.Attr.Ino = data.NodeId out.Attr.Ino = data.NodeId
return out, OK, data return out, OK, data
} }
...@@ -77,15 +77,14 @@ func (me *FileSystemConnector) Forget(h *InHeader, input *ForgetIn) { ...@@ -77,15 +77,14 @@ func (me *FileSystemConnector) Forget(h *InHeader, input *ForgetIn) {
func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
if input.Flags&FUSE_GETATTR_FH != 0 { if input.Flags&FUSE_GETATTR_FH != 0 {
f, mount, _ := me.getFile(input.Fh) f, mount, _ := me.getFile(input.Fh)
attr, err := f.GetAttr() fi, err := f.GetAttr()
if err != OK && err != ENOSYS { if err != OK && err != ENOSYS {
return nil, err return nil, err
} }
if attr != nil { if fi != nil {
out = &AttrOut{ out = &AttrOut{}
Attr: *attr, CopyFileInfo(fi, &out.Attr)
}
out.Attr.Ino = header.NodeId out.Attr.Ino = header.NodeId
SplitNs(mount.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) SplitNs(mount.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
...@@ -98,14 +97,13 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out ...@@ -98,14 +97,13 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
return nil, ENOENT return nil, ENOENT
} }
attr, err := mount.fs.GetAttr(fullPath) fi, err := mount.fs.GetAttr(fullPath)
if err != OK { if err != OK {
return nil, err return nil, err
} }
out = &AttrOut{ out = &AttrOut{}
Attr: *attr, CopyFileInfo(fi, &out.Attr)
}
out.Attr.Ino = header.NodeId out.Attr.Ino = header.NodeId
SplitNs(mount.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) SplitNs(mount.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
......
...@@ -3,6 +3,7 @@ package fuse ...@@ -3,6 +3,7 @@ package fuse
import ( import (
"time" "time"
"log" "log"
"os"
"fmt" "fmt"
) )
...@@ -44,7 +45,7 @@ func (me *TimingFileSystem) HotPaths(operation string) (paths []string) { ...@@ -44,7 +45,7 @@ func (me *TimingFileSystem) HotPaths(operation string) (paths []string) {
return me.LatencyMap.TopArgs(operation) return me.LatencyMap.TopArgs(operation)
} }
func (me *TimingFileSystem) GetAttr(name string) (*Attr, Status) { func (me *TimingFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
defer me.startTimer("GetAttr", name)() defer me.startTimer("GetAttr", name)()
return me.FileSystem.GetAttr(name) return me.FileSystem.GetAttr(name)
} }
......
...@@ -25,8 +25,8 @@ func NewXAttrFs(nm string, m map[string][]byte) *XAttrTestFs { ...@@ -25,8 +25,8 @@ func NewXAttrFs(nm string, m map[string][]byte) *XAttrTestFs {
return x return x
} }
func (me *XAttrTestFs) GetAttr(name string) (*Attr, Status) { func (me *XAttrTestFs) GetAttr(name string) (*os.FileInfo, Status) {
a := new(Attr) a := &os.FileInfo{}
if name == "" || name == "/" { if name == "" || name == "/" {
a.Mode = S_IFDIR | 0700 a.Mode = S_IFDIR | 0700
return a, OK return a, OK
......
...@@ -225,23 +225,23 @@ func (me *AutoUnionFs) GetXAttr(name string, attr string) ([]byte, fuse.Status) ...@@ -225,23 +225,23 @@ func (me *AutoUnionFs) GetXAttr(name string, attr string) ([]byte, fuse.Status)
return nil, syscall.ENODATA return nil, syscall.ENODATA
} }
func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) { func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
if path == "" || path == _CONFIG || path == _STATUS { if path == "" || path == _CONFIG || path == _STATUS {
a := &fuse.Attr{ a := &os.FileInfo{
Mode: fuse.S_IFDIR | 0755, Mode: fuse.S_IFDIR | 0755,
} }
return a, fuse.OK return a, fuse.OK
} }
if path == filepath.Join(_STATUS, _VERSION) { if path == filepath.Join(_STATUS, _VERSION) {
a := &fuse.Attr{ a := &os.FileInfo{
Mode: fuse.S_IFREG | 0644, Mode: fuse.S_IFREG | 0644,
} }
return a, fuse.OK return a, fuse.OK
} }
if path == filepath.Join(_STATUS, _ROOT) { if path == filepath.Join(_STATUS, _ROOT) {
a := &fuse.Attr{ a := &os.FileInfo{
Mode: syscall.S_IFLNK | 0644, Mode: syscall.S_IFLNK | 0644,
} }
return a, fuse.OK return a, fuse.OK
...@@ -256,14 +256,14 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) { ...@@ -256,14 +256,14 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
return nil, fuse.ENOENT return nil, fuse.ENOENT
} }
a := &fuse.Attr{ a := &os.FileInfo{
Mode: syscall.S_IFLNK | 0644, Mode: syscall.S_IFLNK | 0644,
} }
return a, fuse.OK return a, fuse.OK
} }
if me.getUnionFs(path) != nil { if me.getUnionFs(path) != nil {
return &fuse.Attr{ return &os.FileInfo{
Mode: fuse.S_IFDIR | 0755, Mode: fuse.S_IFDIR | 0755,
},fuse.OK },fuse.OK
} }
......
...@@ -3,12 +3,13 @@ package unionfs ...@@ -3,12 +3,13 @@ package unionfs
import ( import (
"fmt" "fmt"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"os"
) )
var _ = fmt.Println var _ = fmt.Println
type attrResponse struct { type attrResponse struct {
*fuse.Attr *os.FileInfo
fuse.Status fuse.Status
} }
...@@ -52,7 +53,7 @@ func readDir(fs fuse.FileSystem, name string) *dirResponse { ...@@ -52,7 +53,7 @@ func readDir(fs fuse.FileSystem, name string) *dirResponse {
func getAttr(fs fuse.FileSystem, name string) *attrResponse { func getAttr(fs fuse.FileSystem, name string) *attrResponse {
a, code := fs.GetAttr(name) a, code := fs.GetAttr(name)
return &attrResponse{ return &attrResponse{
Attr: a, FileInfo: a,
Status: code, Status: code,
} }
} }
...@@ -74,9 +75,9 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem { ...@@ -74,9 +75,9 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
return c return c
} }
func (me *CachingFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Status) { func (me *CachingFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
r := me.attributes.Get(name).(*attrResponse) r := me.attributes.Get(name).(*attrResponse)
return r.Attr, r.Status return r.FileInfo, r.Status
} }
func (me *CachingFileSystem) Readlink(name string) (string, fuse.Status) { func (me *CachingFileSystem) Readlink(name string) (string, fuse.Status) {
......
...@@ -136,7 +136,7 @@ func (me *UnionFs) getBranch(name string) branchResult { ...@@ -136,7 +136,7 @@ func (me *UnionFs) getBranch(name string) branchResult {
} }
type branchResult struct { type branchResult struct {
attr *fuse.Attr attr *os.FileInfo
code fuse.Status code fuse.Status
branch int branch int
} }
...@@ -317,7 +317,7 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) { ...@@ -317,7 +317,7 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
} }
if code.Ok() { if code.Ok() {
me.removeDeletion(path) me.removeDeletion(path)
attr := &fuse.Attr{ attr := &os.FileInfo{
Mode: fuse.S_IFDIR | mode, Mode: fuse.S_IFDIR | mode,
} }
me.branchCache.Set(path, branchResult{attr, fuse.OK, 0}) me.branchCache.Set(path, branchResult{attr, fuse.OK, 0})
...@@ -345,7 +345,7 @@ func (me *UnionFs) Truncate(path string, offset uint64) (code fuse.Status) { ...@@ -345,7 +345,7 @@ func (me *UnionFs) Truncate(path string, offset uint64) (code fuse.Status) {
code = me.fileSystems[0].Truncate(path, offset) code = me.fileSystems[0].Truncate(path, offset)
} }
if code.Ok() { if code.Ok() {
r.attr.Size = offset r.attr.Size = int64(offset)
me.branchCache.Set(path, r) me.branchCache.Set(path, r)
} }
return code return code
...@@ -364,10 +364,8 @@ func (me *UnionFs) Utimens(name string, atime uint64, mtime uint64) (code fuse.S ...@@ -364,10 +364,8 @@ func (me *UnionFs) Utimens(name string, atime uint64, mtime uint64) (code fuse.S
code = me.fileSystems[0].Utimens(name, atime, mtime) code = me.fileSystems[0].Utimens(name, atime, mtime)
} }
if code.Ok() { if code.Ok() {
r.attr.Atime = uint64(atime / 1e9) r.attr.Atime_ns = int64(atime)
r.attr.Atimensec = uint32(atime % 1e9) r.attr.Mtime_ns = int64(mtime)
r.attr.Mtime = uint64(mtime / 1e9)
r.attr.Mtimensec = uint32(mtime % 1e9)
me.branchCache.Set(name, r) me.branchCache.Set(name, r)
} }
return code return code
...@@ -384,7 +382,7 @@ func (me *UnionFs) Chown(name string, uid uint32, gid uint32) (code fuse.Status) ...@@ -384,7 +382,7 @@ func (me *UnionFs) Chown(name string, uid uint32, gid uint32) (code fuse.Status)
return fuse.EPERM return fuse.EPERM
} }
if r.attr.Owner.Uid != uid || r.attr.Owner.Gid != gid { if r.attr.Uid != int(uid) || r.attr.Gid != int(gid) {
if r.branch > 0 { if r.branch > 0 {
code := me.Promote(name, r) code := me.Promote(name, r)
if code != fuse.OK { if code != fuse.OK {
...@@ -394,8 +392,8 @@ func (me *UnionFs) Chown(name string, uid uint32, gid uint32) (code fuse.Status) ...@@ -394,8 +392,8 @@ func (me *UnionFs) Chown(name string, uid uint32, gid uint32) (code fuse.Status)
} }
me.fileSystems[0].Chown(name, uid, gid) me.fileSystems[0].Chown(name, uid, gid)
} }
r.attr.Owner.Uid = uid r.attr.Uid = int(uid)
r.attr.Owner.Gid = gid r.attr.Gid = int(gid)
me.branchCache.Set(name, r) me.branchCache.Set(name, r)
return fuse.OK return fuse.OK
} }
...@@ -526,7 +524,7 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse ...@@ -526,7 +524,7 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse
if code.Ok() { if code.Ok() {
me.removeDeletion(name) me.removeDeletion(name)
a := fuse.Attr{ a := os.FileInfo{
Mode: fuse.S_IFREG | mode, Mode: fuse.S_IFREG | mode,
} }
me.branchCache.Set(name, branchResult{&a, fuse.OK, 0}) me.branchCache.Set(name, branchResult{&a, fuse.OK, 0})
...@@ -534,7 +532,7 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse ...@@ -534,7 +532,7 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse
return fuseFile, code return fuseFile, code
} }
func (me *UnionFs) GetAttr(name string) (a *fuse.Attr, s fuse.Status) { func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
if name == _READONLY { if name == _READONLY {
return nil, fuse.ENOENT return nil, fuse.ENOENT
} }
......
...@@ -13,6 +13,7 @@ path/to/zipfile to /config/zipmount ...@@ -13,6 +13,7 @@ path/to/zipfile to /config/zipmount
import ( import (
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"log" "log"
"os"
"path/filepath" "path/filepath"
"sync" "sync"
"strings" "strings"
...@@ -127,8 +128,8 @@ func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse ...@@ -127,8 +128,8 @@ func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse
return stream, fuse.OK return stream, fuse.OK
} }
func (me *MultiZipFs) GetAttr(name string) (*fuse.Attr, fuse.Status) { func (me *MultiZipFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
a := new(fuse.Attr) a := &os.FileInfo{}
if name == "" { if name == "" {
// Should not write in top dir. // Should not write in top dir.
a.Mode = fuse.S_IFDIR | 0500 a.Mode = fuse.S_IFDIR | 0500
...@@ -156,7 +157,7 @@ func (me *MultiZipFs) GetAttr(name string) (*fuse.Attr, fuse.Status) { ...@@ -156,7 +157,7 @@ func (me *MultiZipFs) GetAttr(name string) (*fuse.Attr, fuse.Status) {
a.Mode = submode a.Mode = submode
entry, hasDir := me.zips[base] entry, hasDir := me.zips[base]
if hasDir { if hasDir {
a.Size = uint64(len(entry.ZipFileName)) a.Size = int64(len(entry.ZipFileName))
return a, fuse.OK return a, fuse.OK
} }
_, hasDir = me.pendingZips[base] _, hasDir = me.pendingZips[base]
......
...@@ -117,19 +117,19 @@ func NewZipArchiveFileSystem(name string) (*ZipArchiveFileSystem, os.Error) { ...@@ -117,19 +117,19 @@ func NewZipArchiveFileSystem(name string) (*ZipArchiveFileSystem, os.Error) {
const zip_DIRMODE uint32 = fuse.S_IFDIR | 0700 const zip_DIRMODE uint32 = fuse.S_IFDIR | 0700
const zip_FILEMODE uint32 = fuse.S_IFREG | 0600 const zip_FILEMODE uint32 = fuse.S_IFREG | 0600
func (me *ZipArchiveFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Status) { func (me *ZipArchiveFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
dir, file := me.tree.Lookup(name) dir, file := me.tree.Lookup(name)
if dir == nil { if dir == nil {
return nil, fuse.ENOENT return nil, fuse.ENOENT
} }
a := new(fuse.Attr) a := &os.FileInfo{}
if file == nil { if file == nil {
a.Mode = zip_DIRMODE a.Mode = zip_DIRMODE
} else { } else {
// TODO - do something intelligent with timestamps. // TODO - do something intelligent with timestamps.
a.Mode = zip_FILEMODE a.Mode = zip_FILEMODE
a.Size = uint64(file.UncompressedSize) a.Size = int64(file.UncompressedSize)
} }
return a, fuse.OK return a, fuse.OK
......
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