Commit 4c9a5b84 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Reinstate erroneously removed FileSystemConnector.Flush().

Add a test that catches this.
parent 1b73d273
......@@ -331,3 +331,10 @@ func (me *FileSystemConnector) Read(header *InHeader, input *ReadIn, bp BufferPo
func (me *FileSystemConnector) StatFs() *StatfsOut {
return me.rootNode.mountPoint.fs.StatFs()
}
func (me *FileSystemConnector) Flush(header *InHeader, input *FlushIn) Status {
node := me.toInode(header.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Flush()
}
......@@ -1051,3 +1051,21 @@ func TestFlushRename(t *testing.T) {
t.Errorf("got %d from Stat().Size, want %d", fi.Size, n)
}
}
func TestTruncGetAttr(t *testing.T) {
wd, clean := setupUfs(t)
defer clean()
c := []byte("hello")
f, err := os.OpenFile(wd+"/mount/file", os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
CheckSuccess(err)
_, err = f.Write(c)
CheckSuccess(err)
err = f.Close()
CheckSuccess(err)
fi, err := os.Lstat(wd+"/mount/file")
if fi.Size != int64(len(c)) {
t.Fatalf("Length mismatch got %d want %d", fi.Size, len(c))
}
}
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