Update external/gptfdisk to 1.0.1

Updates gpftdisk to the latest version 0.8.10 (ish) -> 1.0.1

The downstream patches should be uneffected.

Change-Id: I527678c0b24194f3947e360f0f38c45cfa3b0d1c
This commit is contained in:
Aurimas Liutikas
2016-05-10 18:53:54 -07:00
parent 6bbf89bfc6
commit 74b7490a22
20 changed files with 264 additions and 91 deletions

View File

@@ -28,6 +28,9 @@ sgdisk: $(LIB_OBJS) sgdisk.o gptcl.o
fixparts: $(MBR_LIB_OBJS) fixparts.o fixparts: $(MBR_LIB_OBJS) fixparts.o
$(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts $(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts
test:
./gdisk_test.sh
lint: #no pre-reqs lint: #no pre-reqs
lint $(SRCS) lint $(SRCS)

View File

@@ -1,8 +1,9 @@
CC=gcc CC=gcc
CXX=g++ CXX=clang++
CFLAGS=-O2 -D_FILE_OFFSET_BITS=64 -g FATBINFLAGS=-arch x86_64 -arch i386 -mmacosx-version-min=10.4
#CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 -I/sw/include -I/usr/local/include -I/opt/local/include -g CFLAGS=$(FATBINFLAGS) -O2 -D_FILE_OFFSET_BITS=64 -g
CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -I/sw/include -I /usr/local/include -I/opt/local/include -g #CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 -I/opt/local/include -I/usr/local/include -I/opt/local/include -g
CXXFLAGS=$(FATBINFLAGS) -O2 -Wall -D_FILE_OFFSET_BITS=64 -I/opt/local/include -I /usr/local/include -I/opt/local/include -g
LIB_NAMES=crc32 support guid gptpart mbrpart basicmbr mbr gpt bsd parttypes attributes diskio diskio-unix LIB_NAMES=crc32 support guid gptpart mbrpart basicmbr mbr gpt bsd parttypes attributes diskio diskio-unix
MBR_LIBS=support diskio diskio-unix basicmbr mbrpart MBR_LIBS=support diskio diskio-unix basicmbr mbrpart
#LIB_SRCS=$(NAMES:=.cc) #LIB_SRCS=$(NAMES:=.cc)
@@ -14,19 +15,20 @@ DEPEND= makedepend $(CFLAGS)
all: gdisk sgdisk cgdisk fixparts all: gdisk sgdisk cgdisk fixparts
gdisk: $(LIB_OBJS) gpttext.o gdisk.o gdisk: $(LIB_OBJS) gpttext.o gdisk.o
$(CXX) $(LIB_OBJS) gpttext.o gdisk.o -o gdisk $(CXX) $(LIB_OBJS) gpttext.o gdisk.o $(FATBINFLAGS) -o gdisk
# $(CXX) $(LIB_OBJS) -L/usr/lib -licucore gpttext.o gdisk.o -o gdisk # $(CXX) $(LIB_OBJS) -L/usr/lib -licucore gpttext.o gdisk.o -o gdisk
cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o
$(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -lncurses -o cgdisk $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o /opt/local/lib/libncurses.a $(LDFLAGS) $(FATBINFLAGS) -o cgdisk
# $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licucore -lncurses -o cgdisk # $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licucore -lncurses -o cgdisk
sgdisk: $(LIB_OBJS) gptcl.o sgdisk.o sgdisk: $(LIB_OBJS) gptcl.o sgdisk.o
$(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -lpopt -o sgdisk # $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o /opt/local/lib/libiconv.a /opt/local/lib/libintl.a /opt/local/lib/libpopt.a $(FATBINFLAGS) -o sgdisk
$(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/opt/local/lib -lpopt $(FATBINFLAGS) -o sgdisk
# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk # $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk
fixparts: $(MBR_LIB_OBJS) fixparts.o fixparts: $(MBR_LIB_OBJS) fixparts.o
$(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts $(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) $(FATBINFLAGS) -o fixparts
testguid: $(LIB_OBJS) testguid.o testguid: $(LIB_OBJS) testguid.o
$(CXX) $(LIB_OBJS) testguid.o -o testguid $(CXX) $(LIB_OBJS) testguid.o -o testguid
@@ -35,7 +37,7 @@ lint: #no pre-reqs
lint $(SRCS) lint $(SRCS)
clean: #no pre-reqs clean: #no pre-reqs
rm -f core *.o *~ gdisk sgdisk rm -f core *.o *~ gdisk sgdisk cgdisk fixparts
# what are the source dependencies # what are the source dependencies
depend: $(SRCS) depend: $(SRCS)

105
NEWS
View File

@@ -1,6 +1,107 @@
0.8.11 (?/?/2014): 1.0.1 (10/18/2015):
-------------------
- Fixed bug that caused -N/--largest-new option to sgdisk to fail when
fed a "0" option.
- Fixed bug that caused input glitches in EFI version of gdisk.
- Fixed bug that caused sgdisk to not return an appropriate error code
when it encountered a write error when saving changes.
- Fixed bug that caused cgdisk's "Info" display to under-report the
partition's size by one sector.
- OS X 10.11 includes new security features that prevent GPT fdisk from
working unless these features are disabled. To do so, you must boot to a
Recovery HD system, open a Terminal, type "csrutil disable", and reboot
into the normal system. You can re-enable the security features by
repeating the process, but specify "enable" rather than "disable". I've
added a message pointing users to a Web page explaining how to disable
this feature when gdisk detects that it can't write to the disk under OS
X. If you know of a way around this (including code changes to gdisk),
please contact me.
- I've updated the OS X installation location from the Unix-standard
/usr/sbin (and related locations for documentation) to /usr/local/bin
(and related locations for documentation). This is Just Plain Crazy from
a Unix point of view, but Apple has to be Apple and do things just a
little bit differently.
- I've updated my OS X environment to OS X 10.11 and LLVM 7.0.0. This has
also meant installing fresh versions of popt and ncurses from MacPorts,
which may require upgrading popt to get sgdisk working on some systems.
(gdisk, cgdisk, and fixparts should continue to work normally on all
systems.) The OS X binaries are now "fat" (32- and 64-bit) versions,
which should have no noticeable effect unless you have a Mac with broken
32-bit support, in which case the binaries will now work.
- Changed the default name of 0xab00 partitions from "Apple boot" to
"Recovery HD", since the latter is the name that Apple gives these
partitions. Also, I discovered through painful experience that OS X
flakes out and won't boot if the name is something other than "Recovery
HD", so it really has to have the right name!
- Changed the OpenBSD type codes (0xa600 and 0xa601): 0xa600 is now
824CC7A0-36A8-11E3-890A-952519AD3F61 (OpenBSD disklabel) and 0xa601 is
now gone. Previously, 0xa600 was 516E7CB4-6ECF-11D6-8FF8-00022D09712B, a
duplicate of the FreeBSD disklabel, and 0xa601 was
824CC7A0-36A8-11E3-890A-952519AD3F61. OpenBSD is now officially
supporting 824CC7A0-36A8-11E3-890A-952519AD3F61 as a disklabel type,
though. It's unclear what, if anything, OpenBSD will use for
non-disklabel type codes at the moment.
- Added GUID 0311FC50-01CA-4725-AD77-9ADBB20ACE98 (0xbc00) for
Acronis Secure Zone backup partitions.
- Fixed bug that caused random crashes on ppc64el systems (and perhaps
others).
- Added GUID C91818F9-8025-47AF-89D2-F030D7000C2C (0x3900) for Plan 9.
- Added GUID 69DAD710-2CE4-4E3C-B16C-21A1D49ABED3 (0x8307) for 32-bit ARM
Linux root (/) partition, as per the Freedesktop.org Discoverable
Partition Spec
(http://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/).
- Edited man pages to clarify that default alignment is to 1MiB boundaries;
this translates to 2048 sectors on disks with 512-byte sectors, but it
will be something else on disks with other sector sizes.
- Changed behavior of -z/--zap and -Z/--zap-all options to sgdisk so that
if a subsequent command causes changes, they'll be written to disk.
Previously, doing something like "sgdisk --zap-all --clear /dev/sdd"
would wipe the disk but not create a partition table; to create a blank
table you'd need to do "sgdisk --zap-all --clear --mbrtogpt /dev/sdd",
which is a bit odd and counter-intuitive, to the point of arguably being
a bug.
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 - Small code changes to support compilation as EFI application with the
UEFI GPT fdisk library UEFI GPT fdisk library
(http://sourceforge.net/projects/uefigptfdisk/?source=directory) (http://sourceforge.net/projects/uefigptfdisk/?source=directory)
@@ -9,7 +110,7 @@
(https://github.com/ceph/ceph/blob/9bcc42a3e6b08521694b5c0228b2c6ed7b3d312e/src/ceph-disk#L76-L81): (https://github.com/ceph/ceph/blob/9bcc42a3e6b08521694b5c0228b2c6ed7b3d312e/src/ceph-disk#L76-L81):
4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D/0xf800 (Ceph OSD), 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D/0xf800 (Ceph OSD),
4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D/0xf801 (Ceph dm-crypt 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), 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-F3AD0CEFF2BE/0xf804 (Ceph disk in creation), and
89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE/0xf805 (Ceph dm-crypt disk in 89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE/0xf805 (Ceph dm-crypt disk in

11
README
View File

@@ -200,11 +200,12 @@ be used instead. In addition, note these requirements:
(headers). Most Linux distributions install popt by default, but you may (headers). Most Linux distributions install popt by default, but you may
need to install a package called popt-dev, popt-devel, or something need to install a package called popt-dev, popt-devel, or something
similar to obtain the header files. Mac OS users can find a version of similar to obtain the header files. Mac OS users can find a version of
popt for Mac OS from Darwin Ports (http://popt.darwinports.com) or Fink popt for Mac OS from Darwin Ports (http://popt.darwinports.com), MacPorts
(http://www.finkproject.org); however, you'll first need to install (https://trac.macports.org/browser/trunk/dports/devel/popt/Portfile), or
DarwinPorts or Fink (instructions exist on the relevant projects' pages). Fink (http://www.finkproject.org); however, you'll first need to install
Alternatively, you can compile gdisk and/or cgdisk alone, without sgdisk; DarwinPorts, MacPorts, or Fink (instructions exist on the relevant
gdisk doesn't require popt. projects' pages). Alternatively, you can compile gdisk and/or cgdisk
alone, without sgdisk; gdisk doesn't require popt.
When all the necessary development tools and libraries are installed, you When all the necessary development tools and libraries are installed, you
can uncompress the package and type "make" at the command prompt in the can uncompress the package and type "make" at the command prompt in the

View File

@@ -296,7 +296,7 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
// the logical partition when this is the case.... // the logical partition when this is the case....
ebrType = ebr.partitions[0].partitionType; ebrType = ebr.partitions[0].partitionType;
if ((ebrType == 0x05) || (ebrType == 0x0f) || (ebrType == 0x85)) { 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; offset = extendedStart + ebr.partitions[0].firstLBA;
} else { } else {
// Copy over the basic data.... // Copy over the basic data....

View File

@@ -1,6 +1,6 @@
.\" Copyright 2011-2013 Roderick W. Smith (rodsmith@rodsbooks.com) .\" Copyright 2011-2015 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License .\" 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.1" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME" .SH "NAME"
cgdisk \- Curses-based GUID partition table (GPT) manipulator cgdisk \- Curses-based GUID partition table (GPT) manipulator
.SH "SYNOPSIS" .SH "SYNOPSIS"
@@ -181,12 +181,13 @@ Change the sector alignment value. Disks with more logical sectors than
physical sectors (such as modern Advanced Format drives), some RAID physical sectors (such as modern Advanced Format drives), some RAID
configurations, and many SSD devices, can suffer performance problems if configurations, and many SSD devices, can suffer performance problems if
partitions are not aligned properly for their internal data structures. On partitions are not aligned properly for their internal data structures. On
new disks, GPT fdisk attempts to align partitions on 2048\-sector (1MiB) new disks, GPT fdisk attempts to align partitions on 1MiB boundaries
boundaries by default, which optimizes performance for all of these disk (2048\-sectors on disks with 512-byte sectors) by default, which optimizes
types. On pre\-partitioned disks, GPT fdisk attempts to identify the performance for all of these disk types. On pre\-partitioned disks, GPT
alignment value used on that disk, but will set 8-sector alignment on disks fdisk attempts to identify the alignment value used on that disk, but will
larger than 300 GB even if lesser alignment values are detected. In either set 8-sector alignment on disks larger than 300 GB even if lesser alignment
case, it can be changed by using this option. values are detected. In either case, it can be changed by using this
option.
.TP .TP
.B Backup .B Backup
@@ -276,10 +277,7 @@ Write data. Use this command to save your changes.
.SH "BUGS" .SH "BUGS"
As of March 2014 (version 0.8.10), \fBcgdisk\fR should be considered Known bugs and limitations include:
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:
.TP .TP
.B * .B *
@@ -367,7 +365,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com) * Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com) * Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de) * Florian Zumbiehl (florz@florz.de)

View File

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

View File

@@ -74,7 +74,8 @@ int DiskIO::OpenForRead(void) {
if (fstat64(fd, &st) == 0) { if (fstat64(fd, &st) == 0) {
if (S_ISDIR(st.st_mode)) if (S_ISDIR(st.st_mode))
cerr << "The specified path is a directory!\n"; cerr << "The specified path is a directory!\n";
#if !defined(__FreeBSD__) && !defined(__APPLE__) #if !(defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) \
&& !defined(__APPLE__)
else if (S_ISCHR(st.st_mode)) else if (S_ISCHR(st.st_mode))
cerr << "The specified path is a character device!\n"; cerr << "The specified path is a character device!\n";
#endif #endif
@@ -253,7 +254,8 @@ int DiskIO::DiskSync(void) {
i = ioctl(fd, BLKRRPART); i = ioctl(fd, BLKRRPART);
if (i) { if (i) {
cout << "Warning: The kernel is still using the old partition table.\n" 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 { } else {
retval = 1; retval = 1;
} // if/else } // if/else
@@ -271,7 +273,7 @@ int DiskIO::DiskSync(void) {
// Note that seeking beyond the end of the file is NOT detected as a failure! // Note that seeking beyond the end of the file is NOT detected as a failure!
int DiskIO::Seek(uint64_t sector) { int DiskIO::Seek(uint64_t sector) {
int retval = 1; int retval = 1;
off64_t seekTo, sought; off_t seekTo, sought;
// If disk isn't open, try to open it.... // If disk isn't open, try to open it....
if (!isOpen) { if (!isOpen) {

View File

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

25
gdisk.8
View File

@@ -1,6 +1,6 @@
.\" Copyright 2011-2013 Roderick W. Smith (rodsmith@rodsbooks.com) .\" Copyright 2011-2015 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License .\" 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.1" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME" .SH "NAME"
gdisk \- Interactive GUID partition table (GPT) manipulator gdisk \- Interactive GUID partition table (GPT) manipulator
.SH "SYNOPSIS" .SH "SYNOPSIS"
@@ -212,7 +212,8 @@ sector.
.B o .B o
Clear out all partition data. This includes GPT header data, Clear out all partition data. This includes GPT header data,
all partition definitions, and the protective MBR. The sector alignment all partition definitions, and the protective MBR. The sector alignment
is reset to the default (2048 sectors, or 1MB). is reset to the default (1MB, or 2048 sectors on a disk with 512-byte
sectors).
.TP .TP
.B p .B p
@@ -470,12 +471,13 @@ Change the sector alignment value. Disks with more logical sectors per
physical sectors (such as modern Advanced Format drives), some RAID physical sectors (such as modern Advanced Format drives), some RAID
configurations, and many SSD devices, can suffer performance problems if configurations, and many SSD devices, can suffer performance problems if
partitions are not aligned properly for their internal data structures. On partitions are not aligned properly for their internal data structures. On
new disks, GPT fdisk attempts to align partitions on 2048\-sector (1MiB) new disks, GPT fdisk attempts to align partitions on 1MiB boundaries
boundaries by default, which optimizes performance for all of these disk (2048\-sectors on disks with 512-byte sectors) by default, which optimizes
types. On pre\-partitioned disks, GPT fdisk attempts to identify the performance for all of these disk types. On pre\-partitioned disks, GPT
alignment value used on that disk, but will set 8-sector alignment on disks fdisk attempts to identify the alignment value used on that disk, but will
larger than 300 GB even if lesser alignment values are detected. In either set 8-sector alignment on disks larger than 300 GB even if lesser alignment
case, it can be changed by using this option. values are detected. In either case, it can be changed by using this
option.
.TP .TP
.B m .B m
@@ -561,8 +563,7 @@ entering data. When only one option is possible, \fBgdisk\fR
usually bypasses the prompt entirely. usually bypasses the prompt entirely.
.SH "BUGS" .SH "BUGS"
As of March 2014 (version 0.8.10), \fBgdisk\fR Known bugs and limitations include:
should be considered beta software. Known bugs and limitations include:
.TP .TP
.B * .B *
@@ -660,7 +661,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com) * Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com) * Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de) * Florian Zumbiehl (florz@florz.de)

View File

@@ -115,9 +115,23 @@ Y
w w
Y Y
EOF EOF
ret=$?
if [ $ret -ne 0 ]
then
pretty_print "FAILED" "gdisk return $ret when creating partition table"
exit 1
fi
;; ;;
sgdisk) sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_CLEAR} $SGDISK_BIN $TEMP_DISK -${OPT_CLEAR}
ret=$?
if [ $ret -ne 0 ]
then
pretty_print "FAILED" "sgdisk return $ret when creating partition table"
exit 1
fi
;; ;;
esac esac
@@ -147,7 +161,7 @@ EOF
;; ;;
sgdisk) sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_NEW} 1 -${OPT_CHANGE_NAME} 1:"${TEST_PART_DEFAULT_NAME}" $SGDISK_BIN $TEMP_DISK -${OPT_NEW} 1 -${OPT_CHANGE_NAME} 1:"${TEST_PART_DEFAULT_NAME}" -${OPT_CHANGE_TYPE} 1:$TEST_PART_TYPE
;; ;;
esac esac
@@ -311,6 +325,7 @@ EOF
pretty_print "SUCCESS" "GUID of disk has been sucessfully changed" pretty_print "SUCCESS" "GUID of disk has been sucessfully changed"
else else
pretty_print "FAILED" "GUID of disk is the same as the previous one" pretty_print "FAILED" "GUID of disk is the same as the previous one"
exit 1
fi fi
} }
@@ -353,7 +368,7 @@ EOF
################################### ###################################
# create a file to simulate a real device # create a file to simulate a real device
dd if=/dev/zero of=$TEMP_DISK bs=1024 count=$TEMP_DISK_SIZE dd if=/dev/zero of=$TEMP_DISK bs=1024 count=$TEMP_DISK_SIZE > /dev/null 2>&1
if [ -s $TEMP_DISK ] if [ -s $TEMP_DISK ]
then then

7
gpt.cc
View File

@@ -748,7 +748,12 @@ int GPTData::LoadPartitions(const string & deviceFilename) {
<< "'sysctl kern.geom.debugflags=16' at a shell prompt, and re-running this\n" << "'sysctl kern.geom.debugflags=16' at a shell prompt, and re-running this\n"
<< "program.\n"; << "program.\n";
#endif #endif
cout << "\n"; #if defined (__APPLE__)
cout << "You may need to deactivate System Integrity Protection to use this program. See\n"
<< "https://www.quora.com/How-do-I-turn-off-the-rootless-in-OS-X-El-Capitan-10-11\n"
<< "for more information.\n";
#endif
cout << "\n";
} // if } // if
myDisk.Close(); // Close and re-open read-only in case of bugs myDisk.Close(); // Close and re-open read-only in case of bugs
} else allOK = 0; // if } else allOK = 0; // if

View File

@@ -23,6 +23,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <errno.h> #include <errno.h>
#include <popt.h>
#include "gptcl.h" #include "gptcl.h"
GPTDataCL::GPTDataCL(void) { GPTDataCL::GPTDataCL(void) {
@@ -71,7 +72,8 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
struct poptOption theOptions[] = struct poptOption theOptions[] =
{ {
{"attributes", 'A', POPT_ARG_STRING, &attributeOperation, 'A', "operate on partition attributes", "list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]]"}, {"attributes", 'A', POPT_ARG_STRING, &attributeOperation, 'A', "operate on partition attributes",
"list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]]"},
{"set-alignment", 'a', POPT_ARG_INT, &alignment, 'a', "set sector alignment", "value"}, {"set-alignment", 'a', POPT_ARG_INT, &alignment, 'a', "set sector alignment", "value"},
{"backup", 'b', POPT_ARG_STRING, &backupFile, 'b', "backup GPT to file", "file"}, {"backup", 'b', POPT_ARG_STRING, &backupFile, 'b', "backup GPT to file", "file"},
{"change-name", 'c', POPT_ARG_STRING, &partName, 'c', "change partition's name", "partnum:name"}, {"change-name", 'c', POPT_ARG_STRING, &partName, 'c', "change partition's name", "partnum:name"},
@@ -92,6 +94,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
{"new", 'n', POPT_ARG_STRING, &newPartInfo, 'n', "create new partition", "partnum:start:end"}, {"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"}, {"largest-new", 'N', POPT_ARG_INT, &largestPartNum, 'N', "create largest possible new partition", "partnum"},
{"clear", 'o', POPT_ARG_NONE, NULL, 'o', "clear partition table", ""}, {"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", ""}, {"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", ""}, {"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"}, {"transpose", 'r', POPT_ARG_STRING, &twoParts, 'r', "transpose two partitions", "partnum:partnum"},
@@ -304,8 +307,8 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
startSector = FindFirstInLargest(); startSector = FindFirstInLargest();
Align(&startSector); Align(&startSector);
endSector = FindLastInFree(startSector); endSector = FindLastInFree(startSector);
if (largestPartNum < 0) if (largestPartNum <= 0)
largestPartNum = FindFirstFreePart(); largestPartNum = FindFirstFreePart() + 1;
if (CreatePartition(largestPartNum - 1, startSector, endSector)) { if (CreatePartition(largestPartNum - 1, startSector, endSector)) {
saveData = 1; saveData = 1;
} else { } else {
@@ -319,6 +322,9 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
ClearGPTData(); ClearGPTData();
saveData = 1; saveData = 1;
break; break;
case 'O':
DisplayMBRData();
break;
case 'p': case 'p':
DisplayGPTData(); DisplayGPTData();
break; break;
@@ -399,7 +405,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
if (!pretend) { if (!pretend) {
DestroyGPT(); DestroyGPT();
} // if } // if
saveNonGPT = 0; saveNonGPT = 1;
saveData = 0; saveData = 0;
break; break;
case 'Z': case 'Z':
@@ -407,7 +413,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
DestroyGPT(); DestroyGPT();
DestroyMBR(); DestroyMBR();
} // if } // if
saveNonGPT = 0; saveNonGPT = 1;
saveData = 0; saveData = 0;
break; break;
default: default:
@@ -441,7 +447,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
if (!pretend) { if (!pretend) {
DestroyGPT(); DestroyGPT();
} // if } // if
saveNonGPT = 0; saveNonGPT = 1;
saveData = 0; saveData = 0;
break; break;
case 'Z': case 'Z':
@@ -449,7 +455,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
DestroyGPT(); DestroyGPT();
DestroyMBR(); DestroyMBR();
} // if } // if
saveNonGPT = 0; saveNonGPT = 1;
saveData = 0; saveData = 0;
break; break;
} // switch } // switch
@@ -457,7 +463,8 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
retval = 2; retval = 2;
} // if/else loaded OK } // if/else loaded OK
if ((saveData) && (!neverSaveData) && (saveNonGPT) && (!pretend)) { if ((saveData) && (!neverSaveData) && (saveNonGPT) && (!pretend)) {
SaveGPTData(1); if (!SaveGPTData(1))
retval = 4;
} }
if (saveData && (!saveNonGPT)) { if (saveData && (!saveNonGPT)) {
cout << "Non-GPT disk; not saving changes. Use -g to override.\n"; cout << "Non-GPT disk; not saving changes. Use -g to override.\n";

View File

@@ -332,7 +332,7 @@ void GPTDataCurses::ShowInfo(int partNum) {
BytesToIeee(partitions[partNum].GetFirstLBA(), blockSize).c_str()); BytesToIeee(partitions[partNum].GetFirstLBA(), blockSize).c_str());
printw("Last sector: %lld (at %s)\n", partitions[partNum].GetLastLBA(), printw("Last sector: %lld (at %s)\n", partitions[partNum].GetLastLBA(),
BytesToIeee(partitions[partNum].GetLastLBA(), blockSize).c_str()); BytesToIeee(partitions[partNum].GetLastLBA(), blockSize).c_str());
size = partitions[partNum].GetLastLBA() - partitions[partNum].GetFirstLBA(); size = partitions[partNum].GetLastLBA() - partitions[partNum].GetFirstLBA() + 1;
printw("Partition size: %lld sectors (%s)\n", size, BytesToIeee(size, blockSize).c_str()); printw("Partition size: %lld sectors (%s)\n", size, BytesToIeee(size, blockSize).c_str());
printw("Attribute flags: %016x\n", partitions[partNum].GetAttributes().GetAttributes()); printw("Attribute flags: %016x\n", partitions[partNum].GetAttributes().GetAttributes());
#ifdef USE_UTF16 #ifdef USE_UTF16

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. /* // Assignment operator -- copy entire set of MBR data.
MBRData & MBRData::operator=(const MBRData & orig) { MBRData & MBRData::operator=(const MBRData & orig) {
BasicMBRData::operator=(orig); BasicMBRData::operator=(orig);

1
mbr.h
View File

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

View File

@@ -2,7 +2,7 @@
// Class to manage partition type codes -- a slight variant on MBR type // Class to manage partition type codes -- a slight variant on MBR type
// codes, GUID type codes, and associated names. // codes, GUID type codes, and associated names.
/* This program is copyright (c) 2009-2014 by Roderick W. Smith. It is distributed /* This program is copyright (c) 2009-2015 by Roderick W. Smith. It is distributed
under the terms of the GNU GPL version 2, as detailed in the COPYING file. */ under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
#define __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS
@@ -97,12 +97,16 @@ void PartType::AddAllTypes(void) {
AddType(0x3000, "7412F7D5-A156-4B13-81DC-867174929325", "ONIE boot"); AddType(0x3000, "7412F7D5-A156-4B13-81DC-867174929325", "ONIE boot");
AddType(0x3001, "D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149", "ONIE config"); AddType(0x3001, "D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149", "ONIE config");
// Plan 9; see http://man.cat-v.org/9front/8/prep
AddType(0x3900, "C91818F9-8025-47AF-89D2-F030D7000C2C", "Plan 9");
// PowerPC reference platform boot partition // PowerPC reference platform boot partition
AddType(0x4100, "9E1A2D38-C612-4316-AA26-8B49521E5A8B", "PowerPC PReP boot"); AddType(0x4100, "9E1A2D38-C612-4316-AA26-8B49521E5A8B", "PowerPC PReP boot");
// Windows LDM ("dynamic disk") types // Windows LDM ("dynamic disk") types
AddType(0x4200, "AF9B60A0-1431-4F62-BC68-3311714A69AD", "Windows LDM data"); // Logical disk manager 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(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.... // An oddball IBM filesystem....
AddType(0x7501, "37AFFC90-EF7D-4E96-91C3-2D7AE055B174", "IBM GPFS"); // General Parallel File System (GPFS) AddType(0x7501, "37AFFC90-EF7D-4E96-91C3-2D7AE055B174", "IBM GPFS"); // General Parallel File System (GPFS)
@@ -128,6 +132,7 @@ void PartType::AddAllTypes(void) {
AddType(0x8304, "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709", "Linux x86-64 root (/)"); // Linux / on x86-64 (auto-mounted by systemd) AddType(0x8304, "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709", "Linux x86-64 root (/)"); // Linux / on x86-64 (auto-mounted by systemd)
AddType(0x8305, "B921B045-1DF0-41C3-AF44-4C6F280D3FAE", "Linux ARM64 root (/)"); // Linux / on 64-bit ARM (auto-mounted by systemd) AddType(0x8305, "B921B045-1DF0-41C3-AF44-4C6F280D3FAE", "Linux ARM64 root (/)"); // Linux / on 64-bit ARM (auto-mounted by systemd)
AddType(0x8306, "3B8F8425-20E0-4F3B-907F-1A25A76F98E8", "Linux /srv"); // Linux /srv (auto-mounted by systemd) AddType(0x8306, "3B8F8425-20E0-4F3B-907F-1A25A76F98E8", "Linux /srv"); // Linux /srv (auto-mounted by systemd)
AddType(0x8307, "69DAD710-2CE4-4E3C-B16C-21A1D49ABED3", "Linux ARM32 root (/)"); // Linux / on 32-bit ARM (auto-mounted by systemd)
// Used by Intel Rapid Start technology // Used by Intel Rapid Start technology
AddType(0x8400, "D3BFE2DE-3DAF-11DF-BA40-E3A556D89593", "Intel Rapid Start"); AddType(0x8400, "D3BFE2DE-3DAF-11DF-BA40-E3A556D89593", "Intel Rapid Start");
@@ -153,6 +158,9 @@ void PartType::AddAllTypes(void) {
AddType(0xa584, "85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7", "Midnight BSD ZFS"); AddType(0xa584, "85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7", "Midnight BSD ZFS");
AddType(0xa585, "85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7", "Midnight BSD Vinum"); AddType(0xa585, "85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7", "Midnight BSD Vinum");
// OpenBSD partition type....
AddType(0xa600, "824CC7A0-36A8-11E3-890A-952519AD3F61", "OpenBSD disklabel");
// A MacOS partition type, separated from others by NetBSD partition types... // A MacOS partition type, separated from others by NetBSD partition types...
AddType(0xa800, "55465300-0000-11AA-AA11-00306543ECAC", "Apple UFS"); // Mac OS X AddType(0xa800, "55465300-0000-11AA-AA11-00306543ECAC", "Apple UFS"); // Mac OS X
@@ -167,7 +175,7 @@ void PartType::AddAllTypes(void) {
AddType(0xa906, "49F48DAA-B10E-11DC-B99B-0019D1879648", "NetBSD RAID"); AddType(0xa906, "49F48DAA-B10E-11DC-B99B-0019D1879648", "NetBSD RAID");
// Mac OS partition types (See also 0xa800, above).... // Mac OS partition types (See also 0xa800, above)....
AddType(0xab00, "426F6F74-0000-11AA-AA11-00306543ECAC", "Apple boot"); AddType(0xab00, "426F6F74-0000-11AA-AA11-00306543ECAC", "Recovery HD");
AddType(0xaf00, "48465300-0000-11AA-AA11-00306543ECAC", "Apple HFS/HFS+"); AddType(0xaf00, "48465300-0000-11AA-AA11-00306543ECAC", "Apple HFS/HFS+");
AddType(0xaf01, "52414944-0000-11AA-AA11-00306543ECAC", "Apple RAID"); AddType(0xaf01, "52414944-0000-11AA-AA11-00306543ECAC", "Apple RAID");
AddType(0xaf02, "52414944-5F4F-11AA-AA11-00306543ECAC", "Apple RAID offline"); AddType(0xaf02, "52414944-5F4F-11AA-AA11-00306543ECAC", "Apple RAID offline");
@@ -175,6 +183,9 @@ void PartType::AddAllTypes(void) {
AddType(0xaf04, "5265636F-7665-11AA-AA11-00306543ECAC", "AppleTV recovery"); AddType(0xaf04, "5265636F-7665-11AA-AA11-00306543ECAC", "AppleTV recovery");
AddType(0xaf05, "53746F72-6167-11AA-AA11-00306543ECAC", "Apple Core Storage"); AddType(0xaf05, "53746F72-6167-11AA-AA11-00306543ECAC", "Apple Core Storage");
// Acronis Secure Zone
AddType(0xbc00, "0311FC50-01CA-4725-AD77-9ADBB20ACE98", "Acronis Secure Zone");
// Solaris partition types (one of which is shared with MacOS) // Solaris partition types (one of which is shared with MacOS)
AddType(0xbe00, "6A82CB45-1DD2-11B2-99A6-080020736631", "Solaris boot"); AddType(0xbe00, "6A82CB45-1DD2-11B2-99A6-080020736631", "Solaris boot");
AddType(0xbf00, "6A85CF4D-1DD2-11B2-99A6-080020736631", "Solaris root"); AddType(0xbf00, "6A85CF4D-1DD2-11B2-99A6-080020736631", "Solaris root");
@@ -213,7 +224,7 @@ void PartType::AddAllTypes(void) {
// Ceph type codes; see https://github.com/ceph/ceph/blob/9bcc42a3e6b08521694b5c0228b2c6ed7b3d312e/src/ceph-disk#L76-L81 // 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(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(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(0xf803, "45B0969E-9B03-4F30-B4C6-5EC00CEFF106", "Ceph dm-crypt journal");
AddType(0xf804, "89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE", "Ceph disk in creation"); AddType(0xf804, "89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE", "Ceph disk in creation");
AddType(0xf805, "89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE", "Ceph dm-crypt 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) .\" Copyright 2011-2015 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License .\" 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.1" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME" .SH "NAME"
sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix
.SH "SYNOPSIS" .SH "SYNOPSIS"
@@ -148,11 +148,11 @@ sibling. Options available in \fBsgdisk\fR are:
.TP .TP
.B \-a, \-\-set\-alignment=value .B \-a, \-\-set\-alignment=value
Set the sector alignment multiple. GPT fdisk aligns the start of partitions Set the sector alignment multiple. GPT fdisk aligns the start of partitions
to sectors that are multiples of this value, which defaults to 2048 on to sectors that are multiples of this value, which defaults to 1MiB (2048
freshly formatted disks. This alignment value is necessary to obtain optimum on disks with 512-byte sectors) on freshly formatted disks. This alignment
performance with Western Digital Advanced Format and similar drives with larger value is necessary to obtain optimum performance with Western Digital
physical than logical sector sizes, with some types of RAID arrays, and Advanced Format and similar drives with larger physical than logical sector
with SSD devices. sizes, with some types of RAID arrays, and with SSD devices.
.TP .TP
.B \-A, \-\-attributes=list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]] .B \-A, \-\-attributes=list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]]
@@ -335,10 +335,7 @@ to use the first available partition number. Subsequent uses of the
.TP .TP
.B \-N, \-\-largest\-new=num .B \-N, \-\-largest\-new=num
Create a new partition that fills the largest available block of space on Create a new partition that fills the largest available block of space on
the disk. Note that if used on a completely blank disk, this is likely to the disk. You can use the \fI\-a\fR (\fI\-\-set\-alignment\fR) option to
result in a sector-moved warning, since the first available sector
(normally 34) doesn't fall on a 2048-sector boundary (the default for
alignment). You can use the \fI\-a\fR (\fI\-\-set\-alignment\fR) option to
adjust the alignment, if desired. A num value of 0 causes the program to adjust the alignment, if desired. A num value of 0 causes the program to
use the first available partition number. use the first available partition number.
@@ -352,12 +349,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 disk's original partition table is bad; however, most other options on the
same command line will be ignored. 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 .TP
.B \-p, \-\-print .B \-p, \-\-print
Display basic partition summary data. This includes partition Display basic GPT partition summary data. This includes partition numbers,
numbers, starting and ending sector numbers, partition sizes, starting and ending sector numbers, partition sizes, \fBsgdisk\fR's
\fBsgdisk\fR's partition types codes, and partition names. For partition types codes, and partition names. For additional information, use
additional information, use the \fI\-i\fR (\fI\-\-info\fR) option. the \fI\-i\fR (\fI\-\-info\fR) option.
.TP .TP
.B \-P, \-\-pretend .B \-P, \-\-pretend
@@ -475,7 +480,8 @@ An error occurred while reading the partition table
.TP .TP
.B 3 .B 3
Non\-GPT disk detected and no \fI\-g\fR option Non\-GPT disk detected and no \fI\-g\fR option, but operation requires a
write action
.TP .TP
.B 4 .B 4
@@ -491,8 +497,7 @@ sgdisk, but may with gdisk)
Disk replication operation (-R) failed Disk replication operation (-R) failed
.SH "BUGS" .SH "BUGS"
As of March 2014 (version 0.8.10), \fBsgdisk\fR Known bugs and limitations include:
should be considered beta software. Known bugs and limitations include:
.TP .TP
.B * .B *
@@ -578,7 +583,7 @@ Contributors:
* Justin Maggard (justin.maggard@netgear.com) * Justin Maggard (justin.maggard@netgear.com)
* Dwight Schauer (dschauer@ti.com) * Dwight Schauer (dschauer@gmail.com)
* Florian Zumbiehl (florz@florz.de) * Florian Zumbiehl (florz@florz.de)

View File

@@ -34,6 +34,24 @@ using namespace std;
// Reads a string from stdin, returning it as a C++-style string. // Reads a string from stdin, returning it as a C++-style string.
// Note that the returned string will NOT include the carriage return // Note that the returned string will NOT include the carriage return
// entered by the user. // entered by the user.
#ifdef EFI
extern int __sscanf( const char * str , const char * format , ... ) ;
string ReadString(void) {
string inString;
char efiString[256];
int stringLength;
if (fgets(efiString, 255, stdin) != NULL) {
stringLength = strlen(efiString);
if ((stringLength > 0) && (efiString[stringLength - 1] == '\n'))
efiString[stringLength - 1] = '\0';
inString = efiString;
} else {
inString = "";
}
return inString;
} // ReadString()
#else
string ReadString(void) { string ReadString(void) {
string inString; string inString;
@@ -42,6 +60,7 @@ string ReadString(void) {
exit(5); exit(5);
return inString; return inString;
} // ReadString() } // ReadString()
#endif
// Get a numeric value from the user, between low and high (inclusive). // Get a numeric value from the user, between low and high (inclusive).
// Keeps looping until the user enters a value within that range. // Keeps looping until the user enters a value within that range.
@@ -132,7 +151,7 @@ uint64_t GetSectorNum(uint64_t low, uint64_t high, uint64_t def, uint64_t sSize,
uint64_t IeeeToInt(string inValue, uint64_t sSize, uint64_t low, uint64_t high, uint64_t def) { uint64_t IeeeToInt(string inValue, uint64_t sSize, uint64_t low, uint64_t high, uint64_t def) {
uint64_t response = def, bytesPerUnit = 1, mult = 1, divide = 1; uint64_t response = def, bytesPerUnit = 1, mult = 1, divide = 1;
size_t foundAt = 0; size_t foundAt = 0;
char suffix, plusFlag = ' '; char suffix = ' ', plusFlag = ' ';
string suffixes = "KMGTPE"; string suffixes = "KMGTPE";
int badInput = 0; // flag bad input; once this goes to 1, other values are irrelevant int badInput = 0; // flag bad input; once this goes to 1, other values are irrelevant
@@ -225,7 +244,7 @@ string BytesToIeee(uint64_t size, uint32_t sectorSize) {
uint64_t sizeInIeee; uint64_t sizeInIeee;
uint64_t previousIeee; uint64_t previousIeee;
float decimalIeee; float decimalIeee;
uint index = 0; uint64_t index = 0;
string units, prefixes = " KMGTPEZ"; string units, prefixes = " KMGTPEZ";
ostringstream theValue; ostringstream theValue;

View File

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