Commit f93557e8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: fsync.

parent 0f8226ac
...@@ -95,6 +95,8 @@ type Node interface { ...@@ -95,6 +95,8 @@ type Node interface {
Write(ctx context.Context, f File, data []byte, off int64) (written uint32, code fuse.Status) Write(ctx context.Context, f File, data []byte, off int64) (written uint32, code fuse.Status)
Fsync(ctx context.Context, f File, flags uint32) (code fuse.Status)
// File locking // File locking
GetLk(ctx context.Context, f File, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) GetLk(ctx context.Context, f File, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status)
SetLk(ctx context.Context, f File, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLk(ctx context.Context, f File, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status)
...@@ -143,6 +145,8 @@ type File interface { ...@@ -143,6 +145,8 @@ type File interface {
// once for a file. // once for a file.
Flush(ctx context.Context) fuse.Status Flush(ctx context.Context) fuse.Status
Fsync(ctx context.Context, flags uint32) fuse.Status
// This is called to before the file handle is forgotten. This // This is called to before the file handle is forgotten. This
// method has no return value, so nothing can synchronizes on // method has no return value, so nothing can synchronizes on
// the call. Any cleanup that requires specific synchronization or // the call. Any cleanup that requires specific synchronization or
......
...@@ -405,7 +405,8 @@ func (b *rawBridge) Flush(input *fuse.FlushIn) fuse.Status { ...@@ -405,7 +405,8 @@ func (b *rawBridge) Flush(input *fuse.FlushIn) fuse.Status {
} }
func (b *rawBridge) Fsync(input *fuse.FsyncIn) (code fuse.Status) { func (b *rawBridge) Fsync(input *fuse.FsyncIn) (code fuse.Status) {
return fuse.ENOSYS n, f := b.inode(input.NodeId, input.Fh)
return n.node.Fsync(context.TODO(), f.file, input.FsyncFlags)
} }
func (b *rawBridge) Fallocate(input *fuse.FallocateIn) (code fuse.Status) { func (b *rawBridge) Fallocate(input *fuse.FallocateIn) (code fuse.Status) {
......
...@@ -54,6 +54,14 @@ func (n *DefaultNode) Read(ctx context.Context, f File, dest []byte, off int64) ...@@ -54,6 +54,14 @@ func (n *DefaultNode) Read(ctx context.Context, f File, dest []byte, off int64)
} }
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (n *DefaultNode) Fsync(ctx context.Context, f File, flags uint32) fuse.Status {
if f != nil {
return f.Fsync(ctx, flags)
}
return fuse.ENOSYS
}
func (n *DefaultNode) Write(ctx context.Context, f File, data []byte, off int64) (written uint32, code fuse.Status) { func (n *DefaultNode) Write(ctx context.Context, f File, data []byte, off int64) (written uint32, code fuse.Status) {
if f != nil { if f != nil {
return f.Write(ctx, data, off) return f.Write(ctx, data, off)
......
...@@ -68,7 +68,7 @@ func (f *loopbackFile) Flush(ctx context.Context) fuse.Status { ...@@ -68,7 +68,7 @@ func (f *loopbackFile) Flush(ctx context.Context) fuse.Status {
return fuse.ToStatus(err) return fuse.ToStatus(err)
} }
func (f *loopbackFile) Fsync(ctx context.Context, flags int) (code fuse.Status) { func (f *loopbackFile) Fsync(ctx context.Context, flags uint32) (code fuse.Status) {
f.mu.Lock() f.mu.Lock()
r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd()))) r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd())))
f.mu.Unlock() f.mu.Unlock()
......
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