mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
9307d7c7a4
commit
7e8c83f7d4
|
@ -59,6 +59,7 @@ VirtioFsSimpleFileClose (
|
||||||
//
|
//
|
||||||
RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
|
RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
|
||||||
|
|
||||||
|
FreePool (VirtioFsFile->CanonicalPathname);
|
||||||
FreePool (VirtioFsFile);
|
FreePool (VirtioFsFile);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ VirtioFsSimpleFileDelete (
|
||||||
//
|
//
|
||||||
RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
|
RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
|
||||||
|
|
||||||
|
FreePool (VirtioFsFile->CanonicalPathname);
|
||||||
FreePool (VirtioFsFile);
|
FreePool (VirtioFsFile);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ VirtioFsOpenVolume (
|
||||||
VIRTIO_FS *VirtioFs;
|
VIRTIO_FS *VirtioFs;
|
||||||
VIRTIO_FS_FILE *VirtioFsFile;
|
VIRTIO_FS_FILE *VirtioFsFile;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
CHAR8 *CanonicalPathname;
|
||||||
UINT64 RootDirHandle;
|
UINT64 RootDirHandle;
|
||||||
|
|
||||||
VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This);
|
VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This);
|
||||||
|
@ -37,13 +38,19 @@ VirtioFsOpenVolume (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CanonicalPathname = AllocateCopyPool (sizeof "/", "/");
|
||||||
|
if (CanonicalPathname == NULL) {
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto FreeVirtioFsFile;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open the root directory.
|
// Open the root directory.
|
||||||
//
|
//
|
||||||
Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
|
Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
|
||||||
&RootDirHandle);
|
&RootDirHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto FreeVirtioFsFile;
|
goto FreeCanonicalPathname;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -64,6 +71,7 @@ VirtioFsOpenVolume (
|
||||||
VirtioFsFile->IsDirectory = TRUE;
|
VirtioFsFile->IsDirectory = TRUE;
|
||||||
VirtioFsFile->IsOpenForWriting = FALSE;
|
VirtioFsFile->IsOpenForWriting = FALSE;
|
||||||
VirtioFsFile->OwnerFs = VirtioFs;
|
VirtioFsFile->OwnerFs = VirtioFs;
|
||||||
|
VirtioFsFile->CanonicalPathname = CanonicalPathname;
|
||||||
VirtioFsFile->NodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;
|
VirtioFsFile->NodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;
|
||||||
VirtioFsFile->FuseHandle = RootDirHandle;
|
VirtioFsFile->FuseHandle = RootDirHandle;
|
||||||
|
|
||||||
|
@ -75,6 +83,9 @@ VirtioFsOpenVolume (
|
||||||
*Root = &VirtioFsFile->SimpleFile;
|
*Root = &VirtioFsFile->SimpleFile;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
FreeCanonicalPathname:
|
||||||
|
FreePool (CanonicalPathname);
|
||||||
|
|
||||||
FreeVirtioFsFile:
|
FreeVirtioFsFile:
|
||||||
FreePool (VirtioFsFile);
|
FreePool (VirtioFsFile);
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ typedef struct {
|
||||||
BOOLEAN IsOpenForWriting;
|
BOOLEAN IsOpenForWriting;
|
||||||
VIRTIO_FS *OwnerFs;
|
VIRTIO_FS *OwnerFs;
|
||||||
LIST_ENTRY OpenFilesEntry;
|
LIST_ENTRY OpenFilesEntry;
|
||||||
|
CHAR8 *CanonicalPathname;
|
||||||
//
|
//
|
||||||
// In the FUSE wire protocol, every request except FUSE_INIT refers to a
|
// 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
|
// file, namely by the "VIRTIO_FS_FUSE_REQUEST.NodeId" field; that is, by the
|
||||||
|
|
Loading…
Reference in New Issue