Issue FUSE_FLUSH request during file close.

PiperOrigin-RevId: 571178563
This commit is contained in:
Lucas Manning
2023-10-05 17:27:49 -07:00
committed by gVisor bot
parent f3de61deed
commit 6c24ab8dd8
2 changed files with 26 additions and 0 deletions
+11
View File
@@ -1124,3 +1124,14 @@ type FUSEFallocateIn struct {
// padding
_ uint32
}
// FUSEFlushIn is the request sent by the kernel to the daemon after a file is
// closed.
//
// +marshal
type FUSEFlushIn struct {
Fh uint64
_ uint32 // unused
_ uint32 // padding
LockOwner uint64
}
+15
View File
@@ -92,6 +92,21 @@ func (fd *fileDescription) Release(ctx context.Context) {
conn.CallAsync(ctx, req)
}
// OnClose implements vfs.FileDescriptionImpl.OnClose.
func (fd *fileDescription) OnClose(ctx context.Context) error {
inode := fd.inode()
conn := inode.fs.conn
inode.attrMu.Lock()
defer inode.attrMu.Unlock()
in := linux.FUSEFlushIn{
Fh: fd.Fh,
LockOwner: 0, // TODO(gvisor.dev/issue/3245): file lock
}
req := conn.NewRequest(auth.CredentialsFromContext(ctx), pidFromContext(ctx), inode.nodeID, linux.FUSE_FLUSH, &in)
return conn.CallAsync(ctx, req)
}
// PRead implements vfs.FileDescriptionImpl.PRead.
func (fd *fileDescription) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error) {
return 0, nil