Version 1.0.0 release! Added some type codes and the -O/--print-mbr

option for sgdisk.
This commit is contained in:
Roderick W. Smith
2015-03-17 19:46:05 -04:00
parent 50d3f8fcb2
commit 54f8fb17e6
14 changed files with 87 additions and 33 deletions

27
NEWS
View File

@@ -1,6 +1,29 @@
0.8.11 (?/?/2014):
1.0.0 (3/16/2015):
------------------
- I'm now building a binary package of gdisk_x64.efi, using the UEFI GPT
fdisk package.
- Added partition type for OpenBSD data
(824CC7A0-36A8-11E3-890A-952519AD3F61/0xa601). Also mapped 0xa600 to the
FreeBSD disklabel type code (516E7CB4-6ECF-11D6-8FF8-00022D09712B). I'm
not sure that's 100% correct, but since I can't find references to an
OpenBSD disklabel GPT type code, it seems the best choice at the moment.
- Added partition type for Windows Storage Spaces
(E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D/0x4202)
- Added -O/--print-mbr option to sgdisk, enabling easier display of MBR
data structures without invoking gdisk.
- Updated warning message: "EBR describes a logical partition" now reads
"EBR points to an EBR," which is more technically correct.
- Altered warning displayed when run from Windows on non-GPT disk, because
Windows on UEFI-based systems is becoming more common.
- Fixed spurious "1" return value in gdisk.
- Small code changes to support compilation as EFI application with the
UEFI GPT fdisk library
(http://sourceforge.net/projects/uefigptfdisk/?source=directory)
@@ -9,7 +32,7 @@
(https://github.com/ceph/ceph/blob/9bcc42a3e6b08521694b5c0228b2c6ed7b3d312e/src/ceph-disk#L76-L81):
4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D/0xf800 (Ceph OSD),
4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D/0xf801 (Ceph dm-crypt OSD),
BFBFAFE7-A34F-448A-9A5B-6213EB736C22/0xf802 (Ceph journal),
45B0969E-9B03-4F30-B4C6-B4B80CEFF106/0xf802 (Ceph journal),
45B0969E-9B03-4F30-B4C6-5EC00CEFF106/0xf803 (Ceph dm-crypt journal),
89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE/0xf804 (Ceph disk in creation), and
89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE/0xf805 (Ceph dm-crypt disk in

View File

@@ -296,7 +296,7 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
// the logical partition when this is the case....
ebrType = ebr.partitions[0].partitionType;
if ((ebrType == 0x05) || (ebrType == 0x0f) || (ebrType == 0x85)) {
cout << "EBR describes a logical partition!\n";
cout << "EBR points to an EBR!\n";
offset = extendedStart + ebr.partitions[0].firstLBA;
} else {
// Copy over the basic data....

View File

@@ -1,6 +1,6 @@
.\" Copyright 2011-2013 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License
.TH "CGDISK" "8" "0.8.10" "Roderick W. Smith" "GPT fdisk Manual"
.TH "CGDISK" "8" "1.0.0" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME"
cgdisk \- Curses-based GUID partition table (GPT) manipulator
.SH "SYNOPSIS"
@@ -276,10 +276,7 @@ Write data. Use this command to save your changes.
.SH "BUGS"
As of March 2014 (version 0.8.10), \fBcgdisk\fR should be considered
beta software. Although the underlying partition manipulation code is much
older, the \fBcgdisk\fR ncurses user interface is brand new with GPT fdisk
version 0.8.0. Known bugs and limitations include:
Known bugs and limitations include:
.TP
.B *
@@ -367,7 +364,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com)
* Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de)

View File

@@ -1,12 +1,12 @@
Summary: GPT partitioning and MBR repair software
Name: gptfdisk
Version: 0.8.10
Version: 1.0.0
Release: 1%{?dist}
License: GPLv2
URL: http://www.rodsbooks.com/gdisk
Group: Applications/System
Source: http://www.rodsbooks.com/gdisk/gptfdisk-0.8.10.tar.gz
Source: http://www.rodsbooks.com/gdisk/gptfdisk-1.0.0.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%description
@@ -81,5 +81,5 @@ provides a few additional partition manipulation features.
%changelog
* Sun Mar 2 2014 R Smith <rodsmith@rodsbooks.com> - 0.8.10
- Created spec file for 0.8.10 release
* Sun Mar 2 2014 R Smith <rodsmith@rodsbooks.com> - 1.0.0
- Created spec file for 1.0.0 release

View File

@@ -253,7 +253,8 @@ int DiskIO::DiskSync(void) {
i = ioctl(fd, BLKRRPART);
if (i) {
cout << "Warning: The kernel is still using the old partition table.\n"
<< "The new table will be used at the next reboot.\n";
<< "The new table will be used at the next reboot or after you\n"
<< "run partprobe(8) or kpartx(8)\n";
} else {
retval = 1;
} // if/else

View File

@@ -1,6 +1,6 @@
.\" Copyright 2011-2013 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License
.TH "FIXPARTS" "8" "0.8.10" "Roderick W. Smith" "FixParts Manual"
.TH "FIXPARTS" "8" "1.0.0" "Roderick W. Smith" "FixParts Manual"
.SH "NAME"
fixparts \- MBR partition table repair utility
.SH "SYNOPSIS"
@@ -202,8 +202,7 @@ see a summary of available options.
.PP
.SH "BUGS"
As of March 2014 (version 0.8.10), \fBfixparts\fR
should be considered beta software. Known bugs and limitations include:
Known bugs and limitations include:
.TP
.B *
@@ -259,7 +258,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com)
* Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de)

View File

@@ -1,6 +1,6 @@
.\" Copyright 2011-2013 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License
.TH "GDISK" "8" "0.8.10" "Roderick W. Smith" "GPT fdisk Manual"
.TH "GDISK" "8" "1.0.0" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME"
gdisk \- Interactive GUID partition table (GPT) manipulator
.SH "SYNOPSIS"
@@ -561,8 +561,7 @@ entering data. When only one option is possible, \fBgdisk\fR
usually bypasses the prompt entirely.
.SH "BUGS"
As of March 2014 (version 0.8.10), \fBgdisk\fR
should be considered beta software. Known bugs and limitations include:
Known bugs and limitations include:
.TP
.B *
@@ -660,7 +659,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com)
* Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de)

