summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2010-10-12 16:17:04 -0700
committerTodd Poynor <toddpoynor@google.com>2010-10-12 16:24:27 -0700
commit0a9a538f34acc96b2e23c87728448d29b0186949 (patch)
tree6104b220336ad9a08971a78f71f862e5be0f1335 /fs
parent1e30babbdcfd06866a6c4a75b1e1e7a886a8545b (diff)
fs: EFI: Convert UTF-16LE partition names to UTF-8
Change-Id: Ib3f91913e69ca8d5a3bd644e3a01deca690067a8 Signed-off-by: Todd Poynor <toddpoynor@google.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/partitions/efi.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 486b4444e6a4..35bbbd279d73 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -96,6 +96,7 @@
#include <linux/crc32.h>
#include <linux/math64.h>
#include <linux/slab.h>
+#include <linux/nls.h>
#include "check.h"
#include "efi.h"
@@ -617,15 +618,20 @@ int efi_partition(struct parsed_partitions *state)
u64 start = le64_to_cpu(ptes[i].starting_lba);
u64 size = le64_to_cpu(ptes[i].ending_lba) -
le64_to_cpu(ptes[i].starting_lba) + 1ULL;
+ u8 name[sizeof(ptes->partition_name) / sizeof(efi_char16_t)];
+ int len;
if (!is_pte_valid(&ptes[i], last_lba(state->bdev)))
continue;
+ len = utf16s_to_utf8s(ptes[i].partition_name,
+ sizeof(ptes[i].partition_name) /
+ sizeof(efi_char16_t),
+ UTF16_LITTLE_ENDIAN, name,
+ sizeof(name));
+
put_named_partition(state, i+1, start * ssz, size * ssz,
- (const char *) ptes[i].partition_name,
- strnlen((const char *)
- ptes[i].partition_name,
- sizeof(ptes[i].partition_name)));
+ name, len);
/* If this is a RAID volume, tell md */
if (!efi_guidcmp(ptes[i].partition_type_guid,