]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioFsDxe/FuseForget.c
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / VirtioFsDxe / FuseForget.c
CommitLineData
92a4d30e
LE
1/** @file\r
2 FUSE_FORGET wrapper for the Virtio Filesystem device.\r
3\r
4 Copyright (C) 2020, Red Hat, Inc.\r
5\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7**/\r
8\r
9#include "VirtioFsDxe.h"\r
10\r
11/**\r
12 Make the Virtio Filesysem device drop one reference count from a NodeId that\r
13 the driver looked up by filename.\r
14\r
15 Send the FUSE_FORGET request to the Virtio Filesysem device for this. Unlike\r
16 most other FUSE requests, FUSE_FORGET doesn't elicit a response, not even the\r
17 common VIRTIO_FS_FUSE_RESPONSE header.\r
18\r
19 The function may only be called after VirtioFsFuseInitSession() returns\r
20 successfully and before VirtioFsUninit() is called.\r
21\r
22 @param[in,out] VirtioFs The Virtio Filesystem device to send the FUSE_FORGET\r
23 request to. On output, the FUSE request counter\r
24 "VirtioFs->RequestId" will have been incremented.\r
25\r
26 @param[in] NodeId The inode number that the client learned by way of\r
27 lookup, and that the server should now un-reference\r
28 exactly once.\r
29\r
30 @retval EFI_SUCCESS The FUSE_FORGET request has been submitted.\r
31\r
32 @return Error codes propagated from VirtioFsSgListsValidate(),\r
33 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit().\r
34**/\r
35EFI_STATUS\r
36VirtioFsFuseForget (\r
37 IN OUT VIRTIO_FS *VirtioFs,\r
38 IN UINT64 NodeId\r
39 )\r
40{\r
41 VIRTIO_FS_FUSE_REQUEST CommonReq;\r
42 VIRTIO_FS_FUSE_FORGET_REQUEST ForgetReq;\r
43 VIRTIO_FS_IO_VECTOR ReqIoVec[2];\r
44 VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;\r
45 EFI_STATUS Status;\r
46\r
47 //\r
48 // Set up the scatter-gather list (note: only request).\r
49 //\r
50 ReqIoVec[0].Buffer = &CommonReq;\r
51 ReqIoVec[0].Size = sizeof CommonReq;\r
52 ReqIoVec[1].Buffer = &ForgetReq;\r
53 ReqIoVec[1].Size = sizeof ForgetReq;\r
54 ReqSgList.IoVec = ReqIoVec;\r
55 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);\r
56\r
57 //\r
58 // Validate the scatter-gather list (request only); calculate the total\r
59 // transfer size.\r
60 //\r
61 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, NULL);\r
62 if (EFI_ERROR (Status)) {\r
63 return Status;\r
64 }\r
65\r
66 //\r
67 // Populate the common request header.\r
68 //\r
69 Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,\r
70 VirtioFsFuseOpForget, NodeId);\r
71 if (EFI_ERROR (Status)) {\r
72 return Status;\r
73 }\r
74\r
75 //\r
76 // Populate the FUSE_FORGET-specific fields.\r
77 //\r
78 ForgetReq.NumberOfLookups = 1;\r
79\r
80 //\r
81 // Submit the request. There's not going to be a response.\r
82 //\r
83 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, NULL);\r
84 return Status;\r
85}\r