VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/VirtioFsDxe/FuseFsync.c@ 99396

Last change on this file since 99396 was 89983, checked in by vboxsync, 4 years ago

Devices/EFI: Merge edk-stable202105 and openssl 1.1.1j and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1/** @file
2 FUSE_FSYNC / FUSE_FSYNCDIR wrapper for the Virtio Filesystem device.
3
4 Copyright (C) 2020, Red Hat, Inc.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7**/
8
9#include "VirtioFsDxe.h"
10
11/**
12 Synchronize the in-core state of a regular file or a directory with the
13 storage device on the host, by sending the FUSE_FSYNC or FUSE_FSYNCDIR
14 request to the Virtio Filesystem device.
15
16 The function may only be called after VirtioFsFuseInitSession() returns
17 successfully and before VirtioFsUninit() is called.
18
19 @param[in,out] VirtioFs The Virtio Filesystem device to send the FUSE_FSYNC
20 / FUSE_FSYNCDIR request to. On output, the FUSE
21 request counter "VirtioFs->RequestId" will have been
22 incremented.
23
24 @param[in] NodeId The inode number of the file or directory to sync.
25
26 @param[in] FuseHandle The open handle to the file or directory to sync.
27
28 @param[in] IsDir TRUE if NodeId and FuseHandle refer to a directory,
29 FALSE if NodeId and FuseHandle refer to a regular
30 file.
31
32 @retval EFI_SUCCESS The file or directory has been synchronized.
33
34 @return The "errno" value mapped to an EFI_STATUS code, if the
35 Virtio Filesystem device explicitly reported an error.
36
37 @return Error codes propagated from VirtioFsSgListsValidate(),
38 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(),
39 VirtioFsFuseCheckResponse().
40**/
41EFI_STATUS
42VirtioFsFuseFsyncFileOrDir (
43 IN OUT VIRTIO_FS *VirtioFs,
44 IN UINT64 NodeId,
45 IN UINT64 FuseHandle,
46 IN BOOLEAN IsDir
47 )
48{
49 VIRTIO_FS_FUSE_REQUEST CommonReq;
50 VIRTIO_FS_FUSE_FSYNC_REQUEST FsyncReq;
51 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
52 VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
53 VIRTIO_FS_FUSE_RESPONSE CommonResp;
54 VIRTIO_FS_IO_VECTOR RespIoVec[1];
55 VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
56 EFI_STATUS Status;
57
58 //
59 // Set up the scatter-gather lists.
60 //
61 ReqIoVec[0].Buffer = &CommonReq;
62 ReqIoVec[0].Size = sizeof CommonReq;
63 ReqIoVec[1].Buffer = &FsyncReq;
64 ReqIoVec[1].Size = sizeof FsyncReq;
65 ReqSgList.IoVec = ReqIoVec;
66 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
67
68 RespIoVec[0].Buffer = &CommonResp;
69 RespIoVec[0].Size = sizeof CommonResp;
70 RespSgList.IoVec = RespIoVec;
71 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
72
73 //
74 // Validate the scatter-gather lists; calculate the total transfer sizes.
75 //
76 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
77 if (EFI_ERROR (Status)) {
78 return Status;
79 }
80
81 //
82 // Populate the common request header.
83 //
84 Status = VirtioFsFuseNewRequest (
85 VirtioFs,
86 &CommonReq,
87 ReqSgList.TotalSize,
88 IsDir ? VirtioFsFuseOpFsyncDir : VirtioFsFuseOpFsync,
89 NodeId
90 );
91 if (EFI_ERROR (Status)) {
92 return Status;
93 }
94
95 //
96 // Populate the FUSE_FSYNC- / FUSE_FSYNCDIR-specific fields.
97 //
98 FsyncReq.FileHandle = FuseHandle;
99 FsyncReq.FsyncFlags = 0;
100 FsyncReq.Padding = 0;
101
102 //
103 // Submit the request.
104 //
105 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
106 if (EFI_ERROR (Status)) {
107 return Status;
108 }
109
110 //
111 // Verify the response (all response buffers are fixed size).
112 //
113 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
114 if (Status == EFI_DEVICE_ERROR) {
115 DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
116 "IsDir=%d Errno=%d\n", __FUNCTION__, VirtioFs->Label, NodeId, FuseHandle,
117 IsDir, CommonResp.Error));
118 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
119 }
120 return Status;
121}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette