|
|
|
@ -1,24 +1,24 @@
|
|
|
|
|
From 49ed9305afae9865d9b748ef419b4f923ae4e86d Mon Sep 17 00:00:00 2001
|
|
|
|
|
From a7eaefd9bc4a91a4ca26146f784d40725cfe15fa Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
|
|
|
|
|
Date: Wed, 29 Sep 2021 15:46:37 +0200
|
|
|
|
|
Date: Wed, 29 Sep 2021 15:33:33 +0200
|
|
|
|
|
Subject: [PATCH] Fix incorrect byte order of partition names on big-endian
|
|
|
|
|
systems
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
gdisk.8 | 8 ++++++++
|
|
|
|
|
gptcl.cc | 11 +++++++++++
|
|
|
|
|
gptpart.cc | 13 +++++++------
|
|
|
|
|
gptpart.cc | 14 +++++++-------
|
|
|
|
|
gptpart.h | 1 +
|
|
|
|
|
gpttext.cc | 20 ++++++++++++++++++++
|
|
|
|
|
gpttext.h | 1 +
|
|
|
|
|
sgdisk.8 | 8 ++++++++
|
|
|
|
|
7 files changed, 56 insertions(+), 6 deletions(-)
|
|
|
|
|
7 files changed, 56 insertions(+), 7 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/gdisk.8 b/gdisk.8
|
|
|
|
|
index 62f6bd2..0029b75 100644
|
|
|
|
|
index c2cf83d..071756c 100644
|
|
|
|
|
--- a/gdisk.8
|
|
|
|
|
+++ b/gdisk.8
|
|
|
|
|
@@ -419,6 +419,14 @@ set features for each partition. \fBgdisk\fR supports four attributes:
|
|
|
|
|
@@ -416,6 +416,14 @@ set features for each partition. \fBgdisk\fR supports four attributes:
|
|
|
|
|
aren't translated into anything useful. In practice, most OSes seem to
|
|
|
|
|
ignore these attributes.
|
|
|
|
|
|
|
|
|
@ -34,7 +34,7 @@ index 62f6bd2..0029b75 100644
|
|
|
|
|
.B c
|
|
|
|
|
Change partition GUID. You can enter a custom unique GUID for a partition
|
|
|
|
|
diff --git a/gptcl.cc b/gptcl.cc
|
|
|
|
|
index 2304091..65a99e9 100644
|
|
|
|
|
index 6c36738..58afc8a 100644
|
|
|
|
|
--- a/gptcl.cc
|
|
|
|
|
+++ b/gptcl.cc
|
|
|
|
|
@@ -64,6 +64,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
|
|
|
|
@ -70,10 +70,18 @@ index 2304091..65a99e9 100644
|
|
|
|
|
SaveGPTBackup(backupFile);
|
|
|
|
|
free(backupFile);
|
|
|
|
|
diff --git a/gptpart.cc b/gptpart.cc
|
|
|
|
|
index b268cf0..b83254d 100644
|
|
|
|
|
index 17d6f15..82aeab0 100644
|
|
|
|
|
--- a/gptpart.cc
|
|
|
|
|
+++ b/gptpart.cc
|
|
|
|
|
@@ -242,7 +242,6 @@ void GPTPart::SetName(const string & theName) {
|
|
|
|
|
@@ -83,7 +83,6 @@ string GPTPart::GetDescription(void) {
|
|
|
|
|
size_t pos = 0 ;
|
|
|
|
|
while ( ( pos < NAME_SIZE ) && ( name[ pos ] != 0 ) ) {
|
|
|
|
|
uint16_t cp = name[ pos ++ ] ;
|
|
|
|
|
- if ( ! IsLittleEndian() ) ReverseBytes( & cp , 2 ) ;
|
|
|
|
|
// first to utf32
|
|
|
|
|
uint32_t uni ;
|
|
|
|
|
if ( cp < 0xd800 || cp > 0xdfff ) {
|
|
|
|
|
@@ -234,7 +233,6 @@ void GPTPart::SetName(const string & theName) {
|
|
|
|
|
// then to utf16le
|
|
|
|
|
if ( uni < 0x10000 ) {
|
|
|
|
|
name[ pos ] = (uint16_t) uni ;
|
|
|
|
@ -81,7 +89,7 @@ index b268cf0..b83254d 100644
|
|
|
|
|
pos ++ ;
|
|
|
|
|
} // if
|
|
|
|
|
else {
|
|
|
|
|
@@ -252,10 +251,8 @@ void GPTPart::SetName(const string & theName) {
|
|
|
|
|
@@ -244,10 +242,8 @@ void GPTPart::SetName(const string & theName) {
|
|
|
|
|
} // if
|
|
|
|
|
uni -= 0x10000 ;
|
|
|
|
|
name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ;
|
|
|
|
@ -92,7 +100,7 @@ index b268cf0..b83254d 100644
|
|
|
|
|
pos ++ ;
|
|
|
|
|
}
|
|
|
|
|
} // for
|
|
|
|
|
@@ -415,14 +412,18 @@ int GPTPart::DoTheyOverlap(const GPTPart & other) {
|
|
|
|
|
@@ -407,14 +403,18 @@ int GPTPart::DoTheyOverlap(const GPTPart & other) {
|
|
|
|
|
// Reverse the bytes of integral data types and of the UTF-16LE name;
|
|
|
|
|
// used on big-endian systems.
|
|
|
|
|
void GPTPart::ReversePartBytes(void) {
|
|
|
|
@ -115,10 +123,10 @@ index b268cf0..b83254d 100644
|
|
|
|
|
/****************************************
|
|
|
|
|
* Functions requiring user interaction *
|
|
|
|
|
diff --git a/gptpart.h b/gptpart.h
|
|
|
|
|
index fac514e..51bfb38 100644
|
|
|
|
|
index 657b3f9..ac8a725 100644
|
|
|
|
|
--- a/gptpart.h
|
|
|
|
|
+++ b/gptpart.h
|
|
|
|
|
@@ -94,6 +94,7 @@ class GPTPart {
|
|
|
|
|
@@ -93,6 +93,7 @@ class GPTPart {
|
|
|
|
|
void BlankPartition(void); // empty partition of data
|
|
|
|
|
int DoTheyOverlap(const GPTPart & other); // returns 1 if there's overlap
|
|
|
|
|
void ReversePartBytes(void); // reverse byte order of all integer fields
|
|
|
|
@ -127,7 +135,7 @@ index fac514e..51bfb38 100644
|
|
|
|
|
// Functions requiring user interaction
|
|
|
|
|
void ChangeType(void); // Change the type code
|
|
|
|
|
diff --git a/gpttext.cc b/gpttext.cc
|
|
|
|
|
index ea34444..a5f0fd8 100644
|
|
|
|
|
index 732d861..6de7121 100644
|
|
|
|
|
--- a/gpttext.cc
|
|
|
|
|
+++ b/gpttext.cc
|
|
|
|
|
@@ -341,6 +341,22 @@ int GPTDataTextUI::SetName(uint32_t partNum) {
|
|
|
|
@ -172,7 +180,7 @@ index ea34444..a5f0fd8 100644
|
|
|
|
|
cout << "d\tdisplay the sector alignment value\n";
|
|
|
|
|
cout << "e\trelocate backup data structures to the end of the disk\n";
|
|
|
|
|
diff --git a/gpttext.h b/gpttext.h
|
|
|
|
|
index afe4651..6bd22cf 100644
|
|
|
|
|
index 98e59af..db27246 100644
|
|
|
|
|
--- a/gpttext.h
|
|
|
|
|
+++ b/gpttext.h
|
|
|
|
|
@@ -49,6 +49,7 @@ class GPTDataTextUI : public GPTData {
|
|
|
|
@ -184,7 +192,7 @@ index afe4651..6bd22cf 100644
|
|
|
|
|
int DestroyGPTwPrompt(void); // Returns 1 if user proceeds
|
|
|
|
|
void ShowDetails(void);
|
|
|
|
|
diff --git a/sgdisk.8 b/sgdisk.8
|
|
|
|
|
index 59a3d3c..3fb7ae6 100644
|
|
|
|
|
index 2cb18b9..3bc51f2 100644
|
|
|
|
|
--- a/sgdisk.8
|
|
|
|
|
+++ b/sgdisk.8
|
|
|
|
|
@@ -182,6 +182,14 @@ backup will reflect your changes. If the GPT data structures are damaged,
|
|
|
|
@ -203,5 +211,5 @@ index 59a3d3c..3fb7ae6 100644
|
|
|
|
|
.B \-c, \-\-change\-name=partnum:name
|
|
|
|
|
Change the GPT name of a partition. This name is encoded as a UTF\-16
|
|
|
|
|
--
|
|
|
|
|
2.32.0
|
|
|
|
|
2.35.1
|
|
|
|
|
|