- Fix partition naming patch for big endian systems.

This commit is contained in:
Brian C. Lane 2014-05-16 16:20:42 -07:00
parent f0247c09aa
commit 3e3c91556c
2 changed files with 63 additions and 9 deletions

View File

@ -1,4 +1,4 @@
From 77ce72ddf2bfbb34c8ef02ab955acbec20d643db Mon Sep 17 00:00:00 2001
From 503747d270182088da1298697f5f8651ac1647f4 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 16 May 2014 10:23:28 -0700
Subject: [PATCH] GPT strings are UCS-2LE not UTF-16
@ -11,15 +11,35 @@ checking the written string.
* libparted/labels/gpt.c: Switch to UCS-2LE for GPT Partition names
* tests/t0251-gpt-unicode.sh: Update the test
---
libparted/labels/gpt.c | 4 ++--
tests/t0251-gpt-unicode.sh | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
libparted/labels/gpt.c | 22 ++++++++++------------
tests/t0251-gpt-unicode.sh | 2 +-
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 31f6d17..c19cb59 100644
index 31f6d17..e1113ac 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1891,7 +1891,7 @@ gpt_partition_set_name (PedPartition *part, const char *name)
@@ -819,8 +819,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->type = pte->PartitionTypeGuid;
gpt_part_data->uuid = pte->UniquePartitionGuid;
for (i = 0; i < 36; i++)
- gpt_part_data->name[i] =
- (efi_char16_t) PED_LE16_TO_CPU ((uint16_t) pte->PartitionName[i]);
+ gpt_part_data->name[i] = (efi_char16_t) pte->PartitionName[i];
gpt_part_data->name[i] = 0;
gpt_part_data->translated_name = 0;
@@ -1237,8 +1236,7 @@ _partition_generate_part_entry (PedPartition *part, GuidPartitionEntry_t *pte)
pte->Attributes.LegacyBIOSBootable = 1;
for (i = 0; i < 36; i++)
- pte->PartitionName[i]
- = (efi_char16_t) PED_CPU_TO_LE16 ((uint16_t) gpt_part_data->name[i]);
+ pte->PartitionName[i] = gpt_part_data->name[i];
}
static int
@@ -1891,7 +1889,7 @@ gpt_partition_set_name (PedPartition *part, const char *name)
free(gpt_part_data->translated_name);
gpt_part_data->translated_name = xstrdup(name);
@ -28,15 +48,46 @@ index 31f6d17..c19cb59 100644
if (conv == (iconv_t)-1)
goto err;
char *inbuff = gpt_part_data->translated_name;
@@ -1916,7 +1916,7 @@ gpt_partition_get_name (const PedPartition *part)
@@ -1904,8 +1902,8 @@ gpt_partition_set_name (PedPartition *part, const char *name)
return;
err:
ped_exception_throw (PED_EXCEPTION_WARNING,
- PED_EXCEPTION_IGNORE,
- _("Can not translate partition name"));
+ PED_EXCEPTION_IGNORE,
+ _("Can not translate partition name"));
iconv_close (conv);
}
@@ -1916,23 +1914,23 @@ gpt_partition_get_name (const PedPartition *part)
if (gpt_part_data->translated_name == NULL)
{
char buffer[200];
- iconv_t conv = iconv_open (nl_langinfo (CODESET), "UTF-16");
+ iconv_t conv = iconv_open (nl_langinfo (CODESET), "UCS-2LE");
if (conv == (iconv_t)-1)
goto err;
- goto err;
+ goto err;
char *inbuff = (char *)&gpt_part_data->name;
char *outbuff = buffer;
size_t inbuffsize = 72;
size_t outbuffsize = sizeof(buffer);
if (iconv (conv, &inbuff, &inbuffsize, &outbuff, &outbuffsize) == -1)
- goto err;
+ goto err;
iconv_close (conv);
*outbuff = 0;
gpt_part_data->translated_name = xstrdup (buffer);
return gpt_part_data->translated_name;
err:
ped_exception_throw (PED_EXCEPTION_WARNING,
- PED_EXCEPTION_IGNORE,
- _("Can not translate partition name"));
+ PED_EXCEPTION_IGNORE,
+ _("Can not translate partition name"));
iconv_close (conv);
return "";
}
diff --git a/tests/t0251-gpt-unicode.sh b/tests/t0251-gpt-unicode.sh
index 36a4c26..fbffbcb 100755
--- a/tests/t0251-gpt-unicode.sh

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.1
Release: 22%{?dist}
Release: 23%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -261,6 +261,9 @@ fi
%changelog
* Fri May 16 2014 Brian C. Lane <bcl@redhat.com> 3.1-23
- Fix partition naming patch for big endian systems.
* Fri May 16 2014 Brian C. Lane <bcl@redhat.com> 3.1-22
- Fix a problem with GPT Partition names using. They are UCS-2LE not UTF-16