summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2020-12-16 22:11:04 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-12-21 17:16:23 +0000
commitc09441c3211c1b1e5067b870b0c08249ea3293b9 (patch)
tree2cc99d10968b047d66a39aec36369447a916f34f /OvmfPkg/VirtioFsDxe
parentde0e11902b12ce0a6ffdb18bde65acfde1d6172b (diff)
downloadedk2-c09441c3211c1b1e5067b870b0c08249ea3293b9.tar.gz
edk2-c09441c3211c1b1e5067b870b0c08249ea3293b9.tar.bz2
edk2-c09441c3211c1b1e5067b870b0c08249ea3293b9.zip
OvmfPkg/VirtioFsDxe: erase the dir. entry in EFI_FILE_PROTOCOL.Delete()
At this point, the infrastructure is available for looking up the directly containing directory of the file in EFI_FILE_PROTOCOL.Delete(), and to remove the file in that directory by last pathname component. Do so. The "RM" UEFI shell command will start working only later in the series; the shell needs more EFI_FILE_PROTOCOL members to function before it calls Delete(). Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20201216211125.19496-28-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Diffstat (limited to 'OvmfPkg/VirtioFsDxe')
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsDelete.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
index e2fc2d72df..76cfee5bce 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
@@ -46,9 +46,47 @@ VirtioFsSimpleFileDelete (
// is still valid. Continue with removing the file or directory. The result
// of this operation determines the return status of the function.
//
- // TODO
- //
- Status = EFI_WARN_DELETE_FAILURE;
+ if (VirtioFsFile->IsOpenForWriting) {
+ UINT64 ParentNodeId;
+ CHAR8 *LastComponent;
+
+ //
+ // Split our canonical pathname into most specific parent directory
+ // (identified by NodeId), and single-component filename within that
+ // directory. If This stands for the root directory "/", then the following
+ // function call will gracefully fail.
+ //
+ Status = VirtioFsLookupMostSpecificParentDir (
+ VirtioFs,
+ VirtioFsFile->CanonicalPathname,
+ &ParentNodeId,
+ &LastComponent
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Attempt the actual removal. Regardless of the outcome, ParentNodeId
+ // must be forgotten right after (unless it stands for the root
+ // directory).
+ //
+ Status = VirtioFsFuseRemoveFileOrDir (
+ VirtioFs,
+ ParentNodeId,
+ LastComponent,
+ VirtioFsFile->IsDirectory
+ );
+ if (ParentNodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
+ VirtioFsFuseForget (VirtioFs, ParentNodeId);
+ }
+ }
+ if (EFI_ERROR (Status)) {
+ //
+ // Map any failure to the spec-mandated warning code.
+ //
+ Status = EFI_WARN_DELETE_FAILURE;
+ }
+ } else {
+ Status = EFI_WARN_DELETE_FAILURE;
+ }
//
// Finally, if we've known VirtioFsFile->NodeId from a lookup, then we should