efi_loader: volume name in EFI_FILE_PROTOCOL.GetInfo()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 8 Sep 2019 08:32:54 +0000 (10:32 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 9 Sep 2019 13:21:09 +0000 (15:21 +0200)
We cannot determine the volume name in U-Boot. Instead of providing a dummy
volume name in case of EFI_FILE_SYSTEM_INFO and EFI_UNSUPPORTED in case of
EFI_FILE_SYSTEM_VOLUME_LABEL consistently return an empty string.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
include/efi_api.h
lib/efi_loader/efi_file.c

index f43fb7a9eaa2694cd929dd926b58a9fabff6d71c..37e56da46030883010d55ba524cf74c198ca9cc9 100644 (file)
@@ -1517,6 +1517,10 @@ struct efi_simple_file_system_protocol {
        EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \
                 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
 
+#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \
+       EFI_GUID(0xdb47d7d3, 0xfe81, 0x11d3, \
+                0x9a, 0x35, 0x00, 0x90, 0x27, 0x3f, 0xC1, 0x4d)
+
 #define EFI_FILE_MODE_READ     0x0000000000000001
 #define EFI_FILE_MODE_WRITE    0x0000000000000002
 #define EFI_FILE_MODE_CREATE   0x8000000000000000
index 4b53016bf1bb298045e0c5d25144df312ecb1e5d..3a108c6bf742ce7574159f07dc4f21e4387ab552 100644 (file)
@@ -15,6 +15,9 @@
 /* GUID for file system information */
 const efi_guid_t efi_file_system_info_guid = EFI_FILE_SYSTEM_INFO_GUID;
 
+/* GUID to obtain the volume label */
+const efi_guid_t efi_system_volume_label_id = EFI_FILE_SYSTEM_VOLUME_LABEL_ID;
+
 struct file_system {
        struct efi_simple_file_system_protocol base;
        struct efi_device_path *dp;
@@ -637,9 +640,7 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file,
                        ret = EFI_DEVICE_ERROR;
                        goto error;
                }
-               required_size = sizeof(*info) + 2 *
-                               (utf8_utf16_strlen((const char *)part.name) +
-                                1);
+               required_size = sizeof(*info) + 2;
                if (*buffer_size < required_size) {
                        *buffer_size = required_size;
                        ret = EFI_BUFFER_TOO_SMALL;
@@ -655,10 +656,15 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file,
                info->block_size = part.blksz;
                /*
                 * TODO: The volume label is not available in U-Boot.
-                * Use the partition name as substitute.
                 */
-               dst = info->volume_label;
-               utf8_utf16_strcpy(&dst, (const char *)part.name);
+               info->volume_label[0] = 0;
+       } else if (!guidcmp(info_type, &efi_system_volume_label_id)) {
+               if (*buffer_size < 2) {
+                       *buffer_size = 2;
+                       ret = EFI_BUFFER_TOO_SMALL;
+                       goto error;
+               }
+               *(u16 *)buffer = 0;
        } else {
                ret = EFI_UNSUPPORTED;
        }