OvmfPkg/VirtioFsDxe: implement the wrapper function for FUSE_FORGET
Add the VirtioFsFuseForget() function, for sending the FUSE_FORGET command to the Virtio Filesystem device. This is an unusual command in that it doesn't generate any response from the FUSE server. Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20201216211125.19496-13-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
This commit is contained in:
		
				
					committed by
					
						
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							334c13e106
						
					
				
				
					commit
					92a4d30e04
				
			@@ -85,6 +85,7 @@ typedef struct {
 | 
				
			|||||||
// FUSE operation codes.
 | 
					// FUSE operation codes.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
typedef enum {
 | 
					typedef enum {
 | 
				
			||||||
 | 
					  VirtioFsFuseOpForget      =  2,
 | 
				
			||||||
  VirtioFsFuseOpRelease     = 18,
 | 
					  VirtioFsFuseOpRelease     = 18,
 | 
				
			||||||
  VirtioFsFuseOpInit        = 26,
 | 
					  VirtioFsFuseOpInit        = 26,
 | 
				
			||||||
  VirtioFsFuseOpOpenDir     = 27,
 | 
					  VirtioFsFuseOpOpenDir     = 27,
 | 
				
			||||||
@@ -112,6 +113,13 @@ typedef struct {
 | 
				
			|||||||
  UINT64 Unique;
 | 
					  UINT64 Unique;
 | 
				
			||||||
} VIRTIO_FS_FUSE_RESPONSE;
 | 
					} VIRTIO_FS_FUSE_RESPONSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Header for VirtioFsFuseOpForget.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					  UINT64 NumberOfLookups;
 | 
				
			||||||
 | 
					} VIRTIO_FS_FUSE_FORGET_REQUEST;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Header for VirtioFsFuseOpRelease and VirtioFsFuseOpReleaseDir.
 | 
					// Header for VirtioFsFuseOpRelease and VirtioFsFuseOpReleaseDir.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										85
									
								
								OvmfPkg/VirtioFsDxe/FuseForget.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								OvmfPkg/VirtioFsDxe/FuseForget.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					/** @file
 | 
				
			||||||
 | 
					  FUSE_FORGET wrapper for the Virtio Filesystem device.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Copyright (C) 2020, Red Hat, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
				
			||||||
 | 
					**/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "VirtioFsDxe.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					  Make the Virtio Filesysem device drop one reference count from a NodeId that
 | 
				
			||||||
 | 
					  the driver looked up by filename.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Send the FUSE_FORGET request to the Virtio Filesysem device for this. Unlike
 | 
				
			||||||
 | 
					  most other FUSE requests, FUSE_FORGET doesn't elicit a response, not even the
 | 
				
			||||||
 | 
					  common VIRTIO_FS_FUSE_RESPONSE header.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  The function may only be called after VirtioFsFuseInitSession() returns
 | 
				
			||||||
 | 
					  successfully and before VirtioFsUninit() is called.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @param[in,out] VirtioFs  The Virtio Filesystem device to send the FUSE_FORGET
 | 
				
			||||||
 | 
					                           request to. On output, the FUSE request counter
 | 
				
			||||||
 | 
					                           "VirtioFs->RequestId" will have been incremented.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @param[in] NodeId        The inode number that the client learned by way of
 | 
				
			||||||
 | 
					                           lookup, and that the server should now un-reference
 | 
				
			||||||
 | 
					                           exactly once.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @retval EFI_SUCCESS  The FUSE_FORGET request has been submitted.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @return              Error codes propagated from VirtioFsSgListsValidate(),
 | 
				
			||||||
 | 
					                       VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit().
 | 
				
			||||||
 | 
					**/
 | 
				
			||||||
 | 
					EFI_STATUS
 | 
				
			||||||
 | 
					VirtioFsFuseForget (
 | 
				
			||||||
 | 
					  IN OUT VIRTIO_FS *VirtioFs,
 | 
				
			||||||
 | 
					  IN     UINT64    NodeId
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  VIRTIO_FS_FUSE_REQUEST        CommonReq;
 | 
				
			||||||
 | 
					  VIRTIO_FS_FUSE_FORGET_REQUEST ForgetReq;
 | 
				
			||||||
 | 
					  VIRTIO_FS_IO_VECTOR           ReqIoVec[2];
 | 
				
			||||||
 | 
					  VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
 | 
				
			||||||
 | 
					  EFI_STATUS                    Status;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Set up the scatter-gather list (note: only request).
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  ReqIoVec[0].Buffer = &CommonReq;
 | 
				
			||||||
 | 
					  ReqIoVec[0].Size   = sizeof CommonReq;
 | 
				
			||||||
 | 
					  ReqIoVec[1].Buffer = &ForgetReq;
 | 
				
			||||||
 | 
					  ReqIoVec[1].Size   = sizeof ForgetReq;
 | 
				
			||||||
 | 
					  ReqSgList.IoVec    = ReqIoVec;
 | 
				
			||||||
 | 
					  ReqSgList.NumVec   = ARRAY_SIZE (ReqIoVec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Validate the scatter-gather list (request only); calculate the total
 | 
				
			||||||
 | 
					  // transfer size.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, NULL);
 | 
				
			||||||
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
 | 
					    return Status;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Populate the common request header.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
 | 
				
			||||||
 | 
					             VirtioFsFuseOpForget, NodeId);
 | 
				
			||||||
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
 | 
					    return Status;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Populate the FUSE_FORGET-specific fields.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  ForgetReq.NumberOfLookups = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Submit the request. There's not going to be a response.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, NULL);
 | 
				
			||||||
 | 
					  return Status;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -195,6 +195,12 @@ VirtioFsErrnoToEfiStatus (
 | 
				
			|||||||
// Wrapper functions for FUSE commands (primitives).
 | 
					// Wrapper functions for FUSE commands (primitives).
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EFI_STATUS
 | 
				
			||||||
 | 
					VirtioFsFuseForget (
 | 
				
			||||||
 | 
					  IN OUT VIRTIO_FS *VirtioFs,
 | 
				
			||||||
 | 
					  IN     UINT64    NodeId
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EFI_STATUS
 | 
					EFI_STATUS
 | 
				
			||||||
VirtioFsFuseReleaseFileOrDir (
 | 
					VirtioFsFuseReleaseFileOrDir (
 | 
				
			||||||
  IN OUT VIRTIO_FS *VirtioFs,
 | 
					  IN OUT VIRTIO_FS *VirtioFs,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -82,6 +82,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[Sources]
 | 
					[Sources]
 | 
				
			||||||
  DriverBinding.c
 | 
					  DriverBinding.c
 | 
				
			||||||
 | 
					  FuseForget.c
 | 
				
			||||||
  FuseInit.c
 | 
					  FuseInit.c
 | 
				
			||||||
  FuseOpenDir.c
 | 
					  FuseOpenDir.c
 | 
				
			||||||
  FuseRelease.c
 | 
					  FuseRelease.c
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user