diff options
Diffstat (limited to 'OvmfPkg/VirtioFsDxe/SimpleFsWrite.c')
-rw-r--r-- | OvmfPkg/VirtioFsDxe/SimpleFsWrite.c | 41 |
1 files changed, 22 insertions, 19 deletions
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,
|