]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/VirtioFsDxe: manage path lifecycle in OpenVolume, Close, Delete
authorLaszlo Ersek <lersek@redhat.com>
Wed, 16 Dec 2020 21:10:54 +0000 (22:10 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 21 Dec 2020 17:16:23 +0000 (17:16 +0000)
Add a canonical pathname field to VIRTIO_FS_FILE.

Initialize the new field in EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().

Release the new field in EFI_FILE_PROTOCOL.Close() and
EFI_FILE_PROTOCOL.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-18-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
OvmfPkg/VirtioFsDxe/SimpleFsClose.c
OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
OvmfPkg/VirtioFsDxe/VirtioFsDxe.h

index bc91ad726b2c768a98dab729720600b9b6d3b1b0..04b4f2c382d7cbcc033c67a0fa95fa24a3b4d7b6 100644 (file)
@@ -59,6 +59,7 @@ VirtioFsSimpleFileClose (
   //\r
   RemoveEntryList (&VirtioFsFile->OpenFilesEntry);\r
 \r
+  FreePool (VirtioFsFile->CanonicalPathname);\r
   FreePool (VirtioFsFile);\r
   return EFI_SUCCESS;\r
 }\r
index bbad64bf788674fb7fbeece292961f02aab5c587..e2fc2d72dfeb82cab1acb99ed35d9f81185b6be7 100644 (file)
@@ -63,6 +63,7 @@ VirtioFsSimpleFileDelete (
   //\r
   RemoveEntryList (&VirtioFsFile->OpenFilesEntry);\r
 \r
+  FreePool (VirtioFsFile->CanonicalPathname);\r
   FreePool (VirtioFsFile);\r
   return Status;\r
 }\r
index 67d2deb6bdf27ee0fadb98ddf3c7902349eeed8a..9c0ab434c186698f544551aabf59435ae30b077d 100644 (file)
@@ -28,6 +28,7 @@ VirtioFsOpenVolume (
   VIRTIO_FS      *VirtioFs;\r
   VIRTIO_FS_FILE *VirtioFsFile;\r
   EFI_STATUS     Status;\r
+  CHAR8          *CanonicalPathname;\r
   UINT64         RootDirHandle;\r
 \r
   VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This);\r
@@ -37,13 +38,19 @@ VirtioFsOpenVolume (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  CanonicalPathname = AllocateCopyPool (sizeof "/", "/");\r
+  if (CanonicalPathname == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto FreeVirtioFsFile;\r
+  }\r
+\r
   //\r
   // Open the root directory.\r
   //\r
   Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,\r
              &RootDirHandle);\r
   if (EFI_ERROR (Status)) {\r
-    goto FreeVirtioFsFile;\r
+    goto FreeCanonicalPathname;\r
   }\r
 \r
   //\r
@@ -64,6 +71,7 @@ VirtioFsOpenVolume (
   VirtioFsFile->IsDirectory            = TRUE;\r
   VirtioFsFile->IsOpenForWriting       = FALSE;\r
   VirtioFsFile->OwnerFs                = VirtioFs;\r
+  VirtioFsFile->CanonicalPathname      = CanonicalPathname;\r
   VirtioFsFile->NodeId                 = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;\r
   VirtioFsFile->FuseHandle             = RootDirHandle;\r
 \r
@@ -75,6 +83,9 @@ VirtioFsOpenVolume (
   *Root = &VirtioFsFile->SimpleFile;\r
   return EFI_SUCCESS;\r
 \r
+FreeCanonicalPathname:\r
+  FreePool (CanonicalPathname);\r
+\r
 FreeVirtioFsFile:\r
   FreePool (VirtioFsFile);\r
 \r
index f4fed64c7217baf8f052e956e415afc60626b47a..487d215c7f38fb20827e474e81fa9b787d9b27c3 100644 (file)
@@ -137,6 +137,7 @@ typedef struct {
   BOOLEAN           IsOpenForWriting;\r
   VIRTIO_FS         *OwnerFs;\r
   LIST_ENTRY        OpenFilesEntry;\r
+  CHAR8             *CanonicalPathname;\r
   //\r
   // In the FUSE wire protocol, every request except FUSE_INIT refers to a\r
   // file, namely by the "VIRTIO_FS_FUSE_REQUEST.NodeId" field; that is, by the\r