]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: implement EFI_FILE_SYSTEM_INFO
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 4 Apr 2018 13:42:11 +0000 (15:42 +0200)
committerAlexander Graf <agraf@suse.de>
Thu, 5 Apr 2018 08:01:45 +0000 (10:01 +0200)
Implement the information type EFI_FILE_SYSTEM_INFO in the service
GetInfo() of the EFI_FILE_PROTOCOL.

The volume label is not available in U-Boot. As a work-around use the
partition name instead.

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

index 8af466a6dc7f5421c13a541a6130306e957f1c1f..ae9306116065f691f4ea8c50c002169157bfb885 100644 (file)
@@ -889,6 +889,10 @@ struct efi_simple_file_system_protocol {
        EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
                 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
 
+#define EFI_FILE_SYSTEM_INFO_GUID \
+       EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \
+                0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
 #define EFI_FILE_MODE_READ     0x0000000000000001
 #define EFI_FILE_MODE_WRITE    0x0000000000000002
 #define EFI_FILE_MODE_CREATE   0x8000000000000000
@@ -912,6 +916,15 @@ struct efi_file_info {
        s16 file_name[0];
 };
 
+struct efi_file_system_info {
+       u64 size;
+       u8 read_only;
+       u64 volume_size;
+       u64 free_space;
+       u32 block_size;
+       u16 volume_label[0];
+};
+
 #define EFI_DRIVER_BINDING_PROTOCOL_GUID \
        EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\
                 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71)
index 21e6692e92d97d11044d7102e3b6fdc728219c6b..f2942fbb2b61d7813652f65aa7addf6d8ed51935 100644 (file)
@@ -112,6 +112,8 @@ extern const efi_guid_t efi_guid_loaded_image;
 extern const efi_guid_t efi_guid_device_path_to_text_protocol;
 extern const efi_guid_t efi_simple_file_system_protocol_guid;
 extern const efi_guid_t efi_file_info_guid;
+/* GUID for file system information */
+extern const efi_guid_t efi_file_system_info_guid;
 extern const efi_guid_t efi_guid_device_path_utilities_protocol;
 
 extern unsigned int __efi_runtime_start, __efi_runtime_stop;
index 2fc77cfb87400dac8d6e70b0f9524d4449ac7936..cec8347f558722c32ed45ea584f45d3a3497668b 100644 (file)
@@ -12,6 +12,9 @@
 #include <malloc.h>
 #include <fs.h>
 
+/* GUID for file system information */
+const efi_guid_t efi_file_system_info_guid = EFI_FILE_SYSTEM_INFO_GUID;
+
 struct file_system {
        struct efi_simple_file_system_protocol base;
        struct efi_device_path *dp;
@@ -472,6 +475,41 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file,
                        info->attribute |= EFI_FILE_DIRECTORY;
 
                ascii2unicode((u16 *)info->file_name, filename);
+       } else if (!guidcmp(info_type, &efi_file_system_info_guid)) {
+               struct efi_file_system_info *info = buffer;
+               disk_partition_t part;
+               efi_uintn_t required_size;
+               int r;
+
+               if (fh->fs->part >= 1)
+                       r = part_get_info(fh->fs->desc, fh->fs->part, &part);
+               else
+                       r = part_get_info_whole_disk(fh->fs->desc, &part);
+               if (r < 0) {
+                       ret = EFI_DEVICE_ERROR;
+                       goto error;
+               }
+               required_size = sizeof(info) + 2 *
+                               (strlen((const char *)part.name) + 1);
+               if (*buffer_size < required_size) {
+                       *buffer_size = required_size;
+                       ret = EFI_BUFFER_TOO_SMALL;
+                       goto error;
+               }
+
+               memset(info, 0, required_size);
+
+               info->size = required_size;
+               info->read_only = true;
+               info->volume_size = part.size * part.blksz;
+               info->free_space = 0;
+               info->block_size = part.blksz;
+               /*
+                * TODO: The volume label is not available in U-Boot.
+                * Use the partition name as substitute.
+                */
+               ascii2unicode((u16 *)info->volume_label,
+                             (const char *)part.name);
        } else {
                ret = EFI_UNSUPPORTED;
        }