From de04009745c9c740398321a1f88df4b09771182d Mon Sep 17 00:00:00 2001 From: James Antill Date: Thu, 26 May 2022 07:34:39 -0400 Subject: [PATCH] Auto sync2gitlab import of gdisk-1.0.3-9.el8.src.rpm --- .gitignore | 1 + EMPTY | 1 - gdisk-1.0.3-byteswap.patch | 215 +++++++++++++++++++++++++++++++++++++ gdisk.spec | 204 +++++++++++++++++++++++++++++++++++ sources | 1 + 5 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 .gitignore delete mode 100644 EMPTY create mode 100644 gdisk-1.0.3-byteswap.patch create mode 100644 gdisk.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bff900f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/gptfdisk-1.0.3.tar.gz diff --git a/EMPTY b/EMPTY deleted file mode 100644 index 0519ecb..0000000 --- a/EMPTY +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/gdisk-1.0.3-byteswap.patch b/gdisk-1.0.3-byteswap.patch new file mode 100644 index 0000000..865091a --- /dev/null +++ b/gdisk-1.0.3-byteswap.patch @@ -0,0 +1,215 @@ +From a7eaefd9bc4a91a4ca26146f784d40725cfe15fa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nikola=20Forr=C3=B3?= +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 | 14 +++++++------- + gptpart.h | 1 + + gpttext.cc | 20 ++++++++++++++++++++ + gpttext.h | 1 + + sgdisk.8 | 8 ++++++++ + 7 files changed, 56 insertions(+), 7 deletions(-) + +diff --git a/gdisk.8 b/gdisk.8 +index c2cf83d..071756c 100644 +--- a/gdisk.8 ++++ b/gdisk.8 +@@ -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. + ++.TP ++.B b ++Swap the byte order for the name of the specified partition. Some ++partitioning tools, including GPT fdisk 1.0.7 and earlier, can write the ++partition name in the wrong byte order on big-endian computers, such as the ++IBM s390 mainframes and PowerPC-based Macs. This feature corrects this ++problem. ++ + .TP + .B c + Change partition GUID. You can enter a custom unique GUID for a partition +diff --git a/gptcl.cc b/gptcl.cc +index 6c36738..58afc8a 100644 +--- a/gptcl.cc ++++ b/gptcl.cc +@@ -64,6 +64,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + GPTData secondDevice; + int opt, numOptions = 0, saveData = 0, neverSaveData = 0; + int partNum = 0, newPartNum = -1, saveNonGPT = 1, retval = 0, pretend = 0; ++ int byteSwapPartNum = 0; + uint64_t low, high, startSector, endSector, sSize, mainTableLBA; + uint64_t temp; // temporary variable; free to use in any case + char *device; +@@ -76,6 +77,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + "list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]]"}, + {"set-alignment", 'a', POPT_ARG_INT, &alignment, 'a', "set sector alignment", "value"}, + {"backup", 'b', POPT_ARG_STRING, &backupFile, 'b', "backup GPT to file", "file"}, ++ {"byte-swap-name", 'B', POPT_ARG_INT, &byteSwapPartNum, 'B', "byte-swap partition's name", "partnum"}, + {"change-name", 'c', POPT_ARG_STRING, &partName, 'c', "change partition's name", "partnum:name"}, + {"recompute-chs", 'C', POPT_ARG_NONE, NULL, 'C', "recompute CHS values in protective/hybrid MBR", ""}, + {"delete", 'd', POPT_ARG_INT, &deletePartNum, 'd', "delete a partition", "partnum"}, +@@ -191,6 +193,15 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + case 'a': + SetAlignment(alignment); + break; ++ case 'B': ++ if (IsUsedPartNum(byteSwapPartNum - 1)) { ++ partitions[byteSwapPartNum - 1].ReverseNameBytes(); ++ cout << "Changed partition " << byteSwapPartNum << "'s name to " ++ << partitions[byteSwapPartNum - 1].GetDescription() << "\n"; ++ JustLooking(0); ++ saveData = 1; ++ } ++ break; + case 'b': + SaveGPTBackup(backupFile); + free(backupFile); +diff --git a/gptpart.cc b/gptpart.cc +index 17d6f15..82aeab0 100644 +--- a/gptpart.cc ++++ b/gptpart.cc +@@ -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 ; +- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ; + pos ++ ; + } // if + else { +@@ -244,10 +242,8 @@ void GPTPart::SetName(const string & theName) { + } // if + uni -= 0x10000 ; + name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ; +- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ; + pos ++ ; + name[ pos ] = (uint16_t)( uni & 0x3ff ) | 0xdc00 ; +- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ; + pos ++ ; + } + } // for +@@ -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) { +- int i; +- + ReverseBytes(&firstLBA, 8); + ReverseBytes(&lastLBA, 8); + ReverseBytes(&attributes, 8); ++ ReverseNameBytes(); ++} // GPTPart::ReversePartBytes() ++ ++void GPTPart::ReverseNameBytes(void) { ++ int i; ++ + for (i = 0; i < NAME_SIZE; i ++ ) + ReverseBytes(name + i, 2); +-} // GPTPart::ReverseBytes() ++} // GPTPart::ReverseNameBytes() + + /**************************************** + * Functions requiring user interaction * +diff --git a/gptpart.h b/gptpart.h +index 657b3f9..ac8a725 100644 +--- a/gptpart.h ++++ b/gptpart.h +@@ -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 ++ void ReverseNameBytes(void); // reverse byte order of partition's name field + + // Functions requiring user interaction + void ChangeType(void); // Change the type code +diff --git a/gpttext.cc b/gpttext.cc +index 732d861..6de7121 100644 +--- a/gpttext.cc ++++ b/gpttext.cc +@@ -341,6 +341,22 @@ int GPTDataTextUI::SetName(uint32_t partNum) { + return retval; + } // GPTDataTextUI::SetName() + ++// Enable the user to byte-swap the name of the partition. Used to correct ++// partition names damaged by incorrect byte order, as could be created by ++// GPT fdisk 1.0.7 and earlier on big-endian systems, and perhaps other tools. ++void GPTDataTextUI::ReverseName(uint32_t partNum) { ++ int swapBytes; ++ ++ cout << "Current name is: " << partitions[partNum].GetDescription() << "\n"; ++ partitions[partNum].ReverseNameBytes(); ++ cout << "Byte-swapped name is: " << partitions[partNum].GetDescription() << "\n"; ++ cout << "Do you want to byte-swap the name? "; ++ swapBytes = (GetYN() == 'Y'); ++ // Already swapped for display, so undo if necessary.... ++ if (!swapBytes) ++ partitions[partNum].ReverseNameBytes(); ++} // GPTDataTextUI::ReverseName() ++ + // Ask user for two partition numbers and swap them in the table. Note that + // this just reorders table entries; it doesn't adjust partition layout on + // the disk. +@@ -799,6 +815,9 @@ void GPTDataTextUI::ExpertsMenu(string filename) { + else + cout << "No partitions\n"; + break; ++ case 'b': case 'B': ++ ReverseName(GetPartNum()); ++ break; + case 'c': case 'C': + ChangeUniqueGuid(); + break; +@@ -896,6 +915,7 @@ void GPTDataTextUI::ExpertsMenu(string filename) { + + void GPTDataTextUI::ShowExpertCommands(void) { + cout << "a\tset attributes\n"; ++ cout << "b\tbyte-swap a partition's name\n"; + cout << "c\tchange partition GUID\n"; + 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 98e59af..db27246 100644 +--- a/gpttext.h ++++ b/gpttext.h +@@ -49,6 +49,7 @@ class GPTDataTextUI : public GPTData { + void ChangeUniqueGuid(void); + void SetAttributes(uint32_t partNum); + int SetName(uint32_t partNum); ++ void ReverseName(uint32_t partNum); + int SwapPartitions(void); + int DestroyGPTwPrompt(void); // Returns 1 if user proceeds + void ShowDetails(void); +diff --git a/sgdisk.8 b/sgdisk.8 +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, + the backup may not accurately reflect the damaged state; instead, they + will reflect GPT fdisk's first\-pass interpretation of the GPT. + ++.TP ++.B \-B, \-\-byte\-swap\-name=partnum ++Swap the byte order for the name of the specified partition. Some ++partitioning tools, including GPT fdisk 1.0.7 and earlier, can write the ++partition name in the wrong byte order on big-endian computers, such as the ++IBM s390 mainframes and PowerPC-based Macs. This feature corrects this ++problem. ++ + .TP + .B \-c, \-\-change\-name=partnum:name + Change the GPT name of a partition. This name is encoded as a UTF\-16 +-- +2.35.1 + diff --git a/gdisk.spec b/gdisk.spec new file mode 100644 index 0000000..6dea99a --- /dev/null +++ b/gdisk.spec @@ -0,0 +1,204 @@ +Summary: An fdisk-like partitioning tool for GPT disks +Name: gdisk +Version: 1.0.3 +Release: 9%{?dist} +License: GPLv2 +URL: http://www.rodsbooks.com/gdisk/ +Group: System Environment/Base +Source0: http://downloads.sourceforge.net/gptfdisk/gptfdisk-%{version}.tar.gz +Patch0: gdisk-1.0.3-byteswap.patch +BuildRequires: popt-devel +BuildRequires: libuuid-devel +BuildRequires: ncurses-devel + +%description +An fdisk-like partitioning tool for GPT disks. GPT fdisk features a +command-line interface, fairly direct manipulation of partition table +structures, recovery tools to help you deal with corrupt partition +tables, and the ability to convert MBR disks to GPT format. + +%prep +%setup -q -n gptfdisk-%{version} +%patch0 -p1 +chmod 0644 gdisk_test.sh + +%build +make CXXFLAGS="%{optflags} -D_FILE_OFFSET_BITS=64" LDFLAGS="%{build_ldflags}" + +%install +for f in gdisk sgdisk cgdisk fixparts ; do + install -D -p -m 0755 $f %{buildroot}%{_sbindir}/$f + install -D -p -m 0644 $f.8 %{buildroot}%{_mandir}/man8/$f.8 +done + +%files +%license COPYING +%doc NEWS README gdisk_test.sh +%{_sbindir}/gdisk +%{_sbindir}/cgdisk +%{_sbindir}/sgdisk +%{_sbindir}/fixparts +%{_mandir}/man8/gdisk.8* +%{_mandir}/man8/cgdisk.8* +%{_mandir}/man8/sgdisk.8* +%{_mandir}/man8/fixparts.8* + +%changelog +* Tue Mar 15 2022 Nikola Forró - 1.0.3-9 +- Fix double byteswap on big-endian systems also while reading partition names + related: #1899990 + +* Mon Oct 25 2021 Nikola Forró - 1.0.3-8 +- Add upstream tests as a gating test + related: #1899990 + +* Wed Sep 29 2021 Nikola Forró - 1.0.3-7 +- Fix incorrect byte order of partition names on big-endian systems + resolves: #1899990 + +* Fri Feb 23 2018 Florian Weimer - 1.0.3-6 +- Use LDFLAGS from redhat-rpm-config + +* Wed Feb 07 2018 Fedora Release Engineering - 1.0.3-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Aug 02 2017 Fedora Release Engineering - 1.0.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Mon Jul 31 2017 Florian Weimer - 1.0.3-3 +- Rebuild with binutils fix for ppc64le (#1475636) + +* Fri Jul 28 2017 Terje Rosten - 1.0.3-2 +- Ship NEWS + +* Fri Jul 28 2017 Terje Rosten - 1.0.3-1 +- 1.0.3 + +* Wed Jul 26 2017 Fedora Release Engineering - 1.0.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.0.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Wed Feb 03 2016 Fedora Release Engineering - 1.0.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Thu Oct 29 2015 Terje Rosten - 1.0.1-1 +- 1.0.1 + +* Wed Jun 17 2015 Fedora Release Engineering - 1.0.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sat May 02 2015 Kalev Lember - 1.0.0-2 +- Rebuilt for GCC 5 C++11 ABI change + +* Sat Mar 21 2015 Terje Rosten - 1.0.0-1 +- 1.0.0 + +* Sat Aug 16 2014 Fedora Release Engineering - 0.8.10-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 0.8.10-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Mar 08 2014 Terje Rosten - 0.8.10-2 +- Drop icu from buildreq + +* Sat Mar 08 2014 Terje Rosten - 0.8.10-1 +- 0.8.10 + +* Sun Mar 02 2014 Terje Rosten - 0.8.9-1 +- 0.8.9 + +* Wed Feb 12 2014 Nils Philippsen - 0.8.8-2 +- fix bogus dates in changelog +- rebuild for new libicu + +* Thu Oct 17 2013 Terje Rosten - 0.8.8-1 +- 0.8.8 + +* Fri Sep 13 2013 Richard W.M. Jones - 0.8.7-2 +- Range check -i option (RHBZ#1007847). + +* Sun Aug 11 2013 Terje Rosten - 0.8.7-1 +- 0.8.7 + +* Sat Aug 03 2013 Fedora Release Engineering - 0.8.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Fri Jan 25 2013 Orion Poplawski - 0.8.6-1 +- Update to 0.8.6 + +* Sat Nov 17 2012 Terje Rosten - 0.8.5-1 +- 0.8.5 + +* Thu Jul 19 2012 Fedora Release Engineering - 0.8.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Apr 23 2012 Terje Rosten - 0.8.4-1 +- 0.8.4 + +* Sat Apr 21 2012 Orcan Ogetbil - 0.8.2-3 +- Rebuild for libicu 49.1.1 + +* Tue Feb 28 2012 Fedora Release Engineering - 0.8.2-2 +- Rebuilt for c++ ABI breakage + +* Sun Jan 29 2012 Terje Rosten - 0.8.2-1 +- 0.8.2 + +* Thu Jan 05 2012 Terje Rosten - 0.8.1-3 +- Add patch to build with gcc 4.7 + +* Mon Oct 17 2011 Terje Rosten - 0.8.1-2 +- Add cgdisk and fixparts + +* Mon Oct 17 2011 Terje Rosten - 0.8.1-1 +- 0.8.1 +- Add ncurses-devel to buildreq + +* Thu Sep 08 2011 Orion Poplawski - 0.7.2-2 +- Rebuild for libicu 4.8.1 + +* Sun Jul 10 2011 Terje Rosten - 0.7.2-1 +- 0.7.2 + +* Mon Apr 11 2011 Terje Rosten - 0.7.1-1 +- 0.7.1 + +* Tue Feb 08 2011 Fedora Release Engineering - 0.6.14-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Sat Jan 29 2011 Terje Rosten - 0.6.14-1 +- 0.6.14 + +* Thu Nov 11 2010 Terje Rosten - 0.6.13-1 +- 0.6.13 + +* Fri Jun 18 2010 Terje Rosten - 0.6.8-1 +- 0.6.8 + +* Thu Mar 25 2010 Terje Rosten - 0.6.6-1 +- 0.6.6 +- Compile with -D_FILE_OFFSET_BITS=64, recommended upstream + +* Sat Mar 20 2010 Terje Rosten - 0.6.5-1 +- 0.6.5 +- Add alignment patch (bz #575297) + +* Thu Mar 11 2010 Terje Rosten - 0.6.3-2 +- Fix source url + +* Sun Feb 14 2010 Terje Rosten - 0.6.3-1 +- 0.6.3 + +* Sun Jan 31 2010 Terje Rosten - 0.6.2-1 +- 0.6.2 + +* Mon Jan 25 2010 Terje Rosten - 0.6.1-1 +- 0.6.1 +- add popt-devel to buildreq +- random clean up + +* Fri Jan 15 2010 R Smith - 0.6.0 +- created spec file for 0.6.0 release diff --git a/sources b/sources new file mode 100644 index 0000000..a2e7c0e --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (gptfdisk-1.0.3.tar.gz) = 80d437bfa2365abfffbd4812ea928fcebd52c5421de321cf190d395549e32c5ebdbb2d060cc4b95f77fe13cdd719f4d2bb3d0ed5d97792b100325f92d7c852d7