summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2020-12-16 22:10:54 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-12-21 17:16:23 +0000
commit7e8c83f7d4823009d1f37ec6a0fa2c4ef888c2d5 (patch)
treea456ed9441ce09e1a5f109edbb8baae3377aabd6 /OvmfPkg/VirtioFsDxe
parent9307d7c7a4a851615f1c4ac92e59f1ba33a3f626 (diff)
downloadedk2-7e8c83f7d4823009d1f37ec6a0fa2c4ef888c2d5.tar.gz
edk2-7e8c83f7d4823009d1f37ec6a0fa2c4ef888c2d5.tar.bz2
edk2-7e8c83f7d4823009d1f37ec6a0fa2c4ef888c2d5.zip
OvmfPkg/VirtioFsDxe: manage path lifecycle in OpenVolume, Close, Delete
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>
Diffstat (limited to 'OvmfPkg/VirtioFsDxe')
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsClose.c1
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsDelete.c1
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c13
-rw-r--r--OvmfPkg/VirtioFsDxe/VirtioFsDxe.h1
4 files changed, 15 insertions, 1 deletions
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
index bc91ad726b..04b4f2c382 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
@@ -59,6 +59,7 @@ VirtioFsSimpleFileClose (
//
RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
+ FreePool (VirtioFsFile->CanonicalPathname);
FreePool (VirtioFsFile);
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
index bbad64bf78..e2fc2d72df 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c
@@ -63,6 +63,7 @@ VirtioFsSimpleFileDelete (
//
RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
+ FreePool (VirtioFsFile->CanonicalPathname);
FreePool (VirtioFsFile);
return Status;
}
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
index 67d2deb6bd..9c0ab434c1 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c
@@ -28,6 +28,7 @@ VirtioFsOpenVolume (
VIRTIO_FS *VirtioFs;
VIRTIO_FS_FILE *VirtioFsFile;
EFI_STATUS Status;
+ CHAR8 *CanonicalPathname;
UINT64 RootDirHandle;
VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This);
@@ -37,13 +38,19 @@ VirtioFsOpenVolume (
return EFI_OUT_OF_RESOURCES;
}
+ CanonicalPathname = AllocateCopyPool (sizeof "/", "/");
+ if (CanonicalPathname == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto FreeVirtioFsFile;
+ }
+
//
// Open the root directory.
//
Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
&RootDirHandle);
if (EFI_ERROR (Status)) {
- goto FreeVirtioFsFile;
+ goto FreeCanonicalPathname;
}
//
@@ -64,6 +71,7 @@ VirtioFsOpenVolume (
VirtioFsFile->IsDirectory = TRUE;
VirtioFsFile->IsOpenForWriting = FALSE;
VirtioFsFile->OwnerFs = VirtioFs;
+ VirtioFsFile->CanonicalPathname = CanonicalPathname;
VirtioFsFile->NodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;
VirtioFsFile->FuseHandle = RootDirHandle;
@@ -75,6 +83,9 @@ VirtioFsOpenVolume (
*Root = &VirtioFsFile->SimpleFile;
return EFI_SUCCESS;
+FreeCanonicalPathname:
+ FreePool (CanonicalPathname);
+
FreeVirtioFsFile:
FreePool (VirtioFsFile);
diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h
index f4fed64c72..487d215c7f 100644
--- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h
+++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h
@@ -137,6 +137,7 @@ typedef struct {
BOOLEAN IsOpenForWriting;
VIRTIO_FS *OwnerFs;
LIST_ENTRY OpenFilesEntry;
+ CHAR8 *CanonicalPathname;
//
// 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