View File

@@ -93,6 +93,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
{"new", 'n', POPT_ARG_STRING, &newPartInfo, 'n', "create new partition", "partnum:start:end"},
{"largest-new", 'N', POPT_ARG_INT, &largestPartNum, 'N', "create largest possible new partition", "partnum"},
{"clear", 'o', POPT_ARG_NONE, NULL, 'o', "clear partition table", ""},
{"print-mbr", 'O', POPT_ARG_NONE, NULL, 'O', "print MBR partition table", ""},
{"print", 'p', POPT_ARG_NONE, NULL, 'p', "print partition table", ""},
{"pretend", 'P', POPT_ARG_NONE, NULL, 'P', "make changes in memory, but don't write them", ""},
{"transpose", 'r', POPT_ARG_STRING, &twoParts, 'r', "transpose two partitions", "partnum:partnum"},
@@ -320,6 +321,9 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
ClearGPTData();
saveData = 1;
break;
case 'O':
DisplayMBRData();
break;
case 'p':
DisplayGPTData();
break;

3
mbr.cc
View File

@@ -28,6 +28,9 @@ using namespace std;
* *
****************************************/
MBRData::~MBRData(void) {
} // MBRData destructor
/* // Assignment operator -- copy entire set of MBR data.
MBRData & MBRData::operator=(const MBRData & orig) {
BasicMBRData::operator=(orig);

1
mbr.h
View File

@@ -28,6 +28,7 @@ public:
MBRData(void) {}
MBRData(string deviceFilename) : BasicMBRData(deviceFilename) {}
MBRData & operator=(const BasicMBRData & orig);
~MBRData(void);
// Functions to create, delete, or change partitions
// Pass EmptyMBR 1 to clear the boot loader code, 0 to leave it intact

View File

@@ -103,6 +103,7 @@ void PartType::AddAllTypes(void) {
// Windows LDM ("dynamic disk") types
AddType(0x4200, "AF9B60A0-1431-4F62-BC68-3311714A69AD", "Windows LDM data"); // Logical disk manager
AddType(0x4201, "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3", "Windows LDM metadata"); // Logical disk manager
AddType(0x4202, "E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D", "Windows Storage Spaces"); // A newer LDM-type setup
// An oddball IBM filesystem....
AddType(0x7501, "37AFFC90-EF7D-4E96-91C3-2D7AE055B174", "IBM GPFS"); // General Parallel File System (GPFS)
@@ -153,6 +154,13 @@ void PartType::AddAllTypes(void) {
AddType(0xa584, "85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7", "Midnight BSD ZFS");
AddType(0xa585, "85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7", "Midnight BSD Vinum");
// OpenBSD partition type....
// Note: MBR type 0xa6 is normally subdivided with a BSD disklabel. It's unclear
// if that has a GPT equivalent, so I've mapped it to the same GUID as the
// FreeBSD diskalbel.
AddType(0xa600, "516E7CB4-6ECF-11D6-8FF8-00022D09712B", "OpenBSD disklabel", 0);
AddType(0xa601, "824CC7A0-36A8-11E3-890A-952519AD3F61", "OpenBSD data");
// A MacOS partition type, separated from others by NetBSD partition types...
AddType(0xa800, "55465300-0000-11AA-AA11-00306543ECAC", "Apple UFS"); // Mac OS X
@@ -213,7 +221,7 @@ void PartType::AddAllTypes(void) {
// Ceph type codes; see https://github.com/ceph/ceph/blob/9bcc42a3e6b08521694b5c0228b2c6ed7b3d312e/src/ceph-disk#L76-L81
AddType(0xf800, "4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D", "Ceph OSD"); // Ceph Object Storage Daemon
AddType(0xf801, "4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D", "Ceph dm-crypt OSD"); // Ceph Object Storage Daemon (encrypted)
AddType(0xf802, "BFBFAFE7-A34F-448A-9A5B-6213EB736C22", "Ceph journal");
AddType(0xf802, "45B0969E-9B03-4F30-B4C6-B4B80CEFF106", "Ceph journal");
AddType(0xf803, "45B0969E-9B03-4F30-B4C6-5EC00CEFF106", "Ceph dm-crypt journal");
AddType(0xf804, "89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE", "Ceph disk in creation");
AddType(0xf805, "89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE", "Ceph dm-crypt disk in creation");

View File

@@ -1,6 +1,6 @@
.\" Copyright 2011-2013 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License
.TH "SGDISK" "8" "0.8.10" "Roderick W. Smith" "GPT fdisk Manual"
.TH "SGDISK" "8" "1.0.0" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME"
sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix
.SH "SYNOPSIS"
@@ -352,12 +352,20 @@ and then partition it normally. This option will work even if the
disk's original partition table is bad; however, most other options on the
same command line will be ignored.
.TP
.B \-O, \-\-print\-mbr
Display basic \fIMBR\fR partition summary data. This includes partition
numbers, starting and ending sector numbers, partition sizes, MBR partition
types codes, and partition names. This option is useful mainly for
diagnosing partition table problems, particularly on disks with hybrid
MBRs.
.TP
.B \-p, \-\-print
Display basic partition summary data. This includes partition
numbers, starting and ending sector numbers, partition sizes,
\fBsgdisk\fR's partition types codes, and partition names. For
additional information, use the \fI\-i\fR (\fI\-\-info\fR) option.
Display basic GPT partition summary data. This includes partition numbers,
starting and ending sector numbers, partition sizes, \fBsgdisk\fR's
partition types codes, and partition names. For additional information, use
the \fI\-i\fR (\fI\-\-info\fR) option.
.TP
.B \-P, \-\-pretend
@@ -491,8 +499,7 @@ sgdisk, but may with gdisk)
Disk replication operation (-R) failed
.SH "BUGS"
As of March 2014 (version 0.8.10), \fBsgdisk\fR
should be considered beta software. Known bugs and limitations include:
Known bugs and limitations include:
.TP
.B *
@@ -578,7 +585,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com)
* Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de)

View File

@@ -34,6 +34,17 @@ using namespace std;
// Reads a string from stdin, returning it as a C++-style string.
// Note that the returned string will NOT include the carriage return
// entered by the user.
#ifdef EFI
extern int __sscanf( const char * str , const char * format , ... ) ;
string ReadString(void) {
string inString;
char efiString[256];
fgets(efiString, 255, stdin);
inString = efiString;
return inString;
} // ReadString()
#else
string ReadString(void) {
string inString;
@@ -42,6 +53,7 @@ string ReadString(void) {
exit(5);
return inString;
} // ReadString()
#endif
// Get a numeric value from the user, between low and high (inclusive).
// Keeps looping until the user enters a value within that range.
@@ -225,7 +237,7 @@ string BytesToIeee(uint64_t size, uint32_t sectorSize) {
uint64_t sizeInIeee;
uint64_t previousIeee;
float decimalIeee;
uint index = 0;
uint64_t index = 0;
string units, prefixes = " KMGTPEZ";
ostringstream theValue;

View File

@@ -8,7 +8,7 @@
#ifndef __GPTSUPPORT
#define __GPTSUPPORT
#define GPTFDISK_VERSION "0.8.10.2"
#define GPTFDISK_VERSION "1.0.0"
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
// Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64