VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtioFsDxe/FuseRelease.c@ 94264

Last change on this file since 94264 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.8 KB
Line 
1/** @file
2 FUSE_RELEASE / FUSE_RELEASEDIR 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 Close a regular file or a directory that is open, by sending the FUSE_RELEASE
13 or FUSE_RELEASEDIR request to the Virtio Filesystem device.
14
15 The function may only be called after VirtioFsFuseInitSession() returns
16 successfully and before VirtioFsUninit() is called.
17
18 @param[in,out] VirtioFs The Virtio Filesystem device to send the
19 FUSE_RELEASE / FUSE_RELEASEDIR request to. On
20 output, the FUSE request counter
21 "VirtioFs->RequestId" will have been incremented.
22
23 @param[in] NodeId The inode number of the file or directory to close.
24
25 @param[in] FuseHandle The open handle to the file or directory to close.
26
27 @param[in] IsDir TRUE if NodeId and FuseHandle refer to a directory,
28 FALSE if NodeId and FuseHandle refer to a regular
29 file.
30
31 @retval EFI_SUCCESS The file or directory has been closed.
32
33 @return The "errno" value mapped to an EFI_STATUS code, if the
34 Virtio Filesystem device explicitly reported an error.
35
36 @return Error codes propagated from VirtioFsSgListsValidate(),
37 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(),
38 VirtioFsFuseCheckResponse().
39**/
40EFI_STATUS
41VirtioFsFuseReleaseFileOrDir (
42 IN OUT VIRTIO_FS *VirtioFs,
43 IN UINT64 NodeId,
44 IN UINT64 FuseHandle,
45 IN BOOLEAN IsDir
46 )
47{
48 VIRTIO_FS_FUSE_REQUEST CommonReq;
49 VIRTIO_FS_FUSE_RELEASE_REQUEST ReleaseReq;
50 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
51 VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
52 VIRTIO_FS_FUSE_RESPONSE CommonResp;
53 VIRTIO_FS_IO_VECTOR RespIoVec[1];
54 VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
55 EFI_STATUS Status;
56
57 //
58 // Set up the scatter-gather lists.
59 //
60 ReqIoVec[0].Buffer = &CommonReq;
61 ReqIoVec[0].Size = sizeof CommonReq;
62 ReqIoVec[1].Buffer = &ReleaseReq;
63 ReqIoVec[1].Size = sizeof ReleaseReq;
64 ReqSgList.IoVec = ReqIoVec;
65 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
66
67 RespIoVec[0].Buffer = &CommonResp;
68 RespIoVec[0].Size = sizeof CommonResp;
69 RespSgList.IoVec = RespIoVec;
70 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
71
72 //
73 // Validate the scatter-gather lists; calculate the total transfer sizes.
74 //
75 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
76 if (EFI_ERROR (Status)) {
77 return Status;
78 }
79
80 //
81 // Populate the common request header.
82 //
83 Status = VirtioFsFuseNewRequest (
84 VirtioFs,
85 &CommonReq,
86 ReqSgList.TotalSize,
87 IsDir ? VirtioFsFuseOpReleaseDir : VirtioFsFuseOpRelease,
88 NodeId
89 );
90 if (EFI_ERROR (Status)) {
91 return Status;
92 }
93
94 //
95 // Populate the FUSE_RELEASE- / FUSE_RELEASEDIR-specific fields.
96 //
97 ReleaseReq.FileHandle = FuseHandle;
98 ReleaseReq.Flags = 0;
99 ReleaseReq.ReleaseFlags = 0;
100 ReleaseReq.LockOwner = 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