summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:09 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch)
tree32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/VirtioFsDxe
parentd1050b9dff1cace252aff86630bfdb59dff5f507 (diff)
downloadedk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip
OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the OvmfPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'OvmfPkg/VirtioFsDxe')
-rw-r--r--OvmfPkg/VirtioFsDxe/DriverBinding.c166
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseFlush.c45
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseForget.c23
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseFsync.c39
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseGetAttr.c44
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseInit.c48
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseLookup.c37
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseMkDir.c57
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseOpen.c55
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseOpenDir.c44
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseOpenOrCreate.c69
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseRead.c58
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseRelease.c39
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseRename.c52
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseSetAttr.c60
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseStatFs.c42
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseUnlink.c37
-rw-r--r--OvmfPkg/VirtioFsDxe/FuseWrite.c57
-rw-r--r--OvmfPkg/VirtioFsDxe/Helpers.c1031
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsClose.c30
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsDelete.c22
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsFlush.c23
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsGetInfo.c111
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c7
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsOpen.c227
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c21
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsRead.c155
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c243
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c17
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsWrite.c41
-rw-r--r--OvmfPkg/VirtioFsDxe/VirtioFsDxe.h356
31 files changed, 1885 insertions, 1371 deletions
diff --git a/OvmfPkg/VirtioFsDxe/DriverBinding.c b/OvmfPkg/VirtioFsDxe/DriverBinding.c
index e273c9f362..86eb9cf0ba 100644
--- a/OvmfPkg/VirtioFsDxe/DriverBinding.c
+++ b/OvmfPkg/VirtioFsDxe/DriverBinding.c
@@ -17,8 +17,8 @@
//
// UEFI Driver Model protocol instances.
//
-STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding;
-STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2;
+STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding;
+STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2;
//
// UEFI Driver Model protocol member functions.
@@ -26,18 +26,23 @@ STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2;
EFI_STATUS
EFIAPI
VirtioFsBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- VIRTIO_DEVICE_PROTOCOL *Virtio;
- EFI_STATUS CloseStatus;
-
- Status = gBS->OpenProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- (VOID **)&Virtio, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ EFI_STATUS Status;
+ VIRTIO_DEVICE_PROTOCOL *Virtio;
+ EFI_STATUS CloseStatus;
+
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ (VOID **)&Virtio,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -46,9 +51,12 @@ VirtioFsBindingSupported (
Status = EFI_UNSUPPORTED;
}
- CloseStatus = gBS->CloseProtocol (ControllerHandle,
- &gVirtioDeviceProtocolGuid, This->DriverBindingHandle,
- ControllerHandle);
+ CloseStatus = gBS->CloseProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
ASSERT_EFI_ERROR (CloseStatus);
return Status;
@@ -57,24 +65,30 @@ VirtioFsBindingSupported (
EFI_STATUS
EFIAPI
VirtioFsBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- EFI_STATUS CloseStatus;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ EFI_STATUS CloseStatus;
VirtioFs = AllocatePool (sizeof *VirtioFs);
if (VirtioFs == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
VirtioFs->Signature = VIRTIO_FS_SIG;
- Status = gBS->OpenProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- (VOID **)&VirtioFs->Virtio, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ (VOID **)&VirtioFs->Virtio,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
goto FreeVirtioFs;
}
@@ -89,8 +103,13 @@ VirtioFsBindingStart (
goto UninitVirtioFs;
}
- Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
- VirtioFsExitBoot, VirtioFs, &VirtioFs->ExitBoot);
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_CALLBACK,
+ VirtioFsExitBoot,
+ VirtioFs,
+ &VirtioFs->ExitBoot
+ );
if (EFI_ERROR (Status)) {
goto UninitVirtioFs;
}
@@ -99,9 +118,12 @@ VirtioFsBindingStart (
VirtioFs->SimpleFs.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
VirtioFs->SimpleFs.OpenVolume = VirtioFsOpenVolume;
- Status = gBS->InstallProtocolInterface (&ControllerHandle,
- &gEfiSimpleFileSystemProtocolGuid, EFI_NATIVE_INTERFACE,
- &VirtioFs->SimpleFs);
+ Status = gBS->InstallProtocolInterface (
+ &ControllerHandle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &VirtioFs->SimpleFs
+ );
if (EFI_ERROR (Status)) {
goto CloseExitBoot;
}
@@ -116,9 +138,12 @@ UninitVirtioFs:
VirtioFsUninit (VirtioFs);
CloseVirtio:
- CloseStatus = gBS->CloseProtocol (ControllerHandle,
- &gVirtioDeviceProtocolGuid, This->DriverBindingHandle,
- ControllerHandle);
+ CloseStatus = gBS->CloseProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
ASSERT_EFI_ERROR (CloseStatus);
FreeVirtioFs:
@@ -130,20 +155,24 @@ FreeVirtioFs:
EFI_STATUS
EFIAPI
VirtioFsBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
- VIRTIO_FS *VirtioFs;
-
- Status = gBS->OpenProtocol (ControllerHandle,
- &gEfiSimpleFileSystemProtocolGuid, (VOID **)&SimpleFs,
- This->DriverBindingHandle, ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
+ VIRTIO_FS *VirtioFs;
+
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ (VOID **)&SimpleFs,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -154,8 +183,11 @@ VirtioFsBindingStop (
return EFI_ACCESS_DENIED;
}
- Status = gBS->UninstallProtocolInterface (ControllerHandle,
- &gEfiSimpleFileSystemProtocolGuid, SimpleFs);
+ Status = gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ SimpleFs
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -165,8 +197,12 @@ VirtioFsBindingStop (
VirtioFsUninit (VirtioFs);
- Status = gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ Status = gBS->CloseProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
ASSERT_EFI_ERROR (Status);
FreePool (VirtioFs);
@@ -177,14 +213,15 @@ VirtioFsBindingStop (
EFI_STATUS
EFIAPI
VirtioFsGetDriverName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
if (AsciiStrCmp (Language, "en") != 0) {
return EFI_UNSUPPORTED;
}
+
*DriverName = L"Virtio Filesystem Driver";
return EFI_SUCCESS;
}
@@ -192,11 +229,11 @@ VirtioFsGetDriverName (
EFI_STATUS
EFIAPI
VirtioFsGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
@@ -208,11 +245,11 @@ VirtioFsGetControllerName (
EFI_STATUS
EFIAPI
VirtioFsEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mDriverBinding.Supported = VirtioFsBindingSupported;
mDriverBinding.Start = VirtioFsBindingStart;
@@ -225,8 +262,13 @@ VirtioFsEntryPoint (
mComponentName2.GetControllerName = VirtioFsGetControllerName;
mComponentName2.SupportedLanguages = "en";
- Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
- &gEfiDriverBindingProtocolGuid, &mDriverBinding,
- &gEfiComponentName2ProtocolGuid, &mComponentName2, NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &mDriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &mComponentName2,
+ NULL
+ );
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseFlush.c b/OvmfPkg/VirtioFsDxe/FuseFlush.c
index b689ad3291..ff5d6f3f5a 100644
--- a/OvmfPkg/VirtioFsDxe/FuseFlush.c
+++ b/OvmfPkg/VirtioFsDxe/FuseFlush.c
@@ -35,19 +35,19 @@
**/
EFI_STATUS
VirtioFsFuseFlush (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_FLUSH_REQUEST FlushReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[1];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_FLUSH_REQUEST FlushReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[1];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -75,8 +75,13 @@ VirtioFsFuseFlush (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpFlush, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpFlush,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -102,10 +107,18 @@ VirtioFsFuseFlush (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
- "Errno=%d\n", __FUNCTION__, VirtioFs->Label, NodeId, FuseHandle,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
+ "Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ FuseHandle,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseForget.c b/OvmfPkg/VirtioFsDxe/FuseForget.c
index fdee42cffb..0ed83f1e19 100644
--- a/OvmfPkg/VirtioFsDxe/FuseForget.c
+++ b/OvmfPkg/VirtioFsDxe/FuseForget.c
@@ -34,15 +34,15 @@
**/
EFI_STATUS
VirtioFsFuseForget (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId
+ 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;
+ 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).
@@ -66,8 +66,13 @@ VirtioFsFuseForget (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpForget, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpForget,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseFsync.c b/OvmfPkg/VirtioFsDxe/FuseFsync.c
index ea1463cd80..c537b064e6 100644
--- a/OvmfPkg/VirtioFsDxe/FuseFsync.c
+++ b/OvmfPkg/VirtioFsDxe/FuseFsync.c
@@ -40,20 +40,20 @@
**/
EFI_STATUS
VirtioFsFuseFsyncFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN BOOLEAN IsDir
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN BOOLEAN IsDir
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_FSYNC_REQUEST FsyncReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[1];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_FSYNC_REQUEST FsyncReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[1];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -112,10 +112,19 @@ VirtioFsFuseFsyncFileOrDir (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
- "IsDir=%d Errno=%d\n", __FUNCTION__, VirtioFs->Label, NodeId, FuseHandle,
- IsDir, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
+ "IsDir=%d Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ FuseHandle,
+ IsDir,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseGetAttr.c b/OvmfPkg/VirtioFsDxe/FuseGetAttr.c
index 29d8ec8190..1dc0349a55 100644
--- a/OvmfPkg/VirtioFsDxe/FuseGetAttr.c
+++ b/OvmfPkg/VirtioFsDxe/FuseGetAttr.c
@@ -37,20 +37,20 @@
**/
EFI_STATUS
VirtioFsFuseGetAttr (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_GETATTR_REQUEST GetAttrReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_GETATTR_RESPONSE GetAttrResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_GETATTR_REQUEST GetAttrReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_GETATTR_RESPONSE GetAttrResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -82,8 +82,13 @@ VirtioFsFuseGetAttr (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpGetAttr, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpGetAttr,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -108,9 +113,16 @@ VirtioFsFuseGetAttr (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
- __FUNCTION__, VirtioFs->Label, NodeId, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseInit.c b/OvmfPkg/VirtioFsDxe/FuseInit.c
index 4318428049..d34fc05a50 100644
--- a/OvmfPkg/VirtioFsDxe/FuseInit.c
+++ b/OvmfPkg/VirtioFsDxe/FuseInit.c
@@ -43,18 +43,18 @@
**/
EFI_STATUS
VirtioFsFuseInitSession (
- IN OUT VIRTIO_FS *VirtioFs
+ IN OUT VIRTIO_FS *VirtioFs
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_INIT_REQUEST InitReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_INIT_RESPONSE InitResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_INIT_REQUEST InitReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_INIT_RESPONSE InitResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Initialize the FUSE request counter.
@@ -89,8 +89,13 @@ VirtioFsFuseInitSession (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpInit, 0);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpInit,
+ 0
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -117,20 +122,27 @@ VirtioFsFuseInitSession (
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" Errno=%d\n", __FUNCTION__,
- VirtioFs->Label, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
//
// Check FUSE interface version / feature compatibility.
//
- if (InitResp.Major < InitReq.Major ||
- (InitResp.Major == InitReq.Major && InitResp.Minor < InitReq.Minor) ||
- (InitResp.Flags & VIRTIO_FS_FUSE_INIT_REQ_F_DO_READDIRPLUS) == 0 ||
- InitResp.MaxWrite < SIZE_4KB) {
+ if ((InitResp.Major < InitReq.Major) ||
+ ((InitResp.Major == InitReq.Major) && (InitResp.Minor < InitReq.Minor)) ||
+ ((InitResp.Flags & VIRTIO_FS_FUSE_INIT_REQ_F_DO_READDIRPLUS) == 0) ||
+ (InitResp.MaxWrite < SIZE_4KB))
+ {
return EFI_UNSUPPORTED;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseLookup.c b/OvmfPkg/VirtioFsDxe/FuseLookup.c
index 5c9a825e17..f2bda8a547 100644
--- a/OvmfPkg/VirtioFsDxe/FuseLookup.c
+++ b/OvmfPkg/VirtioFsDxe/FuseLookup.c
@@ -52,21 +52,21 @@
**/
EFI_STATUS
VirtioFsFuseLookup (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 DirNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId,
- OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 DirNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId,
+ OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_NODE_RESPONSE NodeResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_NODE_RESPONSE NodeResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -98,8 +98,13 @@ VirtioFsFuseLookup (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpLookup, DirNodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpLookup,
+ DirNodeId
+ );
if (EFI_ERROR (Status)) {
goto Fail;
}
@@ -132,8 +137,10 @@ VirtioFsFuseLookup (
if (CommonResp.Error == VIRTIO_FS_FUSE_ERRNO_ENOENT) {
return EFI_NOT_FOUND;
}
+
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
goto Fail;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseMkDir.c b/OvmfPkg/VirtioFsDxe/FuseMkDir.c
index 541ff330cd..409e09a418 100644
--- a/OvmfPkg/VirtioFsDxe/FuseMkDir.c
+++ b/OvmfPkg/VirtioFsDxe/FuseMkDir.c
@@ -41,22 +41,22 @@
**/
EFI_STATUS
VirtioFsFuseMkDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 ParentNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 ParentNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_MKDIR_REQUEST MkDirReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_NODE_RESPONSE NodeResp;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE AttrResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_MKDIR_REQUEST MkDirReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_NODE_RESPONSE NodeResp;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE AttrResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -90,8 +90,13 @@ VirtioFsFuseMkDir (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpMkDir, ParentNodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpMkDir,
+ ParentNodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -99,9 +104,9 @@ VirtioFsFuseMkDir (
//
// Populate the FUSE_MKDIR-specific fields.
//
- MkDirReq.Mode = (VIRTIO_FS_FUSE_MODE_PERM_RWXU |
- VIRTIO_FS_FUSE_MODE_PERM_RWXG |
- VIRTIO_FS_FUSE_MODE_PERM_RWXO);
+ MkDirReq.Mode = (VIRTIO_FS_FUSE_MODE_PERM_RWXU |
+ VIRTIO_FS_FUSE_MODE_PERM_RWXG |
+ VIRTIO_FS_FUSE_MODE_PERM_RWXO);
MkDirReq.Umask = 0;
//
@@ -118,11 +123,19 @@ VirtioFsFuseMkDir (
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
- "Errno=%d\n", __FUNCTION__, VirtioFs->Label, ParentNodeId, Name,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
+ "Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ ParentNodeId,
+ Name,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseOpen.c b/OvmfPkg/VirtioFsDxe/FuseOpen.c
index b731580729..64015bb6cc 100644
--- a/OvmfPkg/VirtioFsDxe/FuseOpen.c
+++ b/OvmfPkg/VirtioFsDxe/FuseOpen.c
@@ -38,21 +38,21 @@
**/
EFI_STATUS
VirtioFsFuseOpen (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN BOOLEAN ReadWrite,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN BOOLEAN ReadWrite,
+ OUT UINT64 *FuseHandle
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_OPEN_REQUEST OpenReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_OPEN_RESPONSE OpenResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_OPEN_REQUEST OpenReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_OPEN_RESPONSE OpenResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -82,8 +82,13 @@ VirtioFsFuseOpen (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpOpen, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpOpen,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -91,9 +96,9 @@ VirtioFsFuseOpen (
//
// Populate the FUSE_OPEN-specific fields.
//
- OpenReq.Flags = (ReadWrite ?
- VIRTIO_FS_FUSE_OPEN_REQ_F_RDWR :
- VIRTIO_FS_FUSE_OPEN_REQ_F_RDONLY);
+ OpenReq.Flags = (ReadWrite ?
+ VIRTIO_FS_FUSE_OPEN_REQ_F_RDWR :
+ VIRTIO_FS_FUSE_OPEN_REQ_F_RDONLY);
OpenReq.Unused = 0;
//
@@ -110,11 +115,19 @@ VirtioFsFuseOpen (
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu ReadWrite=%d "
- "Errno=%d\n", __FUNCTION__, VirtioFs->Label, NodeId, ReadWrite,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu ReadWrite=%d "
+ "Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ ReadWrite,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseOpenDir.c b/OvmfPkg/VirtioFsDxe/FuseOpenDir.c
index eef522693c..e49c046b9d 100644
--- a/OvmfPkg/VirtioFsDxe/FuseOpenDir.c
+++ b/OvmfPkg/VirtioFsDxe/FuseOpenDir.c
@@ -36,20 +36,20 @@
**/
EFI_STATUS
VirtioFsFuseOpenDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ OUT UINT64 *FuseHandle
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_OPEN_REQUEST OpenReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_OPEN_RESPONSE OpenResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_OPEN_REQUEST OpenReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_OPEN_RESPONSE OpenResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -79,8 +79,13 @@ VirtioFsFuseOpenDir (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpOpenDir, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpOpenDir,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -105,10 +110,17 @@ VirtioFsFuseOpenDir (
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
- __FUNCTION__, VirtioFs->Label, NodeId, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseOpenOrCreate.c b/OvmfPkg/VirtioFsDxe/FuseOpenOrCreate.c
index 60ab002bcd..4d9846ab3b 100644
--- a/OvmfPkg/VirtioFsDxe/FuseOpenOrCreate.c
+++ b/OvmfPkg/VirtioFsDxe/FuseOpenOrCreate.c
@@ -46,24 +46,24 @@
**/
EFI_STATUS
VirtioFsFuseOpenOrCreate (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 ParentNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 ParentNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId,
+ OUT UINT64 *FuseHandle
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_CREATE_REQUEST CreateReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_NODE_RESPONSE NodeResp;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE AttrResp;
- VIRTIO_FS_FUSE_OPEN_RESPONSE OpenResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[4];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_CREATE_REQUEST CreateReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_NODE_RESPONSE NodeResp;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE AttrResp;
+ VIRTIO_FS_FUSE_OPEN_RESPONSE OpenResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[4];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -99,8 +99,13 @@ VirtioFsFuseOpenOrCreate (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpCreate, ParentNodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpCreate,
+ ParentNodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -113,13 +118,13 @@ VirtioFsFuseOpenOrCreate (
// the only OpenMode of EFI_FILE_PROTOCOL.Open() that enables filesystem
// object creation -- that is, Create/Read/Write.
//
- CreateReq.Flags = VIRTIO_FS_FUSE_OPEN_REQ_F_RDWR;
- CreateReq.Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |
- VIRTIO_FS_FUSE_MODE_PERM_WUSR |
- VIRTIO_FS_FUSE_MODE_PERM_RGRP |
- VIRTIO_FS_FUSE_MODE_PERM_WGRP |
- VIRTIO_FS_FUSE_MODE_PERM_ROTH |
- VIRTIO_FS_FUSE_MODE_PERM_WOTH);
+ CreateReq.Flags = VIRTIO_FS_FUSE_OPEN_REQ_F_RDWR;
+ CreateReq.Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |
+ VIRTIO_FS_FUSE_MODE_PERM_WUSR |
+ VIRTIO_FS_FUSE_MODE_PERM_RGRP |
+ VIRTIO_FS_FUSE_MODE_PERM_WGRP |
+ VIRTIO_FS_FUSE_MODE_PERM_ROTH |
+ VIRTIO_FS_FUSE_MODE_PERM_WOTH);
CreateReq.Umask = 0;
CreateReq.Padding = 0;
@@ -137,11 +142,19 @@ VirtioFsFuseOpenOrCreate (
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
- "Errno=%d\n", __FUNCTION__, VirtioFs->Label, ParentNodeId, Name,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
+ "Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ ParentNodeId,
+ Name,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseRead.c b/OvmfPkg/VirtioFsDxe/FuseRead.c
index 1611e298b9..013dac7e52 100644
--- a/OvmfPkg/VirtioFsDxe/FuseRead.c
+++ b/OvmfPkg/VirtioFsDxe/FuseRead.c
@@ -87,24 +87,24 @@
**/
EFI_STATUS
VirtioFsFuseReadFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN BOOLEAN IsDir,
- IN UINT64 Offset,
- IN OUT UINT32 *Size,
- OUT VOID *Data
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN BOOLEAN IsDir,
+ IN UINT64 Offset,
+ IN OUT UINT32 *Size,
+ OUT VOID *Data
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_READ_REQUEST ReadReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
- UINTN TailBufferFill;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_READ_REQUEST ReadReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
+ UINTN TailBufferFill;
//
// Set up the scatter-gather lists.
@@ -167,16 +167,30 @@ VirtioFsFuseReadFileOrDir (
//
// Verify the response. Note that TailBufferFill is variable.
//
- Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique,
- &TailBufferFill);
+ Status = VirtioFsFuseCheckResponse (
+ &RespSgList,
+ CommonReq.Unique,
+ &TailBufferFill
+ );
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
- "IsDir=%d Offset=0x%Lx Size=0x%x Data@%p Errno=%d\n", __FUNCTION__,
- VirtioFs->Label, NodeId, FuseHandle, IsDir, Offset, *Size, Data,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
+ "IsDir=%d Offset=0x%Lx Size=0x%x Data@%p Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ FuseHandle,
+ IsDir,
+ Offset,
+ *Size,
+ Data,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseRelease.c b/OvmfPkg/VirtioFsDxe/FuseRelease.c
index dd45c7864f..c8363158f5 100644
--- a/OvmfPkg/VirtioFsDxe/FuseRelease.c
+++ b/OvmfPkg/VirtioFsDxe/FuseRelease.c
@@ -39,20 +39,20 @@
**/
EFI_STATUS
VirtioFsFuseReleaseFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN BOOLEAN IsDir
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN BOOLEAN IsDir
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_RELEASE_REQUEST ReleaseReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[1];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_RELEASE_REQUEST ReleaseReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[1];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -112,10 +112,19 @@ VirtioFsFuseReleaseFileOrDir (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
- "IsDir=%d Errno=%d\n", __FUNCTION__, VirtioFs->Label, NodeId, FuseHandle,
- IsDir, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
+ "IsDir=%d Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ FuseHandle,
+ IsDir,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseRename.c b/OvmfPkg/VirtioFsDxe/FuseRename.c
index fc9b27ccf6..a3a1050506 100644
--- a/OvmfPkg/VirtioFsDxe/FuseRename.c
+++ b/OvmfPkg/VirtioFsDxe/FuseRename.c
@@ -49,21 +49,21 @@
**/
EFI_STATUS
VirtioFsFuseRename (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 OldParentNodeId,
- IN CHAR8 *OldName,
- IN UINT64 NewParentNodeId,
- IN CHAR8 *NewName
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 OldParentNodeId,
+ IN CHAR8 *OldName,
+ IN UINT64 NewParentNodeId,
+ IN CHAR8 *NewName
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_RENAME2_REQUEST Rename2Req;
- VIRTIO_FS_IO_VECTOR ReqIoVec[4];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[1];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_RENAME2_REQUEST Rename2Req;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[4];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[1];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -95,8 +95,13 @@ VirtioFsFuseRename (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpRename2, OldParentNodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpRename2,
+ OldParentNodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -121,11 +126,20 @@ VirtioFsFuseRename (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" OldParentNodeId=%Lu OldName=\"%a\" "
- "NewParentNodeId=%Lu NewName=\"%a\" Errno=%d\n", __FUNCTION__,
- VirtioFs->Label, OldParentNodeId, OldName, NewParentNodeId, NewName,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" OldParentNodeId=%Lu OldName=\"%a\" "
+ "NewParentNodeId=%Lu NewName=\"%a\" Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ OldParentNodeId,
+ OldName,
+ NewParentNodeId,
+ NewName,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseSetAttr.c b/OvmfPkg/VirtioFsDxe/FuseSetAttr.c
index dcd0141720..9d0ea93fd9 100644
--- a/OvmfPkg/VirtioFsDxe/FuseSetAttr.c
+++ b/OvmfPkg/VirtioFsDxe/FuseSetAttr.c
@@ -52,24 +52,24 @@
**/
EFI_STATUS
VirtioFsFuseSetAttr (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 *Size OPTIONAL,
- IN UINT64 *Atime OPTIONAL,
- IN UINT64 *Mtime OPTIONAL,
- IN UINT32 *Mode OPTIONAL
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 *Size OPTIONAL,
+ IN UINT64 *Atime OPTIONAL,
+ IN UINT64 *Mtime OPTIONAL,
+ IN UINT32 *Mode OPTIONAL
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_SETATTR_REQUEST AttrReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_GETATTR_RESPONSE GetAttrResp;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE AttrResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_SETATTR_REQUEST AttrReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_GETATTR_RESPONSE GetAttrResp;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE AttrResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -101,8 +101,13 @@ VirtioFsFuseSetAttr (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpSetAttr, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpSetAttr,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -130,12 +135,15 @@ VirtioFsFuseSetAttr (
if (Size != NULL) {
AttrReq.Valid |= VIRTIO_FS_FUSE_SETATTR_REQ_F_SIZE;
}
+
if (Atime != NULL) {
AttrReq.Valid |= VIRTIO_FS_FUSE_SETATTR_REQ_F_ATIME;
}
+
if (Mtime != NULL) {
AttrReq.Valid |= VIRTIO_FS_FUSE_SETATTR_REQ_F_MTIME;
}
+
if (Mode != NULL) {
AttrReq.Valid |= VIRTIO_FS_FUSE_SETATTR_REQ_F_MODE;
}
@@ -153,22 +161,32 @@ VirtioFsFuseSetAttr (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu", __FUNCTION__,
- VirtioFs->Label, NodeId));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId
+ ));
if (Size != NULL) {
DEBUG ((DEBUG_ERROR, " Size=0x%Lx", *Size));
}
+
if (Atime != NULL) {
DEBUG ((DEBUG_ERROR, " Atime=%Lu", *Atime));
}
+
if (Mtime != NULL) {
DEBUG ((DEBUG_ERROR, " Mtime=%Lu", *Mtime));
}
+
if (Mode != NULL) {
DEBUG ((DEBUG_ERROR, " Mode=0x%x", *Mode)); // no support for octal :/
}
- DEBUG ((DEBUG_ERROR, " Errno=%d\n", CommonResp.Error));
+
+ DEBUG ((DEBUG_ERROR, " Errno=%d\n", CommonResp.Error));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseStatFs.c b/OvmfPkg/VirtioFsDxe/FuseStatFs.c
index e794f8977a..d93a62080e 100644
--- a/OvmfPkg/VirtioFsDxe/FuseStatFs.c
+++ b/OvmfPkg/VirtioFsDxe/FuseStatFs.c
@@ -36,18 +36,18 @@
**/
EFI_STATUS
VirtioFsFuseStatFs (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr
- )
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr
+ )
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[1];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[1];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -75,8 +75,13 @@ VirtioFsFuseStatFs (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpStatFs, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpStatFs,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -94,9 +99,16 @@ VirtioFsFuseStatFs (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
- __FUNCTION__, VirtioFs->Label, NodeId, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseUnlink.c b/OvmfPkg/VirtioFsDxe/FuseUnlink.c
index 8f84edbe94..14cbdec5f5 100644
--- a/OvmfPkg/VirtioFsDxe/FuseUnlink.c
+++ b/OvmfPkg/VirtioFsDxe/FuseUnlink.c
@@ -41,19 +41,19 @@
**/
EFI_STATUS
VirtioFsFuseRemoveFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 ParentNodeId,
- IN CHAR8 *Name,
- IN BOOLEAN IsDir
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 ParentNodeId,
+ IN CHAR8 *Name,
+ IN BOOLEAN IsDir
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[1];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[1];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Set up the scatter-gather lists.
@@ -105,10 +105,19 @@ VirtioFsFuseRemoveFileOrDir (
//
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
- "IsDir=%d Errno=%d\n", __FUNCTION__, VirtioFs->Label, ParentNodeId, Name,
- IsDir, CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
+ "IsDir=%d Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ ParentNodeId,
+ Name,
+ IsDir,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/FuseWrite.c b/OvmfPkg/VirtioFsDxe/FuseWrite.c
index cc552bd667..fe65c0bdbe 100644
--- a/OvmfPkg/VirtioFsDxe/FuseWrite.c
+++ b/OvmfPkg/VirtioFsDxe/FuseWrite.c
@@ -52,23 +52,23 @@
**/
EFI_STATUS
VirtioFsFuseWrite (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN UINT64 Offset,
- IN OUT UINT32 *Size,
- IN VOID *Data
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN UINT64 Offset,
+ IN OUT UINT32 *Size,
+ IN VOID *Data
)
{
- VIRTIO_FS_FUSE_REQUEST CommonReq;
- VIRTIO_FS_FUSE_WRITE_REQUEST WriteReq;
- VIRTIO_FS_IO_VECTOR ReqIoVec[3];
- VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
- VIRTIO_FS_FUSE_RESPONSE CommonResp;
- VIRTIO_FS_FUSE_WRITE_RESPONSE WriteResp;
- VIRTIO_FS_IO_VECTOR RespIoVec[2];
- VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
- EFI_STATUS Status;
+ VIRTIO_FS_FUSE_REQUEST CommonReq;
+ VIRTIO_FS_FUSE_WRITE_REQUEST WriteReq;
+ VIRTIO_FS_IO_VECTOR ReqIoVec[3];
+ VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
+ VIRTIO_FS_FUSE_RESPONSE CommonResp;
+ VIRTIO_FS_FUSE_WRITE_RESPONSE WriteResp;
+ VIRTIO_FS_IO_VECTOR RespIoVec[2];
+ VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
+ EFI_STATUS Status;
//
// Honor the write buffer size limit of the Virtio Filesystem device.
@@ -107,8 +107,13 @@ VirtioFsFuseWrite (
//
// Populate the common request header.
//
- Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
- VirtioFsFuseOpWrite, NodeId);
+ Status = VirtioFsFuseNewRequest (
+ VirtioFs,
+ &CommonReq,
+ ReqSgList.TotalSize,
+ VirtioFsFuseOpWrite,
+ NodeId
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -138,12 +143,22 @@ VirtioFsFuseWrite (
Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
- DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
- "Offset=0x%Lx Size=0x%x Data@%p Errno=%d\n", __FUNCTION__,
- VirtioFs->Label, NodeId, FuseHandle, Offset, *Size, Data,
- CommonResp.Error));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Label=\"%s\" NodeId=%Lu FuseHandle=%Lu "
+ "Offset=0x%Lx Size=0x%x Data@%p Errno=%d\n",
+ __FUNCTION__,
+ VirtioFs->Label,
+ NodeId,
+ FuseHandle,
+ Offset,
+ *Size,
+ Data,
+ CommonResp.Error
+ ));
Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/Helpers.c b/OvmfPkg/VirtioFsDxe/Helpers.c
index b81c04e0a4..f32fb1d48a 100644
--- a/OvmfPkg/VirtioFsDxe/Helpers.c
+++ b/OvmfPkg/VirtioFsDxe/Helpers.c
@@ -29,12 +29,12 @@
STATIC
EFI_STATUS
VirtioFsReadConfig (
- IN VIRTIO_DEVICE_PROTOCOL *Virtio,
- OUT VIRTIO_FS_CONFIG *Config
+ IN VIRTIO_DEVICE_PROTOCOL *Virtio,
+ OUT VIRTIO_FS_CONFIG *Config
)
{
- UINTN Idx;
- EFI_STATUS Status;
+ UINTN Idx;
+ EFI_STATUS Status;
for (Idx = 0; Idx < VIRTIO_FS_TAG_BYTES; Idx++) {
Status = Virtio->ReadDevice (
@@ -78,15 +78,15 @@ VirtioFsReadConfig (
**/
EFI_STATUS
VirtioFsInit (
- IN OUT VIRTIO_FS *VirtioFs
+ IN OUT VIRTIO_FS *VirtioFs
)
{
- UINT8 NextDevStat;
- EFI_STATUS Status;
- UINT64 Features;
- VIRTIO_FS_CONFIG Config;
- UINTN Idx;
- UINT64 RingBaseShift;
+ UINT8 NextDevStat;
+ EFI_STATUS Status;
+ UINT64 Features;
+ VIRTIO_FS_CONFIG Config;
+ UINTN Idx;
+ UINT64 RingBaseShift;
//
// Execute virtio-v1.1-cs01-87fa6b5d8155, 3.1.1 Driver Requirements: Device
@@ -95,7 +95,7 @@ VirtioFsInit (
// 1. Reset the device.
//
NextDevStat = 0;
- Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
+ Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -104,7 +104,7 @@ VirtioFsInit (
// 2. Set the ACKNOWLEDGE status bit [...]
//
NextDevStat |= VSTAT_ACK;
- Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
+ Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -113,7 +113,7 @@ VirtioFsInit (
// 3. Set the DRIVER status bit [...]
//
NextDevStat |= VSTAT_DRIVER;
- Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
+ Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -125,10 +125,12 @@ VirtioFsInit (
if (EFI_ERROR (Status)) {
goto Failed;
}
+
if ((Features & VIRTIO_F_VERSION_1) == 0) {
Status = EFI_UNSUPPORTED;
goto Failed;
}
+
//
// No device-specific feature bits have been defined in file "virtio-fs.tex"
// of the virtio spec at <https://github.com/oasis-tcs/virtio-spec.git>, as
@@ -163,12 +165,14 @@ VirtioFsInit (
// original label.
//
for (Idx = 0; Idx < VIRTIO_FS_TAG_BYTES && Config.Tag[Idx] != '\0'; Idx++) {
- if (Config.Tag[Idx] < 0x20 || Config.Tag[Idx] > 0x7E) {
+ if ((Config.Tag[Idx] < 0x20) || (Config.Tag[Idx] > 0x7E)) {
Status = EFI_UNSUPPORTED;
goto Failed;
}
+
VirtioFs->Label[Idx] = Config.Tag[Idx];
}
+
VirtioFs->Label[Idx] = L'\0';
//
@@ -184,16 +188,22 @@ VirtioFsInit (
// queue at once. We'll need two descriptors per request, as a minimum --
// request header, response header.
//
- Status = VirtioFs->Virtio->SetQueueSel (VirtioFs->Virtio,
- VIRTIO_FS_REQUEST_QUEUE);
+ Status = VirtioFs->Virtio->SetQueueSel (
+ VirtioFs->Virtio,
+ VIRTIO_FS_REQUEST_QUEUE
+ );
if (EFI_ERROR (Status)) {
goto Failed;
}
- Status = VirtioFs->Virtio->GetQueueNumMax (VirtioFs->Virtio,
- &VirtioFs->QueueSize);
+
+ Status = VirtioFs->Virtio->GetQueueNumMax (
+ VirtioFs->Virtio,
+ &VirtioFs->QueueSize
+ );
if (EFI_ERROR (Status)) {
goto Failed;
}
+
if (VirtioFs->QueueSize < 2) {
Status = EFI_UNSUPPORTED;
goto Failed;
@@ -202,20 +212,30 @@ VirtioFsInit (
//
// 7.d. [...] population of virtqueues [...]
//
- Status = VirtioRingInit (VirtioFs->Virtio, VirtioFs->QueueSize,
- &VirtioFs->Ring);
+ Status = VirtioRingInit (
+ VirtioFs->Virtio,
+ VirtioFs->QueueSize,
+ &VirtioFs->Ring
+ );
if (EFI_ERROR (Status)) {
goto Failed;
}
- Status = VirtioRingMap (VirtioFs->Virtio, &VirtioFs->Ring, &RingBaseShift,
- &VirtioFs->RingMap);
+ Status = VirtioRingMap (
+ VirtioFs->Virtio,
+ &VirtioFs->Ring,
+ &RingBaseShift,
+ &VirtioFs->RingMap
+ );
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
- Status = VirtioFs->Virtio->SetQueueAddress (VirtioFs->Virtio,
- &VirtioFs->Ring, RingBaseShift);
+ Status = VirtioFs->Virtio->SetQueueAddress (
+ VirtioFs->Virtio,
+ &VirtioFs->Ring,
+ RingBaseShift
+ );
if (EFI_ERROR (Status)) {
goto UnmapQueue;
}
@@ -224,7 +244,7 @@ VirtioFsInit (
// 8. Set the DRIVER_OK status bit.
//
NextDevStat |= VSTAT_DRIVER_OK;
- Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
+ Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
if (EFI_ERROR (Status)) {
goto UnmapQueue;
}
@@ -262,7 +282,7 @@ Failed:
**/
VOID
VirtioFsUninit (
- IN OUT VIRTIO_FS *VirtioFs
+ IN OUT VIRTIO_FS *VirtioFs
)
{
//
@@ -290,15 +310,20 @@ VirtioFsUninit (
VOID
EFIAPI
VirtioFsExitBoot (
- IN EFI_EVENT ExitBootEvent,
- IN VOID *VirtioFsAsVoid
+ IN EFI_EVENT ExitBootEvent,
+ IN VOID *VirtioFsAsVoid
)
{
- VIRTIO_FS *VirtioFs;
+ VIRTIO_FS *VirtioFs;
VirtioFs = VirtioFsAsVoid;
- DEBUG ((DEBUG_VERBOSE, "%a: VirtioFs=0x%p Label=\"%s\"\n", __FUNCTION__,
- VirtioFsAsVoid, VirtioFs->Label));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: VirtioFs=0x%p Label=\"%s\"\n",
+ __FUNCTION__,
+ VirtioFsAsVoid,
+ VirtioFs->Label
+ ));
VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, 0);
}
@@ -371,14 +396,14 @@ VirtioFsExitBoot (
**/
EFI_STATUS
VirtioFsSgListsValidate (
- IN VIRTIO_FS *VirtioFs,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
+ IN VIRTIO_FS *VirtioFs,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
)
{
- VIRTIO_FS_SCATTER_GATHER_LIST *SgListParam[2];
- UINT16 DescriptorsNeeded;
- UINTN ListId;
+ VIRTIO_FS_SCATTER_GATHER_LIST *SgListParam[2];
+ UINT16 DescriptorsNeeded;
+ UINTN ListId;
if (RequestSgList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -389,42 +414,47 @@ VirtioFsSgListsValidate (
DescriptorsNeeded = 0;
for (ListId = 0; ListId < ARRAY_SIZE (SgListParam); ListId++) {
- VIRTIO_FS_SCATTER_GATHER_LIST *SgList;
- UINT32 SgListTotalSize;
- UINTN IoVecIdx;
+ VIRTIO_FS_SCATTER_GATHER_LIST *SgList;
+ UINT32 SgListTotalSize;
+ UINTN IoVecIdx;
SgList = SgListParam[ListId];
if (SgList == NULL) {
continue;
}
+
//
// Sanity-check SgList -- it must provide at least one IO Vector.
//
- if (SgList->IoVec == NULL || SgList->NumVec == 0) {
+ if ((SgList->IoVec == NULL) || (SgList->NumVec == 0)) {
return EFI_INVALID_PARAMETER;
}
+
//
// Make sure that, for each IO Vector in this SgList, a virtio descriptor
// can be added to the virtio queue, after the other descriptors added
// previously.
//
- if (SgList->NumVec > (UINTN)(MAX_UINT16 - DescriptorsNeeded) ||
- DescriptorsNeeded + SgList->NumVec > VirtioFs->QueueSize) {
+ if ((SgList->NumVec > (UINTN)(MAX_UINT16 - DescriptorsNeeded)) ||
+ (DescriptorsNeeded + SgList->NumVec > VirtioFs->QueueSize))
+ {
return EFI_UNSUPPORTED;
}
+
DescriptorsNeeded += (UINT16)SgList->NumVec;
SgListTotalSize = 0;
for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
- VIRTIO_FS_IO_VECTOR *IoVec;
+ VIRTIO_FS_IO_VECTOR *IoVec;
IoVec = &SgList->IoVec[IoVecIdx];
//
// Sanity-check this IoVec -- it must describe a non-empty buffer.
//
- if (IoVec->Buffer == NULL || IoVec->Size == 0) {
+ if ((IoVec->Buffer == NULL) || (IoVec->Size == 0)) {
return EFI_INVALID_PARAMETER;
}
+
//
// Make sure the cumulative size of all IO Vectors in this SgList remains
// expressible as a UINT32.
@@ -432,6 +462,7 @@ VirtioFsSgListsValidate (
if (IoVec->Size > MAX_UINT32 - SgListTotalSize) {
return EFI_UNSUPPORTED;
}
+
SgListTotalSize += (UINT32)IoVec->Size;
//
@@ -505,22 +536,22 @@ VirtioFsSgListsValidate (
**/
EFI_STATUS
VirtioFsSgListsSubmit (
- IN OUT VIRTIO_FS *VirtioFs,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
)
{
- VIRTIO_FS_SCATTER_GATHER_LIST *SgListParam[2];
- VIRTIO_MAP_OPERATION SgListVirtioMapOp[ARRAY_SIZE (SgListParam)];
- UINT16 SgListDescriptorFlag[ARRAY_SIZE (SgListParam)];
- UINTN ListId;
- VIRTIO_FS_SCATTER_GATHER_LIST *SgList;
- UINTN IoVecIdx;
- VIRTIO_FS_IO_VECTOR *IoVec;
- EFI_STATUS Status;
- DESC_INDICES Indices;
- UINT32 TotalBytesWrittenByDevice;
- UINT32 BytesPermittedForWrite;
+ VIRTIO_FS_SCATTER_GATHER_LIST *SgListParam[2];
+ VIRTIO_MAP_OPERATION SgListVirtioMapOp[ARRAY_SIZE (SgListParam)];
+ UINT16 SgListDescriptorFlag[ARRAY_SIZE (SgListParam)];
+ UINTN ListId;
+ VIRTIO_FS_SCATTER_GATHER_LIST *SgList;
+ UINTN IoVecIdx;
+ VIRTIO_FS_IO_VECTOR *IoVec;
+ EFI_STATUS Status;
+ DESC_INDICES Indices;
+ UINT32 TotalBytesWrittenByDevice;
+ UINT32 BytesPermittedForWrite;
SgListParam[0] = RequestSgList;
SgListVirtioMapOp[0] = VirtioOperationBusMasterRead;
@@ -538,6 +569,7 @@ VirtioFsSgListsSubmit (
if (SgList == NULL) {
continue;
}
+
for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
IoVec = &SgList->IoVec[IoVecIdx];
//
@@ -554,6 +586,7 @@ VirtioFsSgListsSubmit (
if (EFI_ERROR (Status)) {
goto Unmap;
}
+
IoVec->Mapped = TRUE;
}
}
@@ -567,18 +600,21 @@ VirtioFsSgListsSubmit (
if (SgList == NULL) {
continue;
}
+
for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
- UINT16 NextFlag;
+ UINT16 NextFlag;
IoVec = &SgList->IoVec[IoVecIdx];
//
// Set VRING_DESC_F_NEXT on all except the very last descriptor.
//
NextFlag = VRING_DESC_F_NEXT;
- if (ListId == ARRAY_SIZE (SgListParam) - 1 &&
- IoVecIdx == SgList->NumVec - 1) {
+ if ((ListId == ARRAY_SIZE (SgListParam) - 1) &&
+ (IoVecIdx == SgList->NumVec - 1))
+ {
NextFlag = 0;
}
+
VirtioAppendDesc (
&VirtioFs->Ring,
IoVec->MappedAddress,
@@ -592,8 +628,13 @@ VirtioFsSgListsSubmit (
//
// Submit the descriptor chain.
//
- Status = VirtioFlush (VirtioFs->Virtio, VIRTIO_FS_REQUEST_QUEUE,
- &VirtioFs->Ring, &Indices, &TotalBytesWrittenByDevice);
+ Status = VirtioFlush (
+ VirtioFs->Virtio,
+ VIRTIO_FS_REQUEST_QUEUE,
+ &VirtioFs->Ring,
+ &Indices,
+ &TotalBytesWrittenByDevice
+ );
if (EFI_ERROR (Status)) {
goto Unmap;
}
@@ -607,6 +648,7 @@ VirtioFsSgListsSubmit (
} else {
BytesPermittedForWrite = ResponseSgList->TotalSize;
}
+
if (TotalBytesWrittenByDevice > BytesPermittedForWrite) {
Status = EFI_DEVICE_ERROR;
goto Unmap;
@@ -620,6 +662,7 @@ VirtioFsSgListsSubmit (
if (SgList == NULL) {
continue;
}
+
for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
IoVec = &SgList->IoVec[IoVecIdx];
if (SgListVirtioMapOp[ListId] == VirtioOperationBusMasterRead) {
@@ -636,8 +679,10 @@ VirtioFsSgListsSubmit (
// across all device-writeable descriptors, in the order they were
// chained on the ring.
//
- IoVec->Transferred = MIN ((UINTN)TotalBytesWrittenByDevice,
- IoVec->Size);
+ IoVec->Transferred = MIN (
+ (UINTN)TotalBytesWrittenByDevice,
+ IoVec->Size
+ );
TotalBytesWrittenByDevice -= (UINT32)IoVec->Transferred;
}
}
@@ -664,9 +709,10 @@ Unmap:
if (SgList == NULL) {
continue;
}
+
IoVecIdx = SgList->NumVec;
while (IoVecIdx > 0) {
- EFI_STATUS UnmapStatus;
+ EFI_STATUS UnmapStatus;
--IoVecIdx;
IoVec = &SgList->IoVec[IoVecIdx];
@@ -676,8 +722,11 @@ Unmap:
if (!IoVec->Mapped) {
continue;
}
- UnmapStatus = VirtioFs->Virtio->UnmapSharedBuffer (VirtioFs->Virtio,
- IoVec->Mapping);
+
+ UnmapStatus = VirtioFs->Virtio->UnmapSharedBuffer (
+ VirtioFs->Virtio,
+ IoVec->Mapping
+ );
//
// Re-set the following fields to the values they initially got from
// VirtioFsSgListsValidate() -- the above unmapping attempt is considered
@@ -740,7 +789,7 @@ Unmap:
EFI_STATUS
VirtioFsFuseNewRequest (
IN OUT VIRTIO_FS *VirtioFs,
- OUT VIRTIO_FS_FUSE_REQUEST *Request,
+ OUT VIRTIO_FS_FUSE_REQUEST *Request,
IN UINT32 RequestSize,
IN VIRTIO_FS_FUSE_OPCODE Opcode,
IN UINT64 NodeId
@@ -822,15 +871,15 @@ VirtioFsFuseNewRequest (
**/
EFI_STATUS
VirtioFsFuseCheckResponse (
- IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList,
- IN UINT64 RequestId,
- OUT UINTN *TailBufferFill
+ IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList,
+ IN UINT64 RequestId,
+ OUT UINTN *TailBufferFill
)
{
- UINTN NumFixedSizeVec;
- VIRTIO_FS_FUSE_RESPONSE *CommonResp;
- UINT32 TotalTransferred;
- UINTN Idx;
+ UINTN NumFixedSizeVec;
+ VIRTIO_FS_FUSE_RESPONSE *CommonResp;
+ UINT32 TotalTransferred;
+ UINTN Idx;
//
// Ensured by VirtioFsSgListsValidate().
@@ -851,6 +900,7 @@ VirtioFsFuseCheckResponse (
if (ResponseSgList->NumVec == 1) {
return EFI_INVALID_PARAMETER;
}
+
NumFixedSizeVec = ResponseSgList->NumVec - 1;
}
@@ -861,6 +911,7 @@ VirtioFsFuseCheckResponse (
if (ResponseSgList->IoVec[0].Size != sizeof *CommonResp) {
return EFI_INVALID_PARAMETER;
}
+
if (ResponseSgList->IoVec[0].Transferred != ResponseSgList->IoVec[0].Size) {
return EFI_PROTOCOL_ERROR;
}
@@ -869,7 +920,7 @@ VirtioFsFuseCheckResponse (
// FUSE must report the same number of bytes, written by the Virtio
// Filesystem device, as the virtio transport does.
//
- CommonResp = ResponseSgList->IoVec[0].Buffer;
+ CommonResp = ResponseSgList->IoVec[0].Buffer;
TotalTransferred = 0;
for (Idx = 0; Idx < ResponseSgList->NumVec; Idx++) {
//
@@ -878,6 +929,7 @@ VirtioFsFuseCheckResponse (
//
TotalTransferred += (UINT32)ResponseSgList->IoVec[Idx].Transferred;
}
+
if (CommonResp->Len != TotalTransferred) {
return EFI_PROTOCOL_ERROR;
}
@@ -905,7 +957,8 @@ VirtioFsFuseCheckResponse (
ASSERT (NumFixedSizeVec >= 1);
for (Idx = 1; Idx < NumFixedSizeVec; Idx++) {
if (ResponseSgList->IoVec[Idx].Transferred !=
- ResponseSgList->IoVec[Idx].Size) {
+ ResponseSgList->IoVec[Idx].Size)
+ {
return EFI_PROTOCOL_ERROR;
}
}
@@ -936,185 +989,185 @@ VirtioFsFuseCheckResponse (
**/
EFI_STATUS
VirtioFsErrnoToEfiStatus (
- IN INT32 Errno
+ IN INT32 Errno
)
{
switch (Errno) {
- case -1: // EPERM Operation not permitted
- return EFI_SECURITY_VIOLATION;
-
- case -2: // ENOENT No such file or directory
- case -3: // ESRCH No such process
- case -6: // ENXIO No such device or address
- case -10: // ECHILD No child processes
- case -19: // ENODEV No such device
- case -49: // EUNATCH Protocol driver not attached
- case -65: // ENOPKG Package not installed
- case -79: // ELIBACC Can not access a needed shared library
- case -126: // ENOKEY Required key not available
- return EFI_NOT_FOUND;
-
- case -4: // EINTR Interrupted system call
- case -11: // EAGAIN, EWOULDBLOCK Resource temporarily unavailable
- case -16: // EBUSY Device or resource busy
- case -26: // ETXTBSY Text file busy
- case -35: // EDEADLK, EDEADLOCK Resource deadlock avoided
- case -39: // ENOTEMPTY Directory not empty
- case -42: // ENOMSG No message of desired type
- case -61: // ENODATA No data available
- case -85: // ERESTART Interrupted system call should be restarted
- return EFI_NOT_READY;
-
- case -5: // EIO Input/output error
- case -45: // EL2NSYNC Level 2 not synchronized
- case -46: // EL3HLT Level 3 halted
- case -47: // EL3RST Level 3 reset
- case -51: // EL2HLT Level 2 halted
- case -121: // EREMOTEIO Remote I/O error
- case -133: // EHWPOISON Memory page has hardware error
- return EFI_DEVICE_ERROR;
-
- case -7: // E2BIG Argument list too long
- case -36: // ENAMETOOLONG File name too long
- case -90: // EMSGSIZE Message too long
- return EFI_BAD_BUFFER_SIZE;
-
- case -8: // ENOEXEC Exec format error
- case -15: // ENOTBLK Block device required
- case -18: // EXDEV Invalid cross-device link
- case -20: // ENOTDIR Not a directory
- case -21: // EISDIR Is a directory
- case -25: // ENOTTY Inappropriate ioctl for device
- case -27: // EFBIG File too large
- case -29: // ESPIPE Illegal seek
- case -38: // ENOSYS Function not implemented
- case -59: // EBFONT Bad font file format
- case -60: // ENOSTR Device not a stream
- case -83: // ELIBEXEC Cannot exec a shared library directly
- case -88: // ENOTSOCK Socket operation on non-socket
- case -91: // EPROTOTYPE Protocol wrong type for socket
- case -92: // ENOPROTOOPT Protocol not available
- case -93: // EPROTONOSUPPORT Protocol not supported
- case -94: // ESOCKTNOSUPPORT Socket type not supported
- case -95: // ENOTSUP, EOPNOTSUPP Operation not supported
- case -96: // EPFNOSUPPORT Protocol family not supported
- case -97: // EAFNOSUPPORT Address family not supported by protocol
- case -99: // EADDRNOTAVAIL Cannot assign requested address
- case -118: // ENOTNAM Not a XENIX named type file
- case -120: // EISNAM Is a named type file
- case -124: // EMEDIUMTYPE Wrong medium type
- return EFI_UNSUPPORTED;
-
- case -9: // EBADF Bad file descriptor
- case -14: // EFAULT Bad address
- case -44: // ECHRNG Channel number out of range
- case -48: // ELNRNG Link number out of range
- case -53: // EBADR Invalid request descriptor
- case -56: // EBADRQC Invalid request code
- case -57: // EBADSLT Invalid slot
- case -76: // ENOTUNIQ Name not unique on network
- case -84: // EILSEQ Invalid or incomplete multibyte or wide character
- return EFI_NO_MAPPING;
-
- case -12: // ENOMEM Cannot allocate memory
- case -23: // ENFILE Too many open files in system
- case -24: // EMFILE Too many open files
- case -31: // EMLINK Too many links
- case -37: // ENOLCK No locks available
- case -40: // ELOOP Too many levels of symbolic links
- case -50: // ENOCSI No CSI structure available
- case -55: // ENOANO No anode
- case -63: // ENOSR Out of streams resources
- case -82: // ELIBMAX Attempting to link in too many shared libraries
- case -87: // EUSERS Too many users
- case -105: // ENOBUFS No buffer space available
- case -109: // ETOOMANYREFS Too many references: cannot splice
- case -119: // ENAVAIL No XENIX semaphores available
- case -122: // EDQUOT Disk quota exceeded
- return EFI_OUT_OF_RESOURCES;
+ case -1:// EPERM Operation not permitted
+ return EFI_SECURITY_VIOLATION;
+
+ case -2: // ENOENT No such file or directory
+ case -3: // ESRCH No such process
+ case -6: // ENXIO No such device or address
+ case -10: // ECHILD No child processes
+ case -19: // ENODEV No such device
+ case -49: // EUNATCH Protocol driver not attached
+ case -65: // ENOPKG Package not installed
+ case -79: // ELIBACC Can not access a needed shared library
+ case -126: // ENOKEY Required key not available
+ return EFI_NOT_FOUND;
+
+ case -4: // EINTR Interrupted system call
+ case -11: // EAGAIN, EWOULDBLOCK Resource temporarily unavailable
+ case -16: // EBUSY Device or resource busy
+ case -26: // ETXTBSY Text file busy
+ case -35: // EDEADLK, EDEADLOCK Resource deadlock avoided
+ case -39: // ENOTEMPTY Directory not empty
+ case -42: // ENOMSG No message of desired type
+ case -61: // ENODATA No data available
+ case -85: // ERESTART Interrupted system call should be restarted
+ return EFI_NOT_READY;
+
+ case -5: // EIO Input/output error
+ case -45: // EL2NSYNC Level 2 not synchronized
+ case -46: // EL3HLT Level 3 halted
+ case -47: // EL3RST Level 3 reset
+ case -51: // EL2HLT Level 2 halted
+ case -121: // EREMOTEIO Remote I/O error
+ case -133: // EHWPOISON Memory page has hardware error
+ return EFI_DEVICE_ERROR;
+
+ case -7: // E2BIG Argument list too long
+ case -36: // ENAMETOOLONG File name too long
+ case -90: // EMSGSIZE Message too long
+ return EFI_BAD_BUFFER_SIZE;
+
+ case -8: // ENOEXEC Exec format error
+ case -15: // ENOTBLK Block device required
+ case -18: // EXDEV Invalid cross-device link
+ case -20: // ENOTDIR Not a directory
+ case -21: // EISDIR Is a directory
+ case -25: // ENOTTY Inappropriate ioctl for device
+ case -27: // EFBIG File too large
+ case -29: // ESPIPE Illegal seek
+ case -38: // ENOSYS Function not implemented
+ case -59: // EBFONT Bad font file format
+ case -60: // ENOSTR Device not a stream
+ case -83: // ELIBEXEC Cannot exec a shared library directly
+ case -88: // ENOTSOCK Socket operation on non-socket
+ case -91: // EPROTOTYPE Protocol wrong type for socket
+ case -92: // ENOPROTOOPT Protocol not available
+ case -93: // EPROTONOSUPPORT Protocol not supported
+ case -94: // ESOCKTNOSUPPORT Socket type not supported
+ case -95: // ENOTSUP, EOPNOTSUPP Operation not supported
+ case -96: // EPFNOSUPPORT Protocol family not supported
+ case -97: // EAFNOSUPPORT Address family not supported by protocol
+ case -99: // EADDRNOTAVAIL Cannot assign requested address
+ case -118: // ENOTNAM Not a XENIX named type file
+ case -120: // EISNAM Is a named type file
+ case -124: // EMEDIUMTYPE Wrong medium type
+ return EFI_UNSUPPORTED;
- case -13: // EACCES Permission denied
- return EFI_ACCESS_DENIED;
+ case -9: // EBADF Bad file descriptor
+ case -14: // EFAULT Bad address
+ case -44: // ECHRNG Channel number out of range
+ case -48: // ELNRNG Link number out of range
+ case -53: // EBADR Invalid request descriptor
+ case -56: // EBADRQC Invalid request code
+ case -57: // EBADSLT Invalid slot
+ case -76: // ENOTUNIQ Name not unique on network
+ case -84: // EILSEQ Invalid or incomplete multibyte or wide character
+ return EFI_NO_MAPPING;
+
+ case -12: // ENOMEM Cannot allocate memory
+ case -23: // ENFILE Too many open files in system
+ case -24: // EMFILE Too many open files
+ case -31: // EMLINK Too many links
+ case -37: // ENOLCK No locks available
+ case -40: // ELOOP Too many levels of symbolic links
+ case -50: // ENOCSI No CSI structure available
+ case -55: // ENOANO No anode
+ case -63: // ENOSR Out of streams resources
+ case -82: // ELIBMAX Attempting to link in too many shared libraries
+ case -87: // EUSERS Too many users
+ case -105: // ENOBUFS No buffer space available
+ case -109: // ETOOMANYREFS Too many references: cannot splice
+ case -119: // ENAVAIL No XENIX semaphores available
+ case -122: // EDQUOT Disk quota exceeded
+ return EFI_OUT_OF_RESOURCES;
- case -17: // EEXIST File exists
- case -98: // EADDRINUSE Address already in use
- case -106: // EISCONN Transport endpoint is already connected
- case -114: // EALREADY Operation already in progress
- case -115: // EINPROGRESS Operation now in progress
- return EFI_ALREADY_STARTED;
+ case -13:// EACCES Permission denied
+ return EFI_ACCESS_DENIED;
- case -22: // EINVAL Invalid argument
- case -33: // EDOM Numerical argument out of domain
- return EFI_INVALID_PARAMETER;
+ case -17: // EEXIST File exists
+ case -98: // EADDRINUSE Address already in use
+ case -106: // EISCONN Transport endpoint is already connected
+ case -114: // EALREADY Operation already in progress
+ case -115: // EINPROGRESS Operation now in progress
+ return EFI_ALREADY_STARTED;
- case -28: // ENOSPC No space left on device
- case -54: // EXFULL Exchange full
- return EFI_VOLUME_FULL;
-
- case -30: // EROFS Read-only file system
- return EFI_WRITE_PROTECTED;
-
- case -32: // EPIPE Broken pipe
- case -43: // EIDRM Identifier removed
- case -67: // ENOLINK Link has been severed
- case -68: // EADV Advertise error
- case -69: // ESRMNT Srmount error
- case -70: // ECOMM Communication error on send
- case -73: // EDOTDOT RFS specific error
- case -78: // EREMCHG Remote address changed
- case -86: // ESTRPIPE Streams pipe error
- case -102: // ENETRESET Network dropped connection on reset
- case -103: // ECONNABORTED Software caused connection abort
- case -104: // ECONNRESET Connection reset by peer
- case -116: // ESTALE Stale file handle
- case -125: // ECANCELED Operation canceled
- case -128: // EKEYREVOKED Key has been revoked
- case -129: // EKEYREJECTED Key was rejected by service
- case -130: // EOWNERDEAD Owner died
- case -131: // ENOTRECOVERABLE State not recoverable
- return EFI_ABORTED;
-
- case -34: // ERANGE Numerical result out of range
- case -75: // EOVERFLOW Value too large for defined data type
- return EFI_BUFFER_TOO_SMALL;
+ case -22: // EINVAL Invalid argument
+ case -33: // EDOM Numerical argument out of domain
+ return EFI_INVALID_PARAMETER;
- case -52: // EBADE Invalid exchange
- case -108: // ESHUTDOWN Cannot send after transport endpoint shutdown
- case -111: // ECONNREFUSED Connection refused
- return EFI_END_OF_FILE;
-
- case -62: // ETIME Timer expired
- case -110: // ETIMEDOUT Connection timed out
- case -127: // EKEYEXPIRED Key has expired
- return EFI_TIMEOUT;
-
- case -64: // ENONET Machine is not on the network
- case -66: // EREMOTE Object is remote
- case -72: // EMULTIHOP Multihop attempted
- case -100: // ENETDOWN Network is down
- case -101: // ENETUNREACH Network is unreachable
- case -112: // EHOSTDOWN Host is down
- case -113: // EHOSTUNREACH No route to host
- case -123: // ENOMEDIUM No medium found
- case -132: // ERFKILL Operation not possible due to RF-kill
- return EFI_NO_MEDIA;
-
- case -71: // EPROTO Protocol error
- return EFI_PROTOCOL_ERROR;
+ case -28: // ENOSPC No space left on device
+ case -54: // EXFULL Exchange full
+ return EFI_VOLUME_FULL;
+
+ case -30:// EROFS Read-only file system
+ return EFI_WRITE_PROTECTED;
+
+ case -32: // EPIPE Broken pipe
+ case -43: // EIDRM Identifier removed
+ case -67: // ENOLINK Link has been severed
+ case -68: // EADV Advertise error
+ case -69: // ESRMNT Srmount error
+ case -70: // ECOMM Communication error on send
+ case -73: // EDOTDOT RFS specific error
+ case -78: // EREMCHG Remote address changed
+ case -86: // ESTRPIPE Streams pipe error
+ case -102: // ENETRESET Network dropped connection on reset
+ case -103: // ECONNABORTED Software caused connection abort
+ case -104: // ECONNRESET Connection reset by peer
+ case -116: // ESTALE Stale file handle
+ case -125: // ECANCELED Operation canceled
+ case -128: // EKEYREVOKED Key has been revoked
+ case -129: // EKEYREJECTED Key was rejected by service
+ case -130: // EOWNERDEAD Owner died
+ case -131: // ENOTRECOVERABLE State not recoverable
+ return EFI_ABORTED;
+
+ case -34: // ERANGE Numerical result out of range
+ case -75: // EOVERFLOW Value too large for defined data type
+ return EFI_BUFFER_TOO_SMALL;
+
+ case -52: // EBADE Invalid exchange
+ case -108: // ESHUTDOWN Cannot send after transport endpoint shutdown
+ case -111: // ECONNREFUSED Connection refused
+ return EFI_END_OF_FILE;
+
+ case -62: // ETIME Timer expired
+ case -110: // ETIMEDOUT Connection timed out
+ case -127: // EKEYEXPIRED Key has expired
+ return EFI_TIMEOUT;
+
+ case -64: // ENONET Machine is not on the network
+ case -66: // EREMOTE Object is remote
+ case -72: // EMULTIHOP Multihop attempted
+ case -100: // ENETDOWN Network is down
+ case -101: // ENETUNREACH Network is unreachable
+ case -112: // EHOSTDOWN Host is down
+ case -113: // EHOSTUNREACH No route to host
+ case -123: // ENOMEDIUM No medium found
+ case -132: // ERFKILL Operation not possible due to RF-kill
+ return EFI_NO_MEDIA;
+
+ case -71:// EPROTO Protocol error
+ return EFI_PROTOCOL_ERROR;
- case -74: // EBADMSG Bad message
- case -77: // EBADFD File descriptor in bad state
- case -80: // ELIBBAD Accessing a corrupted shared library
- case -81: // ELIBSCN .lib section in a.out corrupted
- case -117: // EUCLEAN Structure needs cleaning
- return EFI_VOLUME_CORRUPTED;
+ case -74: // EBADMSG Bad message
+ case -77: // EBADFD File descriptor in bad state
+ case -80: // ELIBBAD Accessing a corrupted shared library
+ case -81: // ELIBSCN .lib section in a.out corrupted
+ case -117: // EUCLEAN Structure needs cleaning
+ return EFI_VOLUME_CORRUPTED;
- case -89: // EDESTADDRREQ Destination address required
- case -107: // ENOTCONN Transport endpoint is not connected
- return EFI_NOT_STARTED;
+ case -89: // EDESTADDRREQ Destination address required
+ case -107: // ENOTCONN Transport endpoint is not connected
+ return EFI_NOT_STARTED;
- default:
- break;
+ default:
+ break;
}
return EFI_DEVICE_ERROR;
@@ -1151,8 +1204,8 @@ typedef enum {
STATIC
VOID
ParserStripSlash (
- IN CHAR8 *Buffer,
- IN OUT UINTN *Position
+ IN CHAR8 *Buffer,
+ IN OUT UINTN *Position
)
{
ASSERT (*Position >= 1);
@@ -1160,6 +1213,7 @@ ParserStripSlash (
if (*Position == 1) {
return;
}
+
(*Position)--;
}
@@ -1182,10 +1236,10 @@ ParserStripSlash (
STATIC
VOID
ParserCopy (
- OUT CHAR8 *Buffer,
- IN OUT UINTN *Position,
- IN UINTN Size,
- IN CHAR8 Char8
+ OUT CHAR8 *Buffer,
+ IN OUT UINTN *Position,
+ IN UINTN Size,
+ IN CHAR8 Char8
)
{
ASSERT (*Position < Size);
@@ -1209,8 +1263,8 @@ ParserCopy (
STATIC
VOID
ParserRewindDot (
- IN CHAR8 *Buffer,
- IN OUT UINTN *Position
+ IN CHAR8 *Buffer,
+ IN OUT UINTN *Position
)
{
ASSERT (*Position >= 2);
@@ -1252,9 +1306,9 @@ ParserRewindDot (
STATIC
VOID
ParserRewindDotDot (
- IN CHAR8 *Buffer,
- IN OUT UINTN *Position,
- OUT BOOLEAN *RootEscape
+ IN CHAR8 *Buffer,
+ IN OUT UINTN *Position,
+ OUT BOOLEAN *RootEscape
)
{
@@ -1283,6 +1337,7 @@ ParserRewindDotDot (
ASSERT (*Position > 0);
(*Position)--;
} while (Buffer[*Position] != '/');
+
(*Position)++;
}
@@ -1349,19 +1404,19 @@ EFI_STATUS
VirtioFsAppendPath (
IN CHAR8 *LhsPath8,
IN CHAR16 *RhsPath16,
- OUT CHAR8 **ResultPath8,
- OUT BOOLEAN *RootEscape
+ OUT CHAR8 **ResultPath8,
+ OUT BOOLEAN *RootEscape
)
{
- UINTN RhsLen;
- CHAR8 *RhsPath8;
- UINTN Idx;
- EFI_STATUS Status;
- UINTN SizeToSanitize;
- CHAR8 *BufferToSanitize;
- CHAR8 *SanitizedBuffer;
- PARSER_STATE State;
- UINTN SanitizedPosition;
+ UINTN RhsLen;
+ CHAR8 *RhsPath8;
+ UINTN Idx;
+ EFI_STATUS Status;
+ UINTN SizeToSanitize;
+ CHAR8 *BufferToSanitize;
+ CHAR8 *SanitizedBuffer;
+ PARSER_STATE State;
+ UINTN SanitizedPosition;
//
// Appending an empty pathname is not allowed.
@@ -1370,6 +1425,7 @@ VirtioFsAppendPath (
if (RhsLen == 0) {
return EFI_INVALID_PARAMETER;
}
+
//
// Enforce length restriction on RhsPath16.
//
@@ -1388,14 +1444,18 @@ VirtioFsAppendPath (
if (RhsPath8 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
for (Idx = 0; RhsPath16[Idx] != L'\0'; Idx++) {
- if (RhsPath16[Idx] < 0x20 || RhsPath16[Idx] > 0x7E ||
- RhsPath16[Idx] == L'/') {
+ if ((RhsPath16[Idx] < 0x20) || (RhsPath16[Idx] > 0x7E) ||
+ (RhsPath16[Idx] == L'/'))
+ {
Status = EFI_UNSUPPORTED;
goto FreeRhsPath8;
}
+
RhsPath8[Idx] = (CHAR8)((RhsPath16[Idx] == L'\\') ? L'/' : RhsPath16[Idx]);
}
+
RhsPath8[Idx++] = '\0';
//
@@ -1412,22 +1472,23 @@ VirtioFsAppendPath (
// If the right hand side path is absolute, then it is not appended to the
// left hand side path -- it *replaces* the left hand side path.
//
- SizeToSanitize = RhsLen + 1;
+ SizeToSanitize = RhsLen + 1;
BufferToSanitize = RhsPath8;
} else {
//
// If the right hand side path is relative, then it is appended (naively)
// to the left hand side.
//
- UINTN LhsLen;
+ UINTN LhsLen;
- LhsLen = AsciiStrLen (LhsPath8);
- SizeToSanitize = LhsLen + 1 + RhsLen + 1;
+ LhsLen = AsciiStrLen (LhsPath8);
+ SizeToSanitize = LhsLen + 1 + RhsLen + 1;
BufferToSanitize = AllocatePool (SizeToSanitize);
if (BufferToSanitize == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeRhsPath8;
}
+
CopyMem (BufferToSanitize, LhsPath8, LhsLen);
BufferToSanitize[LhsLen] = '/';
CopyMem (BufferToSanitize + LhsLen + 1, RhsPath8, RhsLen + 1);
@@ -1451,113 +1512,117 @@ VirtioFsAppendPath (
State = ParserInit;
SanitizedPosition = 0;
do {
- CHAR8 Chr8;
+ CHAR8 Chr8;
ASSERT (Idx < SizeToSanitize);
Chr8 = BufferToSanitize[Idx++];
switch (State) {
- case ParserInit: // just starting
- ASSERT (Chr8 == '/');
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserSlash;
- break;
-
- case ParserSlash: // slash(es) seen
- switch (Chr8) {
- case '\0':
- ParserStripSlash (SanitizedBuffer, &SanitizedPosition);
+ case ParserInit: // just starting
+ ASSERT (Chr8 == '/');
ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserEnd;
- break;
- case '/':
- //
- // skip & stay in same state
- //
- break;
- case '.':
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserDot;
- break;
- default:
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserNormal;
- break;
- }
- break;
-
- case ParserDot: // one dot seen since last slash
- switch (Chr8) {
- case '\0':
- ParserRewindDot (SanitizedBuffer, &SanitizedPosition);
- ParserStripSlash (SanitizedBuffer, &SanitizedPosition);
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserEnd;
- break;
- case '/':
- ParserRewindDot (SanitizedBuffer, &SanitizedPosition);
State = ParserSlash;
break;
- case '.':
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserDotDot;
- break;
- default:
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserNormal;
- break;
- }
- break;
- case ParserDotDot: // two dots seen since last slash
- switch (Chr8) {
- case '\0':
- ParserRewindDotDot (SanitizedBuffer, &SanitizedPosition, RootEscape);
- ParserStripSlash (SanitizedBuffer, &SanitizedPosition);
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserEnd;
- break;
- case '/':
- ParserRewindDotDot (SanitizedBuffer, &SanitizedPosition, RootEscape);
- State = ParserSlash;
+ case ParserSlash: // slash(es) seen
+ switch (Chr8) {
+ case '\0':
+ ParserStripSlash (SanitizedBuffer, &SanitizedPosition);
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserEnd;
+ break;
+ case '/':
+ //
+ // skip & stay in same state
+ //
+ break;
+ case '.':
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserDot;
+ break;
+ default:
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserNormal;
+ break;
+ }
+
break;
- case '.':
- //
- // fall through
- //
- default:
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserNormal;
+
+ case ParserDot: // one dot seen since last slash
+ switch (Chr8) {
+ case '\0':
+ ParserRewindDot (SanitizedBuffer, &SanitizedPosition);
+ ParserStripSlash (SanitizedBuffer, &SanitizedPosition);
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserEnd;
+ break;
+ case '/':
+ ParserRewindDot (SanitizedBuffer, &SanitizedPosition);
+ State = ParserSlash;
+ break;
+ case '.':
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserDotDot;
+ break;
+ default:
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserNormal;
+ break;
+ }
+
break;
- }
- break;
- case ParserNormal: // a different sequence seen
- switch (Chr8) {
- case '\0':
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserEnd;
+ case ParserDotDot: // two dots seen since last slash
+ switch (Chr8) {
+ case '\0':
+ ParserRewindDotDot (SanitizedBuffer, &SanitizedPosition, RootEscape);
+ ParserStripSlash (SanitizedBuffer, &SanitizedPosition);
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserEnd;
+ break;
+ case '/':
+ ParserRewindDotDot (SanitizedBuffer, &SanitizedPosition, RootEscape);
+ State = ParserSlash;
+ break;
+ case '.':
+ //
+ // fall through
+ //
+ default:
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserNormal;
+ break;
+ }
+
break;
- case '/':
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
- State = ParserSlash;
+
+ case ParserNormal: // a different sequence seen
+ switch (Chr8) {
+ case '\0':
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserEnd;
+ break;
+ case '/':
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ State = ParserSlash;
+ break;
+ case '.':
+ //
+ // fall through
+ //
+ default:
+ //
+ // copy and stay in same state
+ //
+ ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ break;
+ }
+
break;
- case '.':
- //
- // fall through
- //
+
default:
- //
- // copy and stay in same state
- //
- ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
+ ASSERT (FALSE);
break;
- }
- break;
-
- default:
- ASSERT (FALSE);
- break;
}
} while (State != ParserEnd);
@@ -1634,16 +1699,16 @@ FreeRhsPath8:
**/
EFI_STATUS
VirtioFsLookupMostSpecificParentDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN OUT CHAR8 *Path,
- OUT UINT64 *DirNodeId,
- OUT CHAR8 **LastComponent
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN OUT CHAR8 *Path,
+ OUT UINT64 *DirNodeId,
+ OUT CHAR8 **LastComponent
)
{
- UINT64 ParentDirNodeId;
- CHAR8 *Slash;
- EFI_STATUS Status;
- UINT64 NextDirNodeId;
+ UINT64 ParentDirNodeId;
+ CHAR8 *Slash;
+ EFI_STATUS Status;
+ UINT64 NextDirNodeId;
if (AsciiStrCmp (Path, "/") == 0) {
return EFI_INVALID_PARAMETER;
@@ -1651,10 +1716,10 @@ VirtioFsLookupMostSpecificParentDir (
ParentDirNodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;
Slash = Path;
- for (;;) {
- CHAR8 *NextSlash;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
- EFI_FILE_INFO FileInfo;
+ for ( ; ;) {
+ CHAR8 *NextSlash;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ EFI_FILE_INFO FileInfo;
//
// Find the slash (if any) that terminates the next pathname component.
@@ -1670,8 +1735,13 @@ VirtioFsLookupMostSpecificParentDir (
// up.
//
*NextSlash = '\0';
- Status = VirtioFsFuseLookup (VirtioFs, ParentDirNodeId, Slash + 1,
- &NextDirNodeId, &FuseAttr);
+ Status = VirtioFsFuseLookup (
+ VirtioFs,
+ ParentDirNodeId,
+ Slash + 1,
+ &NextDirNodeId,
+ &FuseAttr
+ );
*NextSlash = '/';
//
@@ -1696,6 +1766,7 @@ VirtioFsLookupMostSpecificParentDir (
if (EFI_ERROR (Status)) {
goto ForgetNextDirNodeId;
}
+
if ((FileInfo.Attribute & EFI_FILE_DIRECTORY) == 0) {
Status = EFI_ACCESS_DENIED;
goto ForgetNextDirNodeId;
@@ -1751,14 +1822,14 @@ ForgetNextDirNodeId:
EFI_STATUS
VirtioFsGetBasename (
IN CHAR8 *Path,
- OUT CHAR16 *Basename OPTIONAL,
+ OUT CHAR16 *Basename OPTIONAL,
IN OUT UINTN *BasenameSize
)
{
- UINTN AllocSize;
- UINTN LastComponent;
- UINTN Idx;
- UINTN PathSize;
+ UINTN AllocSize;
+ UINTN LastComponent;
+ UINTN Idx;
+ UINTN PathSize;
AllocSize = *BasenameSize;
@@ -1768,6 +1839,7 @@ VirtioFsGetBasename (
LastComponent = Idx;
}
}
+
PathSize = Idx + 1;
ASSERT (LastComponent < MAX_UINTN);
LastComponent++;
@@ -1780,6 +1852,7 @@ VirtioFsGetBasename (
for (Idx = LastComponent; Idx < PathSize; Idx++) {
Basename[Idx - LastComponent] = Path[Idx];
}
+
return EFI_SUCCESS;
}
@@ -1845,8 +1918,8 @@ EFI_STATUS
VirtioFsComposeRenameDestination (
IN CHAR8 *LhsPath8,
IN CHAR16 *RhsPath16,
- OUT CHAR8 **ResultPath8,
- OUT BOOLEAN *RootEscape
+ OUT CHAR8 **ResultPath8,
+ OUT BOOLEAN *RootEscape
)
{
//
@@ -1854,13 +1927,13 @@ VirtioFsComposeRenameDestination (
// excluding terminating NULs. Sizes are expressed as byte counts, including
// the bytes taken up by terminating NULs.
//
- UINTN RhsLen;
- UINTN LhsBasename16Size;
- EFI_STATUS Status;
- UINTN LhsBasenameLen;
- UINTN DestSuffix16Size;
- CHAR16 *DestSuffix16;
- CHAR8 *DestPrefix8;
+ UINTN RhsLen;
+ UINTN LhsBasename16Size;
+ EFI_STATUS Status;
+ UINTN LhsBasenameLen;
+ UINTN DestSuffix16Size;
+ CHAR16 *DestSuffix16;
+ CHAR8 *DestPrefix8;
//
// An empty destination operand for the rename/move operation is not allowed.
@@ -1869,6 +1942,7 @@ VirtioFsComposeRenameDestination (
if (RhsLen == 0) {
return EFI_INVALID_PARAMETER;
}
+
//
// Enforce length restriction on RhsPath16.
//
@@ -1880,7 +1954,7 @@ VirtioFsComposeRenameDestination (
// Determine the length of the basename of LhsPath8.
//
LhsBasename16Size = 0;
- Status = VirtioFsGetBasename (LhsPath8, NULL, &LhsBasename16Size);
+ Status = VirtioFsGetBasename (LhsPath8, NULL, &LhsBasename16Size);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
ASSERT (LhsBasename16Size >= sizeof (CHAR16));
ASSERT (LhsBasename16Size % sizeof (CHAR16) == 0);
@@ -1900,20 +1974,24 @@ VirtioFsComposeRenameDestination (
// Append the basename of LhsPath8 as a CHAR16 string to RhsPath16.
//
DestSuffix16Size = RhsLen * sizeof (CHAR16) + LhsBasename16Size;
- DestSuffix16 = AllocatePool (DestSuffix16Size);
+ DestSuffix16 = AllocatePool (DestSuffix16Size);
if (DestSuffix16 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (DestSuffix16, RhsPath16, RhsLen * sizeof (CHAR16));
- Status = VirtioFsGetBasename (LhsPath8, DestSuffix16 + RhsLen,
- &LhsBasename16Size);
+ Status = VirtioFsGetBasename (
+ LhsPath8,
+ DestSuffix16 + RhsLen,
+ &LhsBasename16Size
+ );
ASSERT_EFI_ERROR (Status);
} else {
//
// Just create a copy of RhsPath16.
//
DestSuffix16Size = (RhsLen + 1) * sizeof (CHAR16);
- DestSuffix16 = AllocateCopyPool (DestSuffix16Size, RhsPath16);
+ DestSuffix16 = AllocateCopyPool (DestSuffix16Size, RhsPath16);
if (DestSuffix16 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1935,8 +2013,8 @@ VirtioFsComposeRenameDestination (
goto FreeDestSuffix16;
}
} else {
- UINTN LhsLen;
- UINTN DestPrefixLen;
+ UINTN LhsLen;
+ UINTN DestPrefixLen;
//
// Strip the basename of LhsPath8.
@@ -1951,11 +2029,13 @@ VirtioFsComposeRenameDestination (
if (DestPrefixLen > 1) {
DestPrefixLen--;
}
+
DestPrefix8 = AllocatePool (DestPrefixLen + 1);
if (DestPrefix8 == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeDestSuffix16;
}
+
CopyMem (DestPrefix8, LhsPath8, DestPrefixLen);
DestPrefix8[DestPrefixLen] = '\0';
}
@@ -1964,8 +2044,12 @@ VirtioFsComposeRenameDestination (
// Now combine DestPrefix8 and DestSuffix16 into the final canonical
// pathname.
//
- Status = VirtioFsAppendPath (DestPrefix8, DestSuffix16, ResultPath8,
- RootEscape);
+ Status = VirtioFsAppendPath (
+ DestPrefix8,
+ DestSuffix16,
+ ResultPath8,
+ RootEscape
+ );
FreePool (DestPrefix8);
//
@@ -2004,13 +2088,13 @@ FreeDestSuffix16:
**/
EFI_STATUS
VirtioFsFuseAttrToEfiFileInfo (
- IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr,
- OUT EFI_FILE_INFO *FileInfo
+ IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr,
+ OUT EFI_FILE_INFO *FileInfo
)
{
- UINT64 EpochTime[3];
- EFI_TIME *ConvertedTime[ARRAY_SIZE (EpochTime)];
- UINTN Idx;
+ UINT64 EpochTime[3];
+ EFI_TIME *ConvertedTime[ARRAY_SIZE (EpochTime)];
+ UINTN Idx;
FileInfo->FileSize = FuseAttr->Size;
@@ -2020,6 +2104,7 @@ VirtioFsFuseAttrToEfiFileInfo (
if (FuseAttr->Blocks >= BIT55) {
return EFI_UNSUPPORTED;
}
+
FileInfo->PhysicalSize = LShiftU64 (FuseAttr->Blocks, 9);
//
@@ -2041,6 +2126,7 @@ VirtioFsFuseAttrToEfiFileInfo (
if (EpochTime[Idx] > MAX_UINTN) {
return EFI_UNSUPPORTED;
}
+
//
// Set the following fields in the converted time: Year, Month, Day, Hour,
// Minute, Second, Nanosecond.
@@ -2063,32 +2149,34 @@ VirtioFsFuseAttrToEfiFileInfo (
// Set the attributes.
//
switch (FuseAttr->Mode & VIRTIO_FS_FUSE_MODE_TYPE_MASK) {
- case VIRTIO_FS_FUSE_MODE_TYPE_DIR:
- FileInfo->Attribute = EFI_FILE_DIRECTORY;
- break;
- case VIRTIO_FS_FUSE_MODE_TYPE_REG:
- FileInfo->Attribute = 0;
- break;
- default:
- //
- // Other file types are not supported.
- //
- return EFI_UNSUPPORTED;
+ case VIRTIO_FS_FUSE_MODE_TYPE_DIR:
+ FileInfo->Attribute = EFI_FILE_DIRECTORY;
+ break;
+ case VIRTIO_FS_FUSE_MODE_TYPE_REG:
+ FileInfo->Attribute = 0;
+ break;
+ default:
+ //
+ // Other file types are not supported.
+ //
+ return EFI_UNSUPPORTED;
}
+
//
// Report the regular file or directory as read-only if all classes lack
// write permission.
//
if ((FuseAttr->Mode & (VIRTIO_FS_FUSE_MODE_PERM_WUSR |
VIRTIO_FS_FUSE_MODE_PERM_WGRP |
- VIRTIO_FS_FUSE_MODE_PERM_WOTH)) == 0) {
+ VIRTIO_FS_FUSE_MODE_PERM_WOTH)) == 0)
+ {
FileInfo->Attribute |= EFI_FILE_READ_ONLY;
}
//
// A hard link count greater than 1 is not supported for regular files.
//
- if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) == 0 && FuseAttr->Nlink > 1) {
+ if (((FileInfo->Attribute & EFI_FILE_DIRECTORY) == 0) && (FuseAttr->Nlink > 1)) {
return EFI_UNSUPPORTED;
}
@@ -2129,19 +2217,20 @@ VirtioFsFuseAttrToEfiFileInfo (
**/
EFI_STATUS
VirtioFsFuseDirentPlusToEfiFileInfo (
- IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent,
- IN OUT EFI_FILE_INFO *FileInfo
+ IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent,
+ IN OUT EFI_FILE_INFO *FileInfo
)
{
- UINTN DirentSize;
- UINTN FileInfoSize;
- UINT8 *DirentName;
- UINT32 Idx;
+ UINTN DirentSize;
+ UINTN FileInfoSize;
+ UINT8 *DirentName;
+ UINT32 Idx;
DirentSize = VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE (FuseDirent->Namelen);
if (DirentSize == 0) {
return EFI_INVALID_PARAMETER;
}
+
//
// We're now safe from overflow in the calculation below.
//
@@ -2156,15 +2245,18 @@ VirtioFsFuseDirentPlusToEfiFileInfo (
//
DirentName = (UINT8 *)(FuseDirent + 1);
for (Idx = 0; Idx < FuseDirent->Namelen; Idx++) {
- UINT8 NameByte;
+ UINT8 NameByte;
NameByte = DirentName[Idx];
- if (NameByte < 0x20 || NameByte > 0x7E ||
- NameByte == '/' || NameByte == '\\') {
+ if ((NameByte < 0x20) || (NameByte > 0x7E) ||
+ (NameByte == '/') || (NameByte == '\\'))
+ {
return EFI_UNSUPPORTED;
}
+
FileInfo->FileName[Idx] = (CHAR16)NameByte;
}
+
FileInfo->FileName[Idx++] = L'\0';
//
// Set the (possibly reduced) size.
@@ -2196,22 +2288,23 @@ VirtioFsFuseDirentPlusToEfiFileInfo (
**/
VOID
VirtioFsGetFuseSizeUpdate (
- IN EFI_FILE_INFO *Info,
- IN EFI_FILE_INFO *NewInfo,
- OUT BOOLEAN *Update,
- OUT UINT64 *Size
+ IN EFI_FILE_INFO *Info,
+ IN EFI_FILE_INFO *NewInfo,
+ OUT BOOLEAN *Update,
+ OUT UINT64 *Size
)
{
- BOOLEAN IsDirectory;
+ BOOLEAN IsDirectory;
IsDirectory = (BOOLEAN)((Info->Attribute & EFI_FILE_DIRECTORY) != 0);
- if (IsDirectory || Info->FileSize == NewInfo->FileSize) {
+ if (IsDirectory || (Info->FileSize == NewInfo->FileSize)) {
*Update = FALSE;
return;
}
+
*Update = TRUE;
- *Size = NewInfo->FileSize;
+ *Size = NewInfo->FileSize;
}
/**
@@ -2260,20 +2353,20 @@ VirtioFsGetFuseSizeUpdate (
**/
EFI_STATUS
VirtioFsGetFuseTimeUpdates (
- IN EFI_FILE_INFO *Info,
- IN EFI_FILE_INFO *NewInfo,
- OUT BOOLEAN *UpdateAtime,
- OUT BOOLEAN *UpdateMtime,
- OUT UINT64 *Atime,
- OUT UINT64 *Mtime
+ IN EFI_FILE_INFO *Info,
+ IN EFI_FILE_INFO *NewInfo,
+ OUT BOOLEAN *UpdateAtime,
+ OUT BOOLEAN *UpdateMtime,
+ OUT UINT64 *Atime,
+ OUT UINT64 *Mtime
)
{
- EFI_TIME *Time[3];
- EFI_TIME *NewTime[ARRAY_SIZE (Time)];
- UINTN Idx;
- STATIC CONST EFI_TIME ZeroTime = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- BOOLEAN Change[ARRAY_SIZE (Time)];
- UINT64 Seconds[ARRAY_SIZE (Time)];
+ EFI_TIME *Time[3];
+ EFI_TIME *NewTime[ARRAY_SIZE (Time)];
+ UINTN Idx;
+ STATIC CONST EFI_TIME ZeroTime = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ BOOLEAN Change[ARRAY_SIZE (Time)];
+ UINT64 Seconds[ARRAY_SIZE (Time)];
Time[0] = &Info->CreateTime;
Time[1] = &Info->LastAccessTime;
@@ -2288,14 +2381,16 @@ VirtioFsGetFuseTimeUpdates (
// changed, calculate the seconds since the Epoch.
//
for (Idx = 0; Idx < ARRAY_SIZE (Time); Idx++) {
- if (CompareMem (NewTime[Idx], &ZeroTime, sizeof (EFI_TIME)) == 0 ||
- CompareMem (NewTime[Idx], Time[Idx], sizeof (EFI_TIME)) == 0) {
+ if ((CompareMem (NewTime[Idx], &ZeroTime, sizeof (EFI_TIME)) == 0) ||
+ (CompareMem (NewTime[Idx], Time[Idx], sizeof (EFI_TIME)) == 0))
+ {
Change[Idx] = FALSE;
} else {
if (!IsTimeValid (NewTime[Idx])) {
return EFI_INVALID_PARAMETER;
}
- Change[Idx] = TRUE;
+
+ Change[Idx] = TRUE;
Seconds[Idx] = EfiTimeToEpoch (NewTime[Idx]);
}
}
@@ -2307,7 +2402,7 @@ VirtioFsGetFuseTimeUpdates (
// last modification time. If changes are requested for both, but to
// different timestamps, we reject the request.
//
- if (Change[0] && Change[2] && Seconds[0] != Seconds[2]) {
+ if (Change[0] && Change[2] && (Seconds[0] != Seconds[2])) {
return EFI_ACCESS_DENIED;
}
@@ -2316,15 +2411,17 @@ VirtioFsGetFuseTimeUpdates (
if (Change[0]) {
*UpdateMtime = TRUE;
- *Mtime = Seconds[0];
+ *Mtime = Seconds[0];
}
+
if (Change[1]) {
*UpdateAtime = TRUE;
- *Atime = Seconds[1];
+ *Atime = Seconds[1];
}
+
if (Change[2]) {
*UpdateMtime = TRUE;
- *Mtime = Seconds[2];
+ *Mtime = Seconds[2];
}
return EFI_SUCCESS;
@@ -2360,16 +2457,16 @@ VirtioFsGetFuseTimeUpdates (
**/
EFI_STATUS
VirtioFsGetFuseModeUpdate (
- IN EFI_FILE_INFO *Info,
- IN EFI_FILE_INFO *NewInfo,
- OUT BOOLEAN *Update,
- OUT UINT32 *Mode
- )
+ IN EFI_FILE_INFO *Info,
+ IN EFI_FILE_INFO *NewInfo,
+ OUT BOOLEAN *Update,
+ OUT UINT32 *Mode
+ )
{
- UINT64 Toggle;
- BOOLEAN IsDirectory;
- BOOLEAN IsWriteable;
- BOOLEAN WillBeWriteable;
+ UINT64 Toggle;
+ BOOLEAN IsDirectory;
+ BOOLEAN IsWriteable;
+ BOOLEAN WillBeWriteable;
Toggle = Info->Attribute ^ NewInfo->Attribute;
if ((Toggle & ~EFI_FILE_VALID_ATTR) != 0) {
@@ -2378,6 +2475,7 @@ VirtioFsGetFuseModeUpdate (
//
return EFI_ACCESS_DENIED;
}
+
if ((Toggle & EFI_FILE_DIRECTORY) != 0) {
//
// EFI_FILE_DIRECTORY cannot be toggled.
@@ -2421,6 +2519,7 @@ VirtioFsGetFuseModeUpdate (
VIRTIO_FS_FUSE_MODE_PERM_ROTH);
}
}
+
*Update = TRUE;
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
index 4c1cf52112..0cae2126b7 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
@@ -14,11 +14,11 @@
EFI_STATUS
EFIAPI
VirtioFsSimpleFileClose (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -34,16 +34,27 @@ VirtioFsSimpleFileClose (
//
if (VirtioFsFile->IsOpenForWriting) {
if (!VirtioFsFile->IsDirectory) {
- VirtioFsFuseFlush (VirtioFs, VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle);
+ VirtioFsFuseFlush (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle
+ );
}
- VirtioFsFuseFsyncFileOrDir (VirtioFs, VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
+ VirtioFsFuseFsyncFileOrDir (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ VirtioFsFile->IsDirectory
+ );
}
- VirtioFsFuseReleaseFileOrDir (VirtioFs, VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
+ VirtioFsFuseReleaseFileOrDir (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ VirtioFsFile->IsDirectory
+ );
//
// VirtioFsFile->FuseHandle is gone at this point, but VirtioFsFile->NodeId
@@ -63,6 +74,7 @@ VirtioFsSimpleFileClose (
if (VirtioFsFile->FileInfoArray != NULL) {
FreePool (VirtioFsFile->FileInfoArray);
}
+
FreePool (VirtioFsFile);
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
index 76a868b3c2..e745c4e252 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
@@ -14,12 +14,12 @@
EFI_STATUS
EFIAPI
VirtioFsSimpleFileDelete (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -38,8 +38,12 @@ VirtioFsSimpleFileDelete (
//
// If any action fails below, we still try the others.
//
- VirtioFsFuseReleaseFileOrDir (VirtioFs, VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
+ VirtioFsFuseReleaseFileOrDir (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ VirtioFsFile->IsDirectory
+ );
//
// VirtioFsFile->FuseHandle is gone at this point, but VirtioFsFile->NodeId
@@ -47,8 +51,8 @@ VirtioFsSimpleFileDelete (
// of this operation determines the return status of the function.
//
if (VirtioFsFile->IsOpenForWriting) {
- UINT64 ParentNodeId;
- CHAR8 *LastComponent;
+ UINT64 ParentNodeId;
+ CHAR8 *LastComponent;
//
// Split our canonical pathname into most specific parent directory
@@ -78,6 +82,7 @@ VirtioFsSimpleFileDelete (
VirtioFsFuseForget (VirtioFs, ParentNodeId);
}
}
+
if (EFI_ERROR (Status)) {
//
// Map any failure to the spec-mandated warning code.
@@ -105,6 +110,7 @@ VirtioFsSimpleFileDelete (
if (VirtioFsFile->FileInfoArray != NULL) {
FreePool (VirtioFsFile->FileInfoArray);
}
+
FreePool (VirtioFsFile);
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c b/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
index ba4a611e5a..d7d04b94e5 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
@@ -11,12 +11,12 @@
EFI_STATUS
EFIAPI
VirtioFsSimpleFileFlush (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -29,14 +29,21 @@ VirtioFsSimpleFileFlush (
// FUSE_FLUSH is for regular files only.
//
if (!VirtioFsFile->IsDirectory) {
- Status = VirtioFsFuseFlush (VirtioFs, VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle);
+ Status = VirtioFsFuseFlush (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
- Status = VirtioFsFuseFsyncFileOrDir (VirtioFs, VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
+ Status = VirtioFsFuseFsyncFileOrDir (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ VirtioFsFile->IsDirectory
+ );
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsGetInfo.c b/OvmfPkg/VirtioFsDxe/SimpleFsGetInfo.c
index c8be1d5022..d4dc642c4d 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsGetInfo.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsGetInfo.c
@@ -19,18 +19,18 @@
STATIC
EFI_STATUS
GetFileInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- UINTN AllocSize;
- UINTN BasenameSize;
- EFI_STATUS Status;
- EFI_FILE_INFO *FileInfo;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ UINTN AllocSize;
+ UINTN BasenameSize;
+ EFI_STATUS Status;
+ EFI_FILE_INFO *FileInfo;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -41,8 +41,11 @@ GetFileInfo (
// Calculate the needed size.
//
BasenameSize = 0;
- Status = VirtioFsGetBasename (VirtioFsFile->CanonicalPathname, NULL,
- &BasenameSize);
+ Status = VirtioFsGetBasename (
+ VirtioFsFile->CanonicalPathname,
+ NULL,
+ &BasenameSize
+ );
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
*BufferSize = OFFSET_OF (EFI_FILE_INFO, FileName) + BasenameSize;
@@ -53,10 +56,13 @@ GetFileInfo (
//
// Set the structure size, and store the basename.
//
- FileInfo = Buffer;
+ FileInfo = Buffer;
FileInfo->Size = *BufferSize;
- Status = VirtioFsGetBasename (VirtioFsFile->CanonicalPathname,
- FileInfo->FileName, &BasenameSize);
+ Status = VirtioFsGetBasename (
+ VirtioFsFile->CanonicalPathname,
+ FileInfo->FileName,
+ &BasenameSize
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -66,6 +72,7 @@ GetFileInfo (
if (!EFI_ERROR (Status)) {
Status = VirtioFsFuseAttrToEfiFileInfo (&FuseAttr, FileInfo);
}
+
return (Status == EFI_BUFFER_TOO_SMALL) ? EFI_DEVICE_ERROR : Status;
}
@@ -75,19 +82,19 @@ GetFileInfo (
STATIC
EFI_STATUS
GetFileSystemInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- UINTN AllocSize;
- UINTN LabelSize;
- EFI_STATUS Status;
- VIRTIO_FS_FUSE_STATFS_RESPONSE FilesysAttr;
- UINT64 MaxBlocks;
- EFI_FILE_SYSTEM_INFO *FilesysInfo;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ UINTN AllocSize;
+ UINTN LabelSize;
+ EFI_STATUS Status;
+ VIRTIO_FS_FUSE_STATFS_RESPONSE FilesysAttr;
+ UINT64 MaxBlocks;
+ EFI_FILE_SYSTEM_INFO *FilesysInfo;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -97,7 +104,7 @@ GetFileSystemInfo (
//
// Calculate the needed size.
//
- LabelSize = StrSize (VirtioFs->Label);
+ LabelSize = StrSize (VirtioFs->Label);
*BufferSize = OFFSET_OF (EFI_FILE_SYSTEM_INFO, VolumeLabel) + LabelSize;
if (*BufferSize > AllocSize) {
@@ -111,18 +118,22 @@ GetFileSystemInfo (
if (EFI_ERROR (Status)) {
return (Status == EFI_BUFFER_TOO_SMALL) ? EFI_DEVICE_ERROR : Status;
}
+
//
// Sanity checks...
//
if (FilesysAttr.Frsize != FilesysAttr.Bsize) {
return EFI_UNSUPPORTED;
}
- if (FilesysAttr.Frsize == 0 || FilesysAttr.Blocks == 0 ||
- FilesysAttr.Bavail > FilesysAttr.Blocks) {
+
+ if ((FilesysAttr.Frsize == 0) || (FilesysAttr.Blocks == 0) ||
+ (FilesysAttr.Bavail > FilesysAttr.Blocks))
+ {
return EFI_DEVICE_ERROR;
}
+
MaxBlocks = DivU64x32 (MAX_UINT64, FilesysAttr.Frsize);
- if (FilesysAttr.Blocks > MaxBlocks || FilesysAttr.Bavail > MaxBlocks) {
+ if ((FilesysAttr.Blocks > MaxBlocks) || (FilesysAttr.Bavail > MaxBlocks)) {
return EFI_DEVICE_ERROR;
}
@@ -132,11 +143,15 @@ GetFileSystemInfo (
FilesysInfo = Buffer;
FilesysInfo->Size = *BufferSize;
FilesysInfo->ReadOnly = FALSE;
- FilesysInfo->VolumeSize = MultU64x32 (FilesysAttr.Blocks,
- FilesysAttr.Frsize);
- FilesysInfo->FreeSpace = MultU64x32 (FilesysAttr.Bavail,
- FilesysAttr.Frsize);
- FilesysInfo->BlockSize = FilesysAttr.Frsize;
+ FilesysInfo->VolumeSize = MultU64x32 (
+ FilesysAttr.Blocks,
+ FilesysAttr.Frsize
+ );
+ FilesysInfo->FreeSpace = MultU64x32 (
+ FilesysAttr.Bavail,
+ FilesysAttr.Frsize
+ );
+ FilesysInfo->BlockSize = FilesysAttr.Frsize;
CopyMem (FilesysInfo->VolumeLabel, VirtioFs->Label, LabelSize);
return EFI_SUCCESS;
@@ -148,16 +163,16 @@ GetFileSystemInfo (
STATIC
EFI_STATUS
GetFileSystemVolumeLabelInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- UINTN AllocSize;
- UINTN LabelSize;
- EFI_FILE_SYSTEM_VOLUME_LABEL *FilesysVolumeLabel;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ UINTN AllocSize;
+ UINTN LabelSize;
+ EFI_FILE_SYSTEM_VOLUME_LABEL *FilesysVolumeLabel;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -167,7 +182,7 @@ GetFileSystemVolumeLabelInfo (
//
// Calculate the needed size.
//
- LabelSize = StrSize (VirtioFs->Label);
+ LabelSize = StrSize (VirtioFs->Label);
*BufferSize = (OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel) +
LabelSize);
@@ -187,10 +202,10 @@ GetFileSystemVolumeLabelInfo (
EFI_STATUS
EFIAPI
VirtioFsSimpleFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c b/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c
index 53212621e9..6c30dcec57 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c
@@ -12,16 +12,17 @@
EFI_STATUS
EFIAPI
VirtioFsSimpleFileGetPosition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS_FILE *VirtioFsFile;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
if (VirtioFsFile->IsDirectory) {
return EFI_UNSUPPORTED;
}
+
*Position = VirtioFsFile->FilePosition;
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
index 9e46e8ab83..d479f76f5b 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
@@ -38,13 +38,13 @@
STATIC
EFI_STATUS
OpenRootDirectory (
- IN OUT VIRTIO_FS *VirtioFs,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN BOOLEAN OpenForWriting
+ IN OUT VIRTIO_FS *VirtioFs,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN BOOLEAN OpenForWriting
)
{
- EFI_STATUS Status;
- VIRTIO_FS_FILE *NewVirtioFsFile;
+ EFI_STATUS Status;
+ VIRTIO_FS_FILE *NewVirtioFsFile;
//
// VirtioFsOpenVolume() opens the root directory for read-only access. If the
@@ -54,18 +54,23 @@ OpenRootDirectory (
// permission first.
//
if (OpenForWriting) {
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
- EFI_FILE_INFO FileInfo;
-
- Status = VirtioFsFuseGetAttr (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
- &FuseAttr);
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ EFI_FILE_INFO FileInfo;
+
+ Status = VirtioFsFuseGetAttr (
+ VirtioFs,
+ VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
+ &FuseAttr
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
Status = VirtioFsFuseAttrToEfiFileInfo (&FuseAttr, &FileInfo);
if (EFI_ERROR (Status)) {
return Status;
}
+
if ((FileInfo.Attribute & EFI_FILE_READ_ONLY) != 0) {
return EFI_ACCESS_DENIED;
}
@@ -76,7 +81,7 @@ OpenRootDirectory (
return Status;
}
- NewVirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (*NewHandle);
+ NewVirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (*NewHandle);
NewVirtioFsFile->IsOpenForWriting = OpenForWriting;
return EFI_SUCCESS;
}
@@ -132,33 +137,39 @@ OpenRootDirectory (
STATIC
EFI_STATUS
OpenExistentFileOrDirectory (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 DirNodeId,
- IN CHAR8 *Name,
- IN BOOLEAN OpenForWriting,
- OUT UINT64 *NodeId,
- OUT UINT64 *FuseHandle,
- OUT BOOLEAN *NodeIsDirectory
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 DirNodeId,
+ IN CHAR8 *Name,
+ IN BOOLEAN OpenForWriting,
+ OUT UINT64 *NodeId,
+ OUT UINT64 *FuseHandle,
+ OUT BOOLEAN *NodeIsDirectory
)
{
- EFI_STATUS Status;
- UINT64 ResolvedNodeId;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
- EFI_FILE_INFO FileInfo;
- BOOLEAN IsDirectory;
- UINT64 NewFuseHandle;
-
- Status = VirtioFsFuseLookup (VirtioFs, DirNodeId, Name, &ResolvedNodeId,
- &FuseAttr);
+ EFI_STATUS Status;
+ UINT64 ResolvedNodeId;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ EFI_FILE_INFO FileInfo;
+ BOOLEAN IsDirectory;
+ UINT64 NewFuseHandle;
+
+ Status = VirtioFsFuseLookup (
+ VirtioFs,
+ DirNodeId,
+ Name,
+ &ResolvedNodeId,
+ &FuseAttr
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
Status = VirtioFsFuseAttrToEfiFileInfo (&FuseAttr, &FileInfo);
if (EFI_ERROR (Status)) {
goto ForgetResolvedNodeId;
}
- if (OpenForWriting && (FileInfo.Attribute & EFI_FILE_READ_ONLY) != 0) {
+ if (OpenForWriting && ((FileInfo.Attribute & EFI_FILE_READ_ONLY) != 0)) {
Status = EFI_ACCESS_DENIED;
goto ForgetResolvedNodeId;
}
@@ -173,9 +184,14 @@ OpenExistentFileOrDirectory (
//
Status = VirtioFsFuseOpenDir (VirtioFs, ResolvedNodeId, &NewFuseHandle);
} else {
- Status = VirtioFsFuseOpen (VirtioFs, ResolvedNodeId, OpenForWriting,
- &NewFuseHandle);
+ Status = VirtioFsFuseOpen (
+ VirtioFs,
+ ResolvedNodeId,
+ OpenForWriting,
+ &NewFuseHandle
+ );
}
+
if (EFI_ERROR (Status)) {
goto ForgetResolvedNodeId;
}
@@ -216,16 +232,16 @@ ForgetResolvedNodeId:
STATIC
EFI_STATUS
CreateDirectory (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 DirNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 DirNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId,
+ OUT UINT64 *FuseHandle
)
{
- EFI_STATUS Status;
- UINT64 NewChildDirNodeId;
- UINT64 NewFuseHandle;
+ EFI_STATUS Status;
+ UINT64 NewChildDirNodeId;
+ UINT64 NewFuseHandle;
Status = VirtioFsFuseMkDir (VirtioFs, DirNodeId, Name, &NewChildDirNodeId);
if (EFI_ERROR (Status)) {
@@ -273,41 +289,46 @@ RemoveNewChildDir:
STATIC
EFI_STATUS
CreateRegularFile (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 DirNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 DirNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId,
+ OUT UINT64 *FuseHandle
)
{
- return VirtioFsFuseOpenOrCreate (VirtioFs, DirNodeId, Name, NodeId,
- FuseHandle);
+ return VirtioFsFuseOpenOrCreate (
+ VirtioFs,
+ DirNodeId,
+ Name,
+ NodeId,
+ FuseHandle
+ );
}
EFI_STATUS
EFIAPI
VirtioFsSimpleFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- BOOLEAN OpenForWriting;
- BOOLEAN PermitCreation;
- BOOLEAN CreateDirectoryIfCreating;
- VIRTIO_FS_FILE *NewVirtioFsFile;
- EFI_STATUS Status;
- CHAR8 *NewCanonicalPath;
- BOOLEAN RootEscape;
- UINT64 DirNodeId;
- CHAR8 *LastComponent;
- UINT64 NewNodeId;
- UINT64 NewFuseHandle;
- BOOLEAN NewNodeIsDirectory;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ BOOLEAN OpenForWriting;
+ BOOLEAN PermitCreation;
+ BOOLEAN CreateDirectoryIfCreating;
+ VIRTIO_FS_FILE *NewVirtioFsFile;
+ EFI_STATUS Status;
+ CHAR8 *NewCanonicalPath;
+ BOOLEAN RootEscape;
+ UINT64 DirNodeId;
+ CHAR8 *LastComponent;
+ UINT64 NewNodeId;
+ UINT64 NewFuseHandle;
+ BOOLEAN NewNodeIsDirectory;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -316,20 +337,20 @@ VirtioFsSimpleFileOpen (
// Validate OpenMode.
//
switch (OpenMode) {
- case EFI_FILE_MODE_READ:
- OpenForWriting = FALSE;
- PermitCreation = FALSE;
- break;
- case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
- OpenForWriting = TRUE;
- PermitCreation = FALSE;
- break;
- case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE:
- OpenForWriting = TRUE;
- PermitCreation = TRUE;
- break;
- default:
- return EFI_INVALID_PARAMETER;
+ case EFI_FILE_MODE_READ:
+ OpenForWriting = FALSE;
+ PermitCreation = FALSE;
+ break;
+ case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
+ OpenForWriting = TRUE;
+ PermitCreation = FALSE;
+ break;
+ case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE:
+ OpenForWriting = TRUE;
+ PermitCreation = TRUE;
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
}
//
@@ -366,6 +387,7 @@ VirtioFsSimpleFileOpen (
));
return EFI_INVALID_PARAMETER;
}
+
CreateDirectoryIfCreating = (BOOLEAN)((Attributes &
EFI_FILE_DIRECTORY) != 0);
}
@@ -401,11 +423,16 @@ VirtioFsSimpleFileOpen (
// Create the canonical pathname at which the desired file is expected to
// exist.
//
- Status = VirtioFsAppendPath (VirtioFsFile->CanonicalPathname, FileName,
- &NewCanonicalPath, &RootEscape);
+ Status = VirtioFsAppendPath (
+ VirtioFsFile->CanonicalPathname,
+ FileName,
+ &NewCanonicalPath,
+ &RootEscape
+ );
if (EFI_ERROR (Status)) {
goto FreeNewVirtioFsFile;
}
+
if (RootEscape) {
Status = EFI_ACCESS_DENIED;
goto FreeNewCanonicalPath;
@@ -426,8 +453,12 @@ VirtioFsSimpleFileOpen (
// (given by DirNodeId) and last pathname component (i.e., immediate child
// within that parent directory).
//
- Status = VirtioFsLookupMostSpecificParentDir (VirtioFs, NewCanonicalPath,
- &DirNodeId, &LastComponent);
+ Status = VirtioFsLookupMostSpecificParentDir (
+ VirtioFs,
+ NewCanonicalPath,
+ &DirNodeId,
+ &LastComponent
+ );
if (EFI_ERROR (Status)) {
goto FreeNewCanonicalPath;
}
@@ -441,22 +472,40 @@ VirtioFsSimpleFileOpen (
// Try to open LastComponent directly under DirNodeId, as an existent regular
// file or directory.
//
- Status = OpenExistentFileOrDirectory (VirtioFs, DirNodeId, LastComponent,
- OpenForWriting, &NewNodeId, &NewFuseHandle, &NewNodeIsDirectory);
+ Status = OpenExistentFileOrDirectory (
+ VirtioFs,
+ DirNodeId,
+ LastComponent,
+ OpenForWriting,
+ &NewNodeId,
+ &NewFuseHandle,
+ &NewNodeIsDirectory
+ );
//
// If LastComponent could not be found under DirNodeId, but the request
// allows us to create a new entry, attempt creating the requested regular
// file or directory.
//
- if (Status == EFI_NOT_FOUND && PermitCreation) {
+ if ((Status == EFI_NOT_FOUND) && PermitCreation) {
ASSERT (OpenForWriting);
if (CreateDirectoryIfCreating) {
- Status = CreateDirectory (VirtioFs, DirNodeId, LastComponent, &NewNodeId,
- &NewFuseHandle);
+ Status = CreateDirectory (
+ VirtioFs,
+ DirNodeId,
+ LastComponent,
+ &NewNodeId,
+ &NewFuseHandle
+ );
} else {
- Status = CreateRegularFile (VirtioFs, DirNodeId, LastComponent,
- &NewNodeId, &NewFuseHandle);
+ Status = CreateRegularFile (
+ VirtioFs,
+ DirNodeId,
+ LastComponent,
+ &NewNodeId,
+ &NewFuseHandle
+ );
}
+
NewNodeIsDirectory = CreateDirectoryIfCreating;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
index 058e7a41ab..d08b8e0a1d 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
@@ -21,15 +21,15 @@
EFI_STATUS
EFIAPI
VirtioFsOpenVolume (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **Root
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
)
{
- VIRTIO_FS *VirtioFs;
- VIRTIO_FS_FILE *VirtioFsFile;
- EFI_STATUS Status;
- CHAR8 *CanonicalPathname;
- UINT64 RootDirHandle;
+ VIRTIO_FS *VirtioFs;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ EFI_STATUS Status;
+ CHAR8 *CanonicalPathname;
+ UINT64 RootDirHandle;
VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This);
@@ -47,8 +47,11 @@ VirtioFsOpenVolume (
//
// Open the root directory.
//
- Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
- &RootDirHandle);
+ Status = VirtioFsFuseOpenDir (
+ VirtioFs,
+ VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
+ &RootDirHandle
+ );
if (EFI_ERROR (Status)) {
goto FreeCanonicalPathname;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsRead.c b/OvmfPkg/VirtioFsDxe/SimpleFsRead.c
index d6368342a1..9940bd99fe 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsRead.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsRead.c
@@ -37,21 +37,22 @@
STATIC
EFI_STATUS
PopulateFileInfo (
- IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *Dirent,
- IN UINTN SingleFileInfoSize,
- OUT EFI_FILE_INFO *FileInfo
+ IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *Dirent,
+ IN UINTN SingleFileInfoSize,
+ OUT EFI_FILE_INFO *FileInfo
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Convert the name, set the actual size.
//
FileInfo->Size = SingleFileInfoSize;
- Status = VirtioFsFuseDirentPlusToEfiFileInfo (Dirent, FileInfo);
+ Status = VirtioFsFuseDirentPlusToEfiFileInfo (Dirent, FileInfo);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Populate the scalar fields.
//
@@ -65,19 +66,19 @@ PopulateFileInfo (
STATIC
EFI_STATUS
RefillFileInfoCache (
- IN OUT VIRTIO_FS_FILE *VirtioFsFile
+ IN OUT VIRTIO_FS_FILE *VirtioFsFile
)
{
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- VIRTIO_FS_FUSE_STATFS_RESPONSE FilesysAttr;
- UINT32 DirentBufSize;
- UINT8 *DirentBuf;
- UINTN SingleFileInfoSize;
- UINT8 *FileInfoArray;
- UINT64 DirStreamCookie;
- UINT64 CacheEndsAtCookie;
- UINTN NumFileInfo;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ VIRTIO_FS_FUSE_STATFS_RESPONSE FilesysAttr;
+ UINT32 DirentBufSize;
+ UINT8 *DirentBuf;
+ UINTN SingleFileInfoSize;
+ UINT8 *FileInfoArray;
+ UINT64 DirStreamCookie;
+ UINT64 CacheEndsAtCookie;
+ UINTN NumFileInfo;
//
// Allocate a DirentBuf that can receive at least
@@ -87,17 +88,20 @@ RefillFileInfoCache (
// check.
//
VirtioFs = VirtioFsFile->OwnerFs;
- Status = VirtioFsFuseStatFs (VirtioFs, VirtioFsFile->NodeId, &FilesysAttr);
+ Status = VirtioFsFuseStatFs (VirtioFs, VirtioFsFile->NodeId, &FilesysAttr);
if (EFI_ERROR (Status)) {
return Status;
}
+
DirentBufSize = (UINT32)VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE (
- FilesysAttr.Namelen);
+ FilesysAttr.Namelen
+ );
if (DirentBufSize == 0) {
return EFI_UNSUPPORTED;
}
+
DirentBufSize *= VIRTIO_FS_FILE_MAX_FILE_INFO;
- DirentBuf = AllocatePool (DirentBufSize);
+ DirentBuf = AllocatePool (DirentBufSize);
if (DirentBuf == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -128,8 +132,8 @@ RefillFileInfoCache (
CacheEndsAtCookie = VirtioFsFile->FilePosition;
NumFileInfo = 0;
do {
- UINT32 Remaining;
- UINT32 Consumed;
+ UINT32 Remaining;
+ UINT32 Consumed;
//
// Fetch a chunk of the directory stream. The chunk may hold more entries
@@ -138,15 +142,15 @@ RefillFileInfoCache (
// supported under UEFI (sockets, FIFOs, filenames with backslashes, etc).
//
Remaining = DirentBufSize;
- Status = VirtioFsFuseReadFileOrDir (
- VirtioFs,
- VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle,
- TRUE, // IsDir
- DirStreamCookie, // Offset
- &Remaining, // Size
- DirentBuf // Data
- );
+ Status = VirtioFsFuseReadFileOrDir (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ TRUE, // IsDir
+ DirStreamCookie, // Offset
+ &Remaining, // Size
+ DirentBuf // Data
+ );
if (EFI_ERROR (Status)) {
goto FreeFileInfoArray;
}
@@ -165,12 +169,13 @@ RefillFileInfoCache (
//
Consumed = 0;
while (Remaining >= sizeof (VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE)) {
- VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *Dirent;
- UINT32 DirentSize;
+ VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *Dirent;
+ UINT32 DirentSize;
- Dirent = (VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *)(DirentBuf + Consumed);
+ Dirent = (VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *)(DirentBuf + Consumed);
DirentSize = (UINT32)VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE (
- Dirent->Namelen);
+ Dirent->Namelen
+ );
if (DirentSize == 0) {
//
// This means one of two things: (a) Dirent->Namelen is zero, or (b)
@@ -182,6 +187,7 @@ RefillFileInfoCache (
Status = EFI_PROTOCOL_ERROR;
goto FreeFileInfoArray;
}
+
if (DirentSize > Remaining) {
//
// Dirent->Namelen suggests that the filename byte array (plus any
@@ -191,6 +197,7 @@ RefillFileInfoCache (
Status = EFI_PROTOCOL_ERROR;
goto FreeFileInfoArray;
}
+
if (Dirent->Namelen > FilesysAttr.Namelen) {
//
// This is possible without tripping the truncation check above, due to
@@ -207,7 +214,7 @@ RefillFileInfoCache (
// Dirent to EFI_FILE_INFO.
//
if (NumFileInfo < VIRTIO_FS_FILE_MAX_FILE_INFO) {
- EFI_FILE_INFO *FileInfo;
+ EFI_FILE_INFO *FileInfo;
FileInfo = (EFI_FILE_INFO *)(FileInfoArray +
(NumFileInfo * SingleFileInfoSize));
@@ -224,6 +231,7 @@ RefillFileInfoCache (
//
CacheEndsAtCookie = Dirent->CookieForNextEntry;
}
+
//
// If Dirent wasn't transformable to an EFI_FILE_INFO, we'll just skip
// it.
@@ -244,8 +252,8 @@ RefillFileInfoCache (
// Advance to the next entry in DirentBuf.
//
DirStreamCookie = Dirent->CookieForNextEntry;
- Consumed += DirentSize;
- Remaining -= DirentSize;
+ Consumed += DirentSize;
+ Remaining -= DirentSize;
}
if (Remaining > 0) {
@@ -257,6 +265,7 @@ RefillFileInfoCache (
Status = EFI_PROTOCOL_ERROR;
goto FreeFileInfoArray;
}
+
//
// Fetch another DirentBuf from the directory stream, unless we've filled
// the EFI_FILE_INFO cache.
@@ -269,6 +278,7 @@ RefillFileInfoCache (
if (VirtioFsFile->FileInfoArray != NULL) {
FreePool (VirtioFsFile->FileInfoArray);
}
+
VirtioFsFile->FileInfoArray = FileInfoArray;
VirtioFsFile->SingleFileInfoSize = SingleFileInfoSize;
VirtioFsFile->NumFileInfo = NumFileInfo;
@@ -293,30 +303,32 @@ FreeDirentBuf:
STATIC
EFI_STATUS
ReadFileInfoCache (
- IN OUT VIRTIO_FS_FILE *VirtioFsFile,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN OUT VIRTIO_FS_FILE *VirtioFsFile,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_FILE_INFO *FileInfo;
- UINTN CallerAllocated;
+ EFI_FILE_INFO *FileInfo;
+ UINTN CallerAllocated;
//
// Refill the cache if needed. If the refill doesn't produce any new
// EFI_FILE_INFO, report End of Directory, by setting (*BufferSize) to 0.
//
if (VirtioFsFile->NextFileInfo == VirtioFsFile->NumFileInfo) {
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = RefillFileInfoCache (VirtioFsFile);
if (EFI_ERROR (Status)) {
return (Status == EFI_BUFFER_TOO_SMALL) ? EFI_DEVICE_ERROR : Status;
}
+
if (VirtioFsFile->NumFileInfo == 0) {
*BufferSize = 0;
return EFI_SUCCESS;
}
}
+
FileInfo = (EFI_FILE_INFO *)(VirtioFsFile->FileInfoArray +
(VirtioFsFile->NextFileInfo *
VirtioFsFile->SingleFileInfoSize));
@@ -337,10 +349,11 @@ ReadFileInfoCache (
// VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE().)
//
CallerAllocated = *BufferSize;
- *BufferSize = (UINTN)FileInfo->Size;
+ *BufferSize = (UINTN)FileInfo->Size;
if (CallerAllocated < *BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
+
//
// Output FileInfo, and remove it from the cache.
//
@@ -355,23 +368,23 @@ ReadFileInfoCache (
STATIC
EFI_STATUS
ReadRegularFile (
- IN OUT VIRTIO_FS_FILE *VirtioFsFile,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN OUT VIRTIO_FS_FILE *VirtioFsFile,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
- UINTN Transferred;
- UINTN Left;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ UINTN Transferred;
+ UINTN Left;
VirtioFs = VirtioFsFile->OwnerFs;
//
// The UEFI spec forbids reads that start beyond the end of the file.
//
Status = VirtioFsFuseGetAttr (VirtioFs, VirtioFsFile->NodeId, &FuseAttr);
- if (EFI_ERROR (Status) || VirtioFsFile->FilePosition > FuseAttr.Size) {
+ if (EFI_ERROR (Status) || (VirtioFsFile->FilePosition > FuseAttr.Size)) {
return EFI_DEVICE_ERROR;
}
@@ -379,29 +392,30 @@ ReadRegularFile (
Transferred = 0;
Left = *BufferSize;
while (Left > 0) {
- UINT32 ReadSize;
+ UINT32 ReadSize;
//
// FUSE_READ cannot express a >=4GB buffer size.
//
ReadSize = (UINT32)MIN ((UINTN)MAX_UINT32, Left);
- Status = VirtioFsFuseReadFileOrDir (
- VirtioFs,
- VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle,
- FALSE, // IsDir
- VirtioFsFile->FilePosition + Transferred,
- &ReadSize,
- (UINT8 *)Buffer + Transferred
- );
- if (EFI_ERROR (Status) || ReadSize == 0) {
+ Status = VirtioFsFuseReadFileOrDir (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ FALSE, // IsDir
+ VirtioFsFile->FilePosition + Transferred,
+ &ReadSize,
+ (UINT8 *)Buffer + Transferred
+ );
+ if (EFI_ERROR (Status) || (ReadSize == 0)) {
break;
}
+
Transferred += ReadSize;
Left -= ReadSize;
}
- *BufferSize = Transferred;
+ *BufferSize = Transferred;
VirtioFsFile->FilePosition += Transferred;
//
// If we managed to read some data, return success. If zero bytes were
@@ -415,13 +429,13 @@ ReadRegularFile (
EFI_STATUS
EFIAPI
VirtioFsSimpleFileRead (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- EFI_STATUS Status;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ EFI_STATUS Status;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
@@ -430,5 +444,6 @@ VirtioFsSimpleFileRead (
} else {
Status = ReadRegularFile (VirtioFsFile, BufferSize, Buffer);
}
+
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c b/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c
index e7cc3d5dc3..b5f1a58341 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c
@@ -56,16 +56,16 @@
STATIC
EFI_STATUS
ValidateInfoStructure (
- IN UINTN SizeByProtocolCaller,
- IN UINTN MinimumStructSize,
- IN BOOLEAN IsSizeByInfoPresent,
- IN VOID *Buffer
+ IN UINTN SizeByProtocolCaller,
+ IN UINTN MinimumStructSize,
+ IN BOOLEAN IsSizeByInfoPresent,
+ IN VOID *Buffer
)
{
- UINTN NameFieldByteOffset;
- UINTN NameFieldBytes;
- UINTN NameFieldChar16s;
- CHAR16 *NameField;
+ UINTN NameFieldByteOffset;
+ UINTN NameFieldBytes;
+ UINTN NameFieldChar16s;
+ CHAR16 *NameField;
//
// Make sure the internal function asking for validation passes in sane
@@ -92,7 +92,7 @@ ValidateInfoStructure (
// agrees with the protocol caller-provided size.
//
if (IsSizeByInfoPresent) {
- UINT64 *SizeByInfo;
+ UINT64 *SizeByInfo;
SizeByInfo = Buffer;
if (*SizeByInfo != SizeByProtocolCaller) {
@@ -172,19 +172,18 @@ ValidateInfoStructure (
STATIC
EFI_STATUS
Rename (
- IN OUT VIRTIO_FS_FILE *VirtioFsFile,
- IN CHAR16 *NewFileName
+ IN OUT VIRTIO_FS_FILE *VirtioFsFile,
+ IN CHAR16 *NewFileName
)
{
-
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- CHAR8 *Destination;
- BOOLEAN RootEscape;
- UINT64 OldParentDirNodeId;
- CHAR8 *OldLastComponent;
- UINT64 NewParentDirNodeId;
- CHAR8 *NewLastComponent;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ CHAR8 *Destination;
+ BOOLEAN RootEscape;
+ UINT64 OldParentDirNodeId;
+ CHAR8 *OldLastComponent;
+ UINT64 NewParentDirNodeId;
+ CHAR8 *NewLastComponent;
VirtioFs = VirtioFsFile->OwnerFs;
@@ -198,21 +197,28 @@ Rename (
//
return EFI_SUCCESS;
}
+
return EFI_ACCESS_DENIED;
}
//
// Compose the canonical pathname for the destination.
//
- Status = VirtioFsComposeRenameDestination (VirtioFsFile->CanonicalPathname,
- NewFileName, &Destination, &RootEscape);
+ Status = VirtioFsComposeRenameDestination (
+ VirtioFsFile->CanonicalPathname,
+ NewFileName,
+ &Destination,
+ &RootEscape
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
if (RootEscape) {
Status = EFI_NOT_FOUND;
goto FreeDestination;
}
+
//
// If the rename would leave VirtioFsFile->CanonicalPathname unchanged, then
// EFI_FILE_PROTOCOL.SetInfo() isn't asking for a rename actually.
@@ -221,24 +227,29 @@ Rename (
Status = EFI_SUCCESS;
goto FreeDestination;
}
+
//
// Check if the rename would break the canonical pathnames of other
// VIRTIO_FS_FILE instances of the same VIRTIO_FS.
//
if (VirtioFsFile->IsDirectory) {
- UINTN PathLen;
- LIST_ENTRY *OpenFilesEntry;
+ UINTN PathLen;
+ LIST_ENTRY *OpenFilesEntry;
PathLen = AsciiStrLen (VirtioFsFile->CanonicalPathname);
BASE_LIST_FOR_EACH (OpenFilesEntry, &VirtioFs->OpenFiles) {
- VIRTIO_FS_FILE *OtherFile;
+ VIRTIO_FS_FILE *OtherFile;
OtherFile = VIRTIO_FS_FILE_FROM_OPEN_FILES_ENTRY (OpenFilesEntry);
- if (OtherFile != VirtioFsFile &&
- AsciiStrnCmp (VirtioFsFile->CanonicalPathname,
- OtherFile->CanonicalPathname, PathLen) == 0 &&
- (OtherFile->CanonicalPathname[PathLen] == '\0' ||
- OtherFile->CanonicalPathname[PathLen] == '/')) {
+ if ((OtherFile != VirtioFsFile) &&
+ (AsciiStrnCmp (
+ VirtioFsFile->CanonicalPathname,
+ OtherFile->CanonicalPathname,
+ PathLen
+ ) == 0) &&
+ ((OtherFile->CanonicalPathname[PathLen] == '\0') ||
+ (OtherFile->CanonicalPathname[PathLen] == '/')))
+ {
//
// OtherFile refers to the same directory as VirtioFsFile, or is a
// (possibly indirect) child of the directory referred to by
@@ -249,6 +260,7 @@ Rename (
}
}
}
+
//
// From this point on, the file needs to be open for writing.
//
@@ -256,26 +268,41 @@ Rename (
Status = EFI_ACCESS_DENIED;
goto FreeDestination;
}
+
//
// Split both source and destination canonical pathnames into (most specific
// parent directory, last component) pairs.
//
- Status = VirtioFsLookupMostSpecificParentDir (VirtioFs,
- VirtioFsFile->CanonicalPathname, &OldParentDirNodeId,
- &OldLastComponent);
+ Status = VirtioFsLookupMostSpecificParentDir (
+ VirtioFs,
+ VirtioFsFile->CanonicalPathname,
+ &OldParentDirNodeId,
+ &OldLastComponent
+ );
if (EFI_ERROR (Status)) {
goto FreeDestination;
}
- Status = VirtioFsLookupMostSpecificParentDir (VirtioFs, Destination,
- &NewParentDirNodeId, &NewLastComponent);
+
+ Status = VirtioFsLookupMostSpecificParentDir (
+ VirtioFs,
+ Destination,
+ &NewParentDirNodeId,
+ &NewLastComponent
+ );
if (EFI_ERROR (Status)) {
goto ForgetOldParentDirNodeId;
}
+
//
// Perform the rename. If the destination path exists, the rename will fail.
//
- Status = VirtioFsFuseRename (VirtioFs, OldParentDirNodeId, OldLastComponent,
- NewParentDirNodeId, NewLastComponent);
+ Status = VirtioFsFuseRename (
+ VirtioFs,
+ OldParentDirNodeId,
+ OldLastComponent,
+ NewParentDirNodeId,
+ NewLastComponent
+ );
if (EFI_ERROR (Status)) {
goto ForgetNewParentDirNodeId;
}
@@ -285,8 +312,8 @@ Rename (
//
FreePool (VirtioFsFile->CanonicalPathname);
VirtioFsFile->CanonicalPathname = Destination;
- Destination = NULL;
- Status = EFI_SUCCESS;
+ Destination = NULL;
+ Status = EFI_SUCCESS;
//
// Fall through.
@@ -305,6 +332,7 @@ FreeDestination:
if (Destination != NULL) {
FreePool (Destination);
}
+
return Status;
}
@@ -332,22 +360,22 @@ FreeDestination:
STATIC
EFI_STATUS
UpdateAttributes (
- IN OUT VIRTIO_FS_FILE *VirtioFsFile,
- IN EFI_FILE_INFO *NewFileInfo
+ IN OUT VIRTIO_FS_FILE *VirtioFsFile,
+ IN EFI_FILE_INFO *NewFileInfo
)
{
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
- EFI_FILE_INFO FileInfo;
- BOOLEAN UpdateFileSize;
- UINT64 FileSize;
- BOOLEAN UpdateAtime;
- BOOLEAN UpdateMtime;
- UINT64 Atime;
- UINT64 Mtime;
- BOOLEAN UpdateMode;
- UINT32 Mode;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ EFI_FILE_INFO FileInfo;
+ BOOLEAN UpdateFileSize;
+ UINT64 FileSize;
+ BOOLEAN UpdateAtime;
+ BOOLEAN UpdateMtime;
+ UINT64 Atime;
+ UINT64 Mtime;
+ BOOLEAN UpdateMode;
+ UINT32 Mode;
VirtioFs = VirtioFsFile->OwnerFs;
@@ -359,28 +387,44 @@ UpdateAttributes (
if (EFI_ERROR (Status)) {
return Status;
}
+
Status = VirtioFsFuseAttrToEfiFileInfo (&FuseAttr, &FileInfo);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Collect the updates.
//
if (VirtioFsFile->IsDirectory) {
UpdateFileSize = FALSE;
} else {
- VirtioFsGetFuseSizeUpdate (&FileInfo, NewFileInfo, &UpdateFileSize,
- &FileSize);
- }
-
- Status = VirtioFsGetFuseTimeUpdates (&FileInfo, NewFileInfo, &UpdateAtime,
- &UpdateMtime, &Atime, &Mtime);
+ VirtioFsGetFuseSizeUpdate (
+ &FileInfo,
+ NewFileInfo,
+ &UpdateFileSize,
+ &FileSize
+ );
+ }
+
+ Status = VirtioFsGetFuseTimeUpdates (
+ &FileInfo,
+ NewFileInfo,
+ &UpdateAtime,
+ &UpdateMtime,
+ &Atime,
+ &Mtime
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- Status = VirtioFsGetFuseModeUpdate (&FileInfo, NewFileInfo, &UpdateMode,
- &Mode);
+ Status = VirtioFsGetFuseModeUpdate (
+ &FileInfo,
+ NewFileInfo,
+ &UpdateMode,
+ &Mode
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -391,14 +435,17 @@ UpdateAttributes (
if (!UpdateFileSize && !UpdateAtime && !UpdateMtime && !UpdateMode) {
return EFI_SUCCESS;
}
+
//
// If the file is not open for writing, then only Mode may be updated (for
// toggling EFI_FILE_READ_ONLY).
//
if (!VirtioFsFile->IsOpenForWriting &&
- (UpdateFileSize || UpdateAtime || UpdateMtime)) {
+ (UpdateFileSize || UpdateAtime || UpdateMtime))
+ {
return EFI_ACCESS_DENIED;
}
+
//
// Send the FUSE_SETATTR request now.
//
@@ -419,14 +466,14 @@ UpdateAttributes (
STATIC
EFI_STATUS
SetFileInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- EFI_STATUS Status;
- EFI_FILE_INFO *FileInfo;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ EFI_STATUS Status;
+ EFI_FILE_INFO *FileInfo;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
@@ -435,14 +482,17 @@ SetFileInfo (
//
Status = ValidateInfoStructure (
BufferSize, // SizeByProtocolCaller
- OFFSET_OF (EFI_FILE_INFO,
- FileName) + sizeof (CHAR16), // MinimumStructSize
+ OFFSET_OF (
+ EFI_FILE_INFO,
+ FileName
+ ) + sizeof (CHAR16), // MinimumStructSize
TRUE, // IsSizeByInfoPresent
Buffer
);
if (EFI_ERROR (Status)) {
return Status;
}
+
FileInfo = Buffer;
//
@@ -452,6 +502,7 @@ SetFileInfo (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Update any attributes requested.
//
@@ -470,15 +521,15 @@ SetFileInfo (
STATIC
EFI_STATUS
SetFileSystemInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- EFI_FILE_SYSTEM_INFO *FileSystemInfo;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ EFI_FILE_SYSTEM_INFO *FileSystemInfo;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -488,14 +539,17 @@ SetFileSystemInfo (
//
Status = ValidateInfoStructure (
BufferSize, // SizeByProtocolCaller
- OFFSET_OF (EFI_FILE_SYSTEM_INFO,
- VolumeLabel) + sizeof (CHAR16), // MinimumStructSize
+ OFFSET_OF (
+ EFI_FILE_SYSTEM_INFO,
+ VolumeLabel
+ ) + sizeof (CHAR16), // MinimumStructSize
TRUE, // IsSizeByInfoPresent
Buffer
);
if (EFI_ERROR (Status)) {
return Status;
}
+
FileSystemInfo = Buffer;
//
@@ -509,6 +563,7 @@ SetFileSystemInfo (
if (StrCmp (FileSystemInfo->VolumeLabel, VirtioFs->Label) == 0) {
return EFI_SUCCESS;
}
+
return EFI_WRITE_PROTECTED;
}
@@ -518,15 +573,15 @@ SetFileSystemInfo (
STATIC
EFI_STATUS
SetFileSystemVolumeLabelInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- EFI_FILE_SYSTEM_VOLUME_LABEL *FileSystemVolumeLabel;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ EFI_FILE_SYSTEM_VOLUME_LABEL *FileSystemVolumeLabel;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -536,14 +591,17 @@ SetFileSystemVolumeLabelInfo (
//
Status = ValidateInfoStructure (
BufferSize, // SizeByProtocolCaller
- OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL,
- VolumeLabel) + sizeof (CHAR16), // MinimumStructSize
+ OFFSET_OF (
+ EFI_FILE_SYSTEM_VOLUME_LABEL,
+ VolumeLabel
+ ) + sizeof (CHAR16), // MinimumStructSize
FALSE, // IsSizeByInfoPresent
Buffer
);
if (EFI_ERROR (Status)) {
return Status;
}
+
FileSystemVolumeLabel = Buffer;
//
@@ -554,16 +612,17 @@ SetFileSystemVolumeLabelInfo (
if (StrCmp (FileSystemVolumeLabel->VolumeLabel, VirtioFs->Label) == 0) {
return EFI_SUCCESS;
}
+
return EFI_WRITE_PROTECTED;
}
EFI_STATUS
EFIAPI
VirtioFsSimpleFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c b/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c
index a548012d9c..dd05081396 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c
@@ -14,14 +14,14 @@
EFI_STATUS
EFIAPI
VirtioFsSimpleFileSetPosition (
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
@@ -32,11 +32,13 @@ VirtioFsSimpleFileSetPosition (
if (Position != 0) {
return EFI_UNSUPPORTED;
}
+
VirtioFsFile->FilePosition = 0;
if (VirtioFsFile->FileInfoArray != NULL) {
FreePool (VirtioFsFile->FileInfoArray);
VirtioFsFile->FileInfoArray = NULL;
}
+
VirtioFsFile->SingleFileInfoSize = 0;
VirtioFsFile->NumFileInfo = 0;
VirtioFsFile->NextFileInfo = 0;
@@ -58,10 +60,11 @@ VirtioFsSimpleFileSetPosition (
// Caller is requesting a seek to EOF.
//
VirtioFs = VirtioFsFile->OwnerFs;
- Status = VirtioFsFuseGetAttr (VirtioFs, VirtioFsFile->NodeId, &FuseAttr);
+ Status = VirtioFsFuseGetAttr (VirtioFs, VirtioFsFile->NodeId, &FuseAttr);
if (EFI_ERROR (Status)) {
return Status;
}
+
VirtioFsFile->FilePosition = FuseAttr.Size;
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c b/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c
index 8ae317c88e..7f4ff8c5bb 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c
@@ -11,16 +11,16 @@
EFI_STATUS
EFIAPI
VirtioFsSimpleFileWrite (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
- VIRTIO_FS_FILE *VirtioFsFile;
- VIRTIO_FS *VirtioFs;
- EFI_STATUS Status;
- UINTN Transferred;
- UINTN Left;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+ UINTN Transferred;
+ UINTN Left;
VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
VirtioFs = VirtioFsFile->OwnerFs;
@@ -28,6 +28,7 @@ VirtioFsSimpleFileWrite (
if (VirtioFsFile->IsDirectory) {
return EFI_UNSUPPORTED;
}
+
if (!VirtioFsFile->IsOpenForWriting) {
return EFI_ACCESS_DENIED;
}
@@ -36,34 +37,36 @@ VirtioFsSimpleFileWrite (
Transferred = 0;
Left = *BufferSize;
while (Left > 0) {
- UINT32 WriteSize;
+ UINT32 WriteSize;
//
// Honor the write buffer size limit.
//
WriteSize = (UINT32)MIN ((UINTN)VirtioFs->MaxWrite, Left);
- Status = VirtioFsFuseWrite (
- VirtioFs,
- VirtioFsFile->NodeId,
- VirtioFsFile->FuseHandle,
- VirtioFsFile->FilePosition + Transferred,
- &WriteSize,
- (UINT8 *)Buffer + Transferred
- );
- if (!EFI_ERROR (Status) && WriteSize == 0) {
+ Status = VirtioFsFuseWrite (
+ VirtioFs,
+ VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle,
+ VirtioFsFile->FilePosition + Transferred,
+ &WriteSize,
+ (UINT8 *)Buffer + Transferred
+ );
+ if (!EFI_ERROR (Status) && (WriteSize == 0)) {
//
// Progress should have been made.
//
Status = EFI_DEVICE_ERROR;
}
+
if (EFI_ERROR (Status)) {
break;
}
+
Transferred += WriteSize;
Left -= WriteSize;
}
- *BufferSize = Transferred;
+ *BufferSize = Transferred;
VirtioFsFile->FilePosition += Transferred;
//
// According to the UEFI spec,
diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h
index 3c3eb1ac93..0bbf5b7895 100644
--- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h
+++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h
@@ -18,7 +18,7 @@
#include <Protocol/VirtioDevice.h> // VIRTIO_DEVICE_PROTOCOL
#include <Uefi/UefiBaseType.h> // EFI_EVENT
-#define VIRTIO_FS_SIG SIGNATURE_64 ('V', 'I', 'R', 'T', 'I', 'O', 'F', 'S')
+#define VIRTIO_FS_SIG SIGNATURE_64 ('V', 'I', 'R', 'T', 'I', 'O', 'F', 'S')
#define VIRTIO_FS_FILE_SIG \
SIGNATURE_64 ('V', 'I', 'O', 'F', 'S', 'F', 'I', 'L')
@@ -45,12 +45,12 @@
// pathnames, separate limits could be used; a common limit is used purely for
// simplicity.
//
-#define VIRTIO_FS_MAX_PATHNAME_LENGTH ((UINTN)65535)
+#define VIRTIO_FS_MAX_PATHNAME_LENGTH ((UINTN)65535)
//
// Maximum value for VIRTIO_FS_FILE.NumFileInfo.
//
-#define VIRTIO_FS_FILE_MAX_FILE_INFO 256
+#define VIRTIO_FS_FILE_MAX_FILE_INFO 256
//
// Filesystem label encoded in UCS-2, transformed from the UTF-8 representation
@@ -71,17 +71,17 @@ typedef struct {
//
// field init function init depth
// ----------- ------------------ ----------
- UINT64 Signature; // DriverBindingStart 0
- VIRTIO_DEVICE_PROTOCOL *Virtio; // DriverBindingStart 0
- VIRTIO_FS_LABEL Label; // VirtioFsInit 1
- UINT16 QueueSize; // VirtioFsInit 1
- VRING Ring; // VirtioRingInit 2
- VOID *RingMap; // VirtioRingMap 2
- UINT64 RequestId; // FuseInitSession 1
- UINT32 MaxWrite; // FuseInitSession 1
- EFI_EVENT ExitBoot; // DriverBindingStart 0
- LIST_ENTRY OpenFiles; // DriverBindingStart 0
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs; // DriverBindingStart 0
+ UINT64 Signature; // DriverBindingStart 0
+ VIRTIO_DEVICE_PROTOCOL *Virtio; // DriverBindingStart 0
+ VIRTIO_FS_LABEL Label; // VirtioFsInit 1
+ UINT16 QueueSize; // VirtioFsInit 1
+ VRING Ring; // VirtioRingInit 2
+ VOID *RingMap; // VirtioRingMap 2
+ UINT64 RequestId; // FuseInitSession 1
+ UINT32 MaxWrite; // FuseInitSession 1
+ EFI_EVENT ExitBoot; // DriverBindingStart 0
+ LIST_ENTRY OpenFiles; // DriverBindingStart 0
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs; // DriverBindingStart 0
} VIRTIO_FS;
#define VIRTIO_FS_FROM_SIMPLE_FS(SimpleFsReference) \
@@ -95,8 +95,8 @@ typedef struct {
//
// The following fields originate from the owner of the buffer.
//
- VOID *Buffer;
- UINTN Size;
+ VOID *Buffer;
+ UINTN Size;
//
// All of the fields below, until the end of the structure, are
// zero-initialized when the structure is initially validated.
@@ -105,16 +105,16 @@ typedef struct {
// for VirtioOperationBusMasterRead or VirtioOperationBusMasterWrite. They
// are again updated when the buffer is unmapped.
//
- BOOLEAN Mapped;
- EFI_PHYSICAL_ADDRESS MappedAddress;
- VOID *Mapping;
+ BOOLEAN Mapped;
+ EFI_PHYSICAL_ADDRESS MappedAddress;
+ VOID *Mapping;
//
// Transferred is updated after VirtioFlush() returns successfully:
// - for VirtioOperationBusMasterRead, Transferred is set to Size;
// - for VirtioOperationBusMasterWrite, Transferred is calculated from the
// UsedLen output parameter of VirtioFlush().
//
- UINTN Transferred;
+ UINTN Transferred;
} VIRTIO_FS_IO_VECTOR;
//
@@ -124,13 +124,13 @@ typedef struct {
//
// The following fields originate from the owner of the buffers.
//
- VIRTIO_FS_IO_VECTOR *IoVec;
- UINTN NumVec;
+ VIRTIO_FS_IO_VECTOR *IoVec;
+ UINTN NumVec;
//
// TotalSize is calculated when the scatter-gather list is initially
// validated.
//
- UINT32 TotalSize;
+ UINT32 TotalSize;
} VIRTIO_FS_SCATTER_GATHER_LIST;
//
@@ -138,14 +138,14 @@ typedef struct {
// FUSE file reference.
//
typedef struct {
- UINT64 Signature;
- EFI_FILE_PROTOCOL SimpleFile;
- BOOLEAN IsDirectory;
- BOOLEAN IsOpenForWriting;
- VIRTIO_FS *OwnerFs;
- LIST_ENTRY OpenFilesEntry;
- CHAR8 *CanonicalPathname;
- UINT64 FilePosition;
+ UINT64 Signature;
+ EFI_FILE_PROTOCOL SimpleFile;
+ BOOLEAN IsDirectory;
+ BOOLEAN IsOpenForWriting;
+ VIRTIO_FS *OwnerFs;
+ LIST_ENTRY OpenFilesEntry;
+ CHAR8 *CanonicalPathname;
+ UINT64 FilePosition;
//
// In the FUSE wire protocol, every request except FUSE_INIT refers to a
// file, namely by the "VIRTIO_FS_FUSE_REQUEST.NodeId" field; that is, by the
@@ -158,8 +158,8 @@ typedef struct {
// function must send a FUSE request that needs the file handle *in addition*
// to the inode number, FuseHandle will be at our disposal at once.
//
- UINT64 NodeId;
- UINT64 FuseHandle;
+ UINT64 NodeId;
+ UINT64 FuseHandle;
//
// EFI_FILE_INFO objects cached for an in-flight directory read.
//
@@ -170,10 +170,10 @@ typedef struct {
// EFI_FILE_INFOs immediately. EFI_FILE_PROTOCOL.Read() invocations (on
// directories) will be served from this EFI_FILE_INFO cache.
//
- UINT8 *FileInfoArray;
- UINTN SingleFileInfoSize;
- UINTN NumFileInfo;
- UINTN NextFileInfo;
+ UINT8 *FileInfoArray;
+ UINTN SingleFileInfoSize;
+ UINTN NumFileInfo;
+ UINTN NextFileInfo;
} VIRTIO_FS_FILE;
#define VIRTIO_FS_FILE_FROM_SIMPLE_FILE(SimpleFileReference) \
@@ -189,39 +189,39 @@ typedef struct {
EFI_STATUS
VirtioFsInit (
- IN OUT VIRTIO_FS *VirtioFs
+ IN OUT VIRTIO_FS *VirtioFs
);
VOID
VirtioFsUninit (
- IN OUT VIRTIO_FS *VirtioFs
+ IN OUT VIRTIO_FS *VirtioFs
);
VOID
EFIAPI
VirtioFsExitBoot (
- IN EFI_EVENT ExitBootEvent,
- IN VOID *VirtioFsAsVoid
+ IN EFI_EVENT ExitBootEvent,
+ IN VOID *VirtioFsAsVoid
);
EFI_STATUS
VirtioFsSgListsValidate (
- IN VIRTIO_FS *VirtioFs,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
+ IN VIRTIO_FS *VirtioFs,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
);
EFI_STATUS
VirtioFsSgListsSubmit (
- IN OUT VIRTIO_FS *VirtioFs,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
- IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
+ IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
);
EFI_STATUS
VirtioFsFuseNewRequest (
IN OUT VIRTIO_FS *VirtioFs,
- OUT VIRTIO_FS_FUSE_REQUEST *Request,
+ OUT VIRTIO_FS_FUSE_REQUEST *Request,
IN UINT32 RequestSize,
IN VIRTIO_FS_FUSE_OPCODE Opcode,
IN UINT64 NodeId
@@ -229,36 +229,36 @@ VirtioFsFuseNewRequest (
EFI_STATUS
VirtioFsFuseCheckResponse (
- IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList,
- IN UINT64 RequestId,
- OUT UINTN *TailBufferFill
+ IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList,
+ IN UINT64 RequestId,
+ OUT UINTN *TailBufferFill
);
EFI_STATUS
VirtioFsErrnoToEfiStatus (
- IN INT32 Errno
+ IN INT32 Errno
);
EFI_STATUS
VirtioFsAppendPath (
IN CHAR8 *LhsPath8,
IN CHAR16 *RhsPath16,
- OUT CHAR8 **ResultPath8,
- OUT BOOLEAN *RootEscape
+ OUT CHAR8 **ResultPath8,
+ OUT BOOLEAN *RootEscape
);
EFI_STATUS
VirtioFsLookupMostSpecificParentDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN OUT CHAR8 *Path,
- OUT UINT64 *DirNodeId,
- OUT CHAR8 **LastComponent
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN OUT CHAR8 *Path,
+ OUT UINT64 *DirNodeId,
+ OUT CHAR8 **LastComponent
);
EFI_STATUS
VirtioFsGetBasename (
IN CHAR8 *Path,
- OUT CHAR16 *Basename OPTIONAL,
+ OUT CHAR16 *Basename OPTIONAL,
IN OUT UINTN *BasenameSize
);
@@ -266,47 +266,47 @@ EFI_STATUS
VirtioFsComposeRenameDestination (
IN CHAR8 *LhsPath8,
IN CHAR16 *RhsPath16,
- OUT CHAR8 **ResultPath8,
- OUT BOOLEAN *RootEscape
+ OUT CHAR8 **ResultPath8,
+ OUT BOOLEAN *RootEscape
);
EFI_STATUS
VirtioFsFuseAttrToEfiFileInfo (
- IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr,
- OUT EFI_FILE_INFO *FileInfo
+ IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr,
+ OUT EFI_FILE_INFO *FileInfo
);
EFI_STATUS
VirtioFsFuseDirentPlusToEfiFileInfo (
- IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent,
- IN OUT EFI_FILE_INFO *FileInfo
+ IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent,
+ IN OUT EFI_FILE_INFO *FileInfo
);
VOID
VirtioFsGetFuseSizeUpdate (
- IN EFI_FILE_INFO *Info,
- IN EFI_FILE_INFO *NewInfo,
- OUT BOOLEAN *Update,
- OUT UINT64 *Size
+ IN EFI_FILE_INFO *Info,
+ IN EFI_FILE_INFO *NewInfo,
+ OUT BOOLEAN *Update,
+ OUT UINT64 *Size
);
EFI_STATUS
VirtioFsGetFuseTimeUpdates (
- IN EFI_FILE_INFO *Info,
- IN EFI_FILE_INFO *NewInfo,
- OUT BOOLEAN *UpdateAtime,
- OUT BOOLEAN *UpdateMtime,
- OUT UINT64 *Atime,
- OUT UINT64 *Mtime
+ IN EFI_FILE_INFO *Info,
+ IN EFI_FILE_INFO *NewInfo,
+ OUT BOOLEAN *UpdateAtime,
+ OUT BOOLEAN *UpdateMtime,
+ OUT UINT64 *Atime,
+ OUT UINT64 *Mtime
);
EFI_STATUS
VirtioFsGetFuseModeUpdate (
- IN EFI_FILE_INFO *Info,
- IN EFI_FILE_INFO *NewInfo,
- OUT BOOLEAN *Update,
- OUT UINT32 *Mode
- );
+ IN EFI_FILE_INFO *Info,
+ IN EFI_FILE_INFO *NewInfo,
+ OUT BOOLEAN *Update,
+ OUT UINT32 *Mode
+ );
//
// Wrapper functions for FUSE commands (primitives).
@@ -314,139 +314,139 @@ VirtioFsGetFuseModeUpdate (
EFI_STATUS
VirtioFsFuseLookup (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 DirNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId,
- OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 DirNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId,
+ OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
);
EFI_STATUS
VirtioFsFuseForget (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId
);
EFI_STATUS
VirtioFsFuseGetAttr (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
);
EFI_STATUS
VirtioFsFuseSetAttr (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 *Size OPTIONAL,
- IN UINT64 *Atime OPTIONAL,
- IN UINT64 *Mtime OPTIONAL,
- IN UINT32 *Mode OPTIONAL
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 *Size OPTIONAL,
+ IN UINT64 *Atime OPTIONAL,
+ IN UINT64 *Mtime OPTIONAL,
+ IN UINT32 *Mode OPTIONAL
);
EFI_STATUS
VirtioFsFuseMkDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 ParentNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 ParentNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId
);
EFI_STATUS
VirtioFsFuseRemoveFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 ParentNodeId,
- IN CHAR8 *Name,
- IN BOOLEAN IsDir
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 ParentNodeId,
+ IN CHAR8 *Name,
+ IN BOOLEAN IsDir
);
EFI_STATUS
VirtioFsFuseOpen (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN BOOLEAN ReadWrite,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN BOOLEAN ReadWrite,
+ OUT UINT64 *FuseHandle
);
EFI_STATUS
VirtioFsFuseReadFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN BOOLEAN IsDir,
- IN UINT64 Offset,
- IN OUT UINT32 *Size,
- OUT VOID *Data
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN BOOLEAN IsDir,
+ IN UINT64 Offset,
+ IN OUT UINT32 *Size,
+ OUT VOID *Data
);
EFI_STATUS
VirtioFsFuseWrite (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN UINT64 Offset,
- IN OUT UINT32 *Size,
- IN VOID *Data
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN UINT64 Offset,
+ IN OUT UINT32 *Size,
+ IN VOID *Data
);
EFI_STATUS
VirtioFsFuseStatFs (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr
- );
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr
+ );
EFI_STATUS
VirtioFsFuseReleaseFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN BOOLEAN IsDir
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN BOOLEAN IsDir
);
EFI_STATUS
VirtioFsFuseFsyncFileOrDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle,
- IN BOOLEAN IsDir
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle,
+ IN BOOLEAN IsDir
);
EFI_STATUS
VirtioFsFuseFlush (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- IN UINT64 FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ IN UINT64 FuseHandle
);
EFI_STATUS
VirtioFsFuseInitSession (
- IN OUT VIRTIO_FS *VirtioFs
+ IN OUT VIRTIO_FS *VirtioFs
);
EFI_STATUS
VirtioFsFuseOpenDir (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 NodeId,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 NodeId,
+ OUT UINT64 *FuseHandle
);
EFI_STATUS
VirtioFsFuseOpenOrCreate (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 ParentNodeId,
- IN CHAR8 *Name,
- OUT UINT64 *NodeId,
- OUT UINT64 *FuseHandle
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 ParentNodeId,
+ IN CHAR8 *Name,
+ OUT UINT64 *NodeId,
+ OUT UINT64 *FuseHandle
);
EFI_STATUS
VirtioFsFuseRename (
- IN OUT VIRTIO_FS *VirtioFs,
- IN UINT64 OldParentNodeId,
- IN CHAR8 *OldName,
- IN UINT64 NewParentNodeId,
- IN CHAR8 *NewName
+ IN OUT VIRTIO_FS *VirtioFs,
+ IN UINT64 OldParentNodeId,
+ IN CHAR8 *OldName,
+ IN UINT64 NewParentNodeId,
+ IN CHAR8 *NewName
);
//
@@ -457,8 +457,8 @@ VirtioFsFuseRename (
EFI_STATUS
EFIAPI
VirtioFsOpenVolume (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **Root
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
);
//
@@ -468,77 +468,77 @@ VirtioFsOpenVolume (
EFI_STATUS
EFIAPI
VirtioFsSimpleFileClose (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileDelete (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileFlush (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileGetPosition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileRead (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileSetPosition (
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
);
EFI_STATUS
EFIAPI
VirtioFsSimpleFileWrite (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
);
#endif // VIRTIO_FS_DXE_H_