summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe/DriverBinding.c
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2020-12-16 22:10:48 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-12-21 17:16:23 +0000
commit334c13e106ebad35a8e620f3b0f1179a1a6eaa54 (patch)
treef451f9c97671155b6935dfd66517aec0175a6919 /OvmfPkg/VirtioFsDxe/DriverBinding.c
parent72d4f133e9674e25d8fbbeda1b6746f9bd29ad7f (diff)
downloadedk2-334c13e106ebad35a8e620f3b0f1179a1a6eaa54.tar.gz
edk2-334c13e106ebad35a8e620f3b0f1179a1a6eaa54.tar.bz2
edk2-334c13e106ebad35a8e620f3b0f1179a1a6eaa54.zip
OvmfPkg/VirtioFsDxe: implement EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()
With the help of the VirtioFsFuseOpenDir() and VirtioFsFuseReleaseFileOrDir() functions introduced previously, we can now open and close the root directory. So let's implement EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume(). OpenVolume() creates a new EFI_FILE_PROTOCOL object -- a reference to the root directory of the filesystem. Thus, we have to start tracking references to EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, lest we unbind the virtio-fs device while files are open. There are two methods that release an EFI_FILE_PROTOCOL object: the Close() and the Delete() member functions. In particular, they are not allowed to fail with regard to resource management -- they must release resources unconditionally. Thus, for rolling back the resource accounting that we do in EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume(), we have to implement the first versions of EFI_FILE_PROTOCOL.Close() and EFI_FILE_PROTOCOL.Delete() in this patch as well. With this patch applied, the UEFI shell can enter the root directory of the Virtio Filesystem (such as with the "FS3:" shell command), and the "DIR" shell command exercises FUSE_OPENDIR and FUSE_RELEASEDIR, according to the virtiofsd log. The "DIR" command reports the root directory as if it were empty; probably because at this time, we only allow the shell to open and to close the root directory, but not to read it. 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-12-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Diffstat (limited to 'OvmfPkg/VirtioFsDxe/DriverBinding.c')
-rw-r--r--OvmfPkg/VirtioFsDxe/DriverBinding.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/OvmfPkg/VirtioFsDxe/DriverBinding.c b/OvmfPkg/VirtioFsDxe/DriverBinding.c
index 4f77ffaa99..e273c9f362 100644
--- a/OvmfPkg/VirtioFsDxe/DriverBinding.c
+++ b/OvmfPkg/VirtioFsDxe/DriverBinding.c
@@ -95,6 +95,7 @@ VirtioFsBindingStart (
goto UninitVirtioFs;
}
+ InitializeListHead (&VirtioFs->OpenFiles);
VirtioFs->SimpleFs.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
VirtioFs->SimpleFs.OpenVolume = VirtioFsOpenVolume;
@@ -149,6 +150,10 @@ VirtioFsBindingStop (
VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (SimpleFs);
+ if (!IsListEmpty (&VirtioFs->OpenFiles)) {
+ return EFI_ACCESS_DENIED;
+ }
+
Status = gBS->UninstallProtocolInterface (ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid, SimpleFs);
if (EFI_ERROR (Status)) {