Commit 5690be47 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Populate Block count in GetAttr result.

This fixes 'du'.

Fixes #159.
parent 26b2eb35
...@@ -114,6 +114,7 @@ func (n *memNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Contex ...@@ -114,6 +114,7 @@ func (n *memNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Contex
return fuse.OK return fuse.OK
} }
n.file.Stat(out) n.file.Stat(out)
out.Blocks = (out.Size + 511) / 512
return fuse.OK return fuse.OK
} }
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"syscall"
"testing" "testing"
"time" "time"
...@@ -72,6 +73,10 @@ func TestZipFs(t *testing.T) { ...@@ -72,6 +73,10 @@ func TestZipFs(t *testing.T) {
if fi.Mode() != 0664 { if fi.Mode() != 0664 {
t.Fatalf("File mode 0%o != 0664", fi.Mode()) t.Fatalf("File mode 0%o != 0664", fi.Mode())
} }
if st := fi.Sys().(*syscall.Stat_t); st.Blocks != 1 {
t.Errorf("got block count %d, want 1", st.Blocks)
}
mtime, err := time.Parse(time.RFC3339, "2011-02-22T12:56:12Z") mtime, err := time.Parse(time.RFC3339, "2011-02-22T12:56:12Z")
if err != nil { if err != nil {
panic(err) panic(err)
......
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