efi_loader: disk: install file system protocol to a whole disk
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Mon, 7 Oct 2019 05:59:39 +0000 (14:59 +0900)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 12 Nov 2019 22:13:54 +0000 (23:13 +0100)
Currently, a whole disk without any partitions is not associated
with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. So even if it houses some
file system, there is a chance that we may not be able to access
it, particularly, when accesses are to be attempted after searching
that protocol against a device handle.

With this patch, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed
to such a disk if part_get_info() shows there is no partition
table installed on it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Only if no partition table exists, check for a file system on disk level.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_disk.c

index 861fcaf3747ff87f5d946b380a18d55fac55f360..ed7fb3f7d339e305b5f3ec561c7d407fdbe7d71c 100644 (file)
@@ -337,7 +337,9 @@ static efi_status_t efi_disk_add_dev(
                               diskobj->dp);
        if (ret != EFI_SUCCESS)
                return ret;
-       if (part >= 1 && efi_fs_exists(desc, part)) {
+       /* partitions or whole disk without partitions */
+       if ((part || desc->part_type == PART_TYPE_UNKNOWN) &&
+           efi_fs_exists(desc, part)) {
                diskobj->volume = efi_simple_file_system(desc, part,
                                                         diskobj->dp);
                ret = efi_add_protocol(&diskobj->header,