]>
git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioFsDxe/SimpleFsWrite.c
8ae317c88e43c184af87c7baf883040f1b02bf1d
2 EFI_FILE_PROTOCOL.Write() member function for the Virtio Filesystem driver.
4 Copyright (C) 2020, Red Hat, Inc.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "VirtioFsDxe.h"
13 VirtioFsSimpleFileWrite (
14 IN EFI_FILE_PROTOCOL
*This
,
15 IN OUT UINTN
*BufferSize
,
19 VIRTIO_FS_FILE
*VirtioFsFile
;
25 VirtioFsFile
= VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This
);
26 VirtioFs
= VirtioFsFile
->OwnerFs
;
28 if (VirtioFsFile
->IsDirectory
) {
29 return EFI_UNSUPPORTED
;
31 if (!VirtioFsFile
->IsOpenForWriting
) {
32 return EFI_ACCESS_DENIED
;
42 // Honor the write buffer size limit.
44 WriteSize
= (UINT32
)MIN ((UINTN
)VirtioFs
->MaxWrite
, Left
);
45 Status
= VirtioFsFuseWrite (
48 VirtioFsFile
->FuseHandle
,
49 VirtioFsFile
->FilePosition
+ Transferred
,
51 (UINT8
*)Buffer
+ Transferred
53 if (!EFI_ERROR (Status
) && WriteSize
== 0) {
55 // Progress should have been made.
57 Status
= EFI_DEVICE_ERROR
;
59 if (EFI_ERROR (Status
)) {
62 Transferred
+= WriteSize
;
66 *BufferSize
= Transferred
;
67 VirtioFsFile
->FilePosition
+= Transferred
;
69 // According to the UEFI spec,
71 // - 'Partial writes only occur when there has been a data error during the
72 // write attempt (such as "file space full")', and
74 // - (as an example) EFI_VOLUME_FULL is returned when 'The volume is full'.
76 // These together imply that after a partial write, we have to return an
77 // error. In other words, (Transferred > 0) is inconsequential for the return