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