Commit 6db54109 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Don't create garbage in zipfs Stat().

parent 155e343e
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
) )
type MemFile interface { type MemFile interface {
Stat() *fuse.Attr Stat(out *fuse.Attr)
Data() []byte Data() []byte
} }
...@@ -94,7 +94,7 @@ func (n *memNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context) ...@@ -94,7 +94,7 @@ func (n *memNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context)
out.Mode= fuse.S_IFDIR | 0777 out.Mode= fuse.S_IFDIR | 0777
return fuse.OK return fuse.OK
} }
*out = *n.file.Stat() n.file.Stat(out)
return fuse.OK return fuse.OK
} }
......
...@@ -17,15 +17,12 @@ var _ = fmt.Println ...@@ -17,15 +17,12 @@ var _ = fmt.Println
// TODO - handle symlinks. // TODO - handle symlinks.
func HeaderToFileInfo(h *tar.Header) (*fuse.Attr, string) { func HeaderToFileInfo(out *fuse.Attr, h *tar.Header) {
a := &fuse.Attr{ out.Mode = uint32(h.Mode)
Mode: uint32(h.Mode), out.Size = uint64(h.Size)
Size: uint64(h.Size), out.Uid = uint32(h.Uid)
} out.Gid = uint32(h.Gid)
a.Uid = uint32(h.Uid) out.SetTimes(&h.AccessTime, &h.ModTime, &h.ChangeTime)
a.Gid = uint32(h.Gid)
a.SetTimes(&h.AccessTime, &h.ModTime, &h.ChangeTime)
return a, h.Name
} }
type TarFile struct { type TarFile struct {
...@@ -33,10 +30,9 @@ type TarFile struct { ...@@ -33,10 +30,9 @@ type TarFile struct {
tar.Header tar.Header
} }
func (f *TarFile) Stat() *fuse.Attr { func (f *TarFile) Stat(out *fuse.Attr) {
fi, _ := HeaderToFileInfo(&f.Header) HeaderToFileInfo(out, &f.Header)
fi.Mode |= syscall.S_IFREG out.Mode |= syscall.S_IFREG
return fi
} }
func (f *TarFile) Data() []byte { func (f *TarFile) Data() []byte {
......
...@@ -19,12 +19,10 @@ type ZipFile struct { ...@@ -19,12 +19,10 @@ type ZipFile struct {
*zip.File *zip.File
} }
func (f *ZipFile) Stat() *fuse.Attr { func (f *ZipFile) Stat(out *fuse.Attr) {
// TODO - do something intelligent with timestamps. // TODO - do something intelligent with timestamps.
return &fuse.Attr{ out.Mode = fuse.S_IFREG | 0444
Mode: fuse.S_IFREG | 0444, out.Size = uint64(f.File.UncompressedSize)
Size: uint64(f.File.UncompressedSize),
}
} }
func (f *ZipFile) Data() []byte { func (f *ZipFile) Data() []byte {
......
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