Commit 148d3830 authored by Eliot Courtney's avatar Eliot Courtney Committed by Han-Wen Nienhuys

Add fsync handling to FileSystemConnector.

parent d36ee9dd
......@@ -21,6 +21,13 @@ func (c *FileSystemConnector) RawFS() fuse.RawFileSystem {
type rawBridge FileSystemConnector
func (c *rawBridge) Fsync(input *fuse.FsyncIn) fuse.Status {
node := c.toInode(input.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
if opened != nil {
return opened.WithFlags.File.Fsync(int(input.FsyncFlags))
}
return fuse.ENOSYS
}
......
......@@ -18,6 +18,7 @@ type MutableDataFile struct {
data []byte
fuse.Attr
GetAttrCalled bool
FsyncCalled bool
}
func (f *MutableDataFile) String() string {
......@@ -86,6 +87,11 @@ func (f *MutableDataFile) Chmod(perms uint32) fuse.Status {
return fuse.OK
}
func (f *MutableDataFile) Fsync(flags int) fuse.Status {
f.FsyncCalled = true
return fuse.OK
}
////////////////
// This FS only supports a single r/w file called "/file".
......@@ -181,9 +187,10 @@ func TestDataReadLarge(t *testing.T) {
}
func TestFSetAttr(t *testing.T) {
fs := pathfs.NewLockingFileSystem(&FSetAttrFs{
fSetAttrFs := &FSetAttrFs{
FileSystem: pathfs.NewDefaultFileSystem(),
})
}
fs := pathfs.NewLockingFileSystem(fSetAttrFs)
dir, clean := setupFAttrTest(t, fs)
defer clean()
......@@ -245,5 +252,14 @@ func TestFSetAttr(t *testing.T) {
if i1 != i2 {
t.Errorf("f.Lstat().Ino = %d. Returned %d before.", i2, i1)
}
if code := syscall.Fsync(int(f.Fd())); code != nil {
t.Error("Fsync failed:", os.NewSyscallError("Fsync", code))
}
if !fSetAttrFs.file.FsyncCalled {
t.Error("Fsync was not called")
}
// TODO - test chown if run as root.
}
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