Skip to content

Commit

Permalink
Changes for version 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
srs5694 committed Sep 11, 2011
1 parent 3860cbe commit a17fe69
Show file tree
Hide file tree
Showing 22 changed files with 581 additions and 988 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ MBR_LIB_OBJS=$(MBR_LIBS:=.o)
LIB_HEADERS=$(LIB_NAMES:=.h)
DEPEND= makedepend $(CXXFLAGS)

all: gdisk sgdisk fixparts
all: cgdisk gdisk sgdisk fixparts

gdisk: $(LIB_OBJS) gdisk.o gpttext.o
# $(CXX) $(LIB_OBJS) gdisk.o gpttext.o $(LDFLAGS) -luuid -o gdisk
$(CXX) $(LIB_OBJS) gdisk.o gpttext.o $(LDFLAGS) -licuio -licuuc -luuid -o gdisk

sgdisk: $(LIB_OBJS) sgdisk.o
# $(CXX) $(LIB_OBJS) sgdisk.o $(LDFLAGS) -luuid -lpopt -o sgdisk
$(CXX) $(LIB_OBJS) sgdisk.o $(LDFLAGS) -licuio -licuuc -luuid -lpopt -o sgdisk
cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o
# $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -luuid -lncurses -o cgdisk
$(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licuio -licuuc -luuid -lncurses -o cgdisk

sgdisk: $(LIB_OBJS) sgdisk.o gptcl.o
# $(CXX) $(LIB_OBJS) sgdisk.o gptcl.o $(LDFLAGS) -luuid -lpopt -o sgdisk
$(CXX) $(LIB_OBJS) sgdisk.o gptcl.o $(LDFLAGS) -licuio -licuuc -luuid -lpopt -o sgdisk

fixparts: $(MBR_LIB_OBJS) fixparts.o
$(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts
Expand All @@ -28,7 +32,7 @@ lint: #no pre-reqs
lint $(SRCS)

clean: #no pre-reqs
rm -f core *.o *~ gdisk sgdisk fixparts
rm -f core *.o *~ gdisk sgdisk cgdisk fixparts

# what are the source dependencies
depend: $(SRCS)
Expand All @@ -38,3 +42,4 @@ $(OBJS):
$(CRITICAL_CXX_FLAGS)

# DO NOT DELETE

12 changes: 8 additions & 4 deletions Makefile.freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ MBR_LIB_OBJS=$(MBR_LIBS:=.o)
LIB_HEADERS=$(LIB_NAMES:=.h)
DEPEND= makedepend $(CXXFLAGS)

all: gdisk sgdisk fixparts
all: gdisk cgdisk sgdisk fixparts

gdisk: $(LIB_OBJS) gdisk.o gpttext.o
$(CXX) $(LIB_OBJS) gdisk.o gpttext.o -L/usr/local/lib $(LDFLAGS) -licuio -luuid -o gdisk
# $(CXX) $(LIB_OBJS) gdisk.o gpttext.o -L/usr/local/lib $(LDFLAGS) -luuid -o gdisk

sgdisk: $(LIB_OBJS) sgdisk.o
$(CXX) $(LIB_OBJS) sgdisk.o -L/usr/local/lib $(LDFLAGS) -luuid -licuio -lpopt -o sgdisk
# $(CXX) $(LIB_OBJS) sgdisk.o -L/usr/local/lib $(LDFLAGS) -luuid -lpopt -o sgdisk
cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o
$(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o -L/usr/local/lib $(LDFLAGS) -licuio -luuid -lncurses -o cgdisk
# $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o -L/usr/local/lib $(LDFLAGS) -luuid -lncurses -o cgdisk

sgdisk: $(LIB_OBJS) sgdisk.o gptcl.o
$(CXX) $(LIB_OBJS) sgdisk.o gptcl.o -L/usr/local/lib $(LDFLAGS) -luuid -licuio -lpopt -o sgdisk
# $(CXX) $(LIB_OBJS) sgdisk.o gptcl.o -L/usr/local/lib $(LDFLAGS) -luuid -lpopt -o sgdisk

fixparts: $(MBR_LIB_OBJS) fixparts.o
$(CXX) $(MBR_LIB_OBJS) fixparts.o -L/usr/local/lib $(LDFLAGS) -o fixparts
Expand Down
12 changes: 8 additions & 4 deletions Makefile.mac
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ MBR_LIB_OBJS=$(MBR_LIBS:=.o)
LIB_HEADERS=$(LIB_NAMES:=.h)
DEPEND= makedepend $(CFLAGS)

all: gdisk sgdisk fixparts
all: gdisk sgdisk cgdisk fixparts

gdisk: $(LIB_OBJS) gpttext.o gdisk.o
# $(CXX) $(LIB_OBJS) gpttext.o gdisk.o -o gdisk
$(CXX) $(LIB_OBJS) -L/usr/lib -licucore gpttext.o gdisk.o -o gdisk

sgdisk: $(LIB_OBJS) sgdisk.o
# $(CXX) $(LIB_OBJS) sgdisk.o -L/sw/lib -lpopt -o sgdisk
$(CXX) $(LIB_OBJS) sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk
cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o
# $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -lncurses -o sgdisk
$(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licucore -lncurses -o cgdisk

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 -L/sw/lib -licucore -lpopt -o sgdisk

fixparts: $(MBR_LIB_OBJS) fixparts.o
$(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts
Expand Down
33 changes: 33 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
0.8.0 (9/10/2011):
------------------

- Added new return option for sgdisk: 8, which means that a replication
operation (-R or --replicate) failed. Note that other operations on
the same command line might still have succeeded.

- Added gdisk_test.sh shell script, contributed by Guillaume Delacour.
This script tests some common gdisk and sgdisk operations to be sure
they're working correctly.

- Enable sgdisk's -l (--load-backup) and -o (--clear) options to work
even on disks that are damaged. Most other options will still be ignored,
though, so if you suspect a disk may be bad and want to use one of these
options, you should do so on a line by itself, followed by a separate
command to perform other actions (such as adding new partitions).

- Added check for mis-matched primary and backup partition tables.
A mismatch is reported as a CRC error.

- Added Apple Core Storage partition type code (hex code AF05, GUID
53746F72-6167-11AA-AA11-00306543ECAC).

- Added cgdisk program to the family. This program is a rough workalike
to cfdisk, much as gdisk is a rough workalike to fdisk. See the cgdisk
man page or http://www.rodsbooks.com/gdisk/cgdisk-walkthrough.html for
details about its operation.

- Fixed bug that caused CHS end point for protective MBR to be set to
0xfeffff rather than the spec-mandated 0xffffff on disks over ~8GB. This
is a very minor bug, since not much cares about this, and most other GPT
tools get it wrong in the same way, too.

0.7.2 (6/26/2011):
------------------

Expand Down
4 changes: 4 additions & 0 deletions basicmbr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,12 @@ int BasicMBRData::BlankGPTData(void) {
// the most common value for big disks (255 heads, 63 sectors per
// track, & however many cylinders that computes to).
void BasicMBRData::ReadCHSGeom(void) {
int err;

numHeads = myDisk->GetNumHeads();
numSecspTrack = myDisk->GetNumSecsPerTrack();
diskSize = myDisk->DiskSize(&err);
blockSize = myDisk->GetBlockSize();
partitions[0].SetGeometry(numHeads, numSecspTrack, diskSize, blockSize);
} // BasicMBRData::ReadCHSGeom()

Expand Down
23 changes: 13 additions & 10 deletions current.spec
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
Summary: GPT partitioning and MBR repair software
Name: gptfdisk
Version: 0.7.2
Version: 0.8.0
Release: 1%{?dist}
License: GPLv2
URL: http://www.rodsbooks.com/gdisk
Group: Applications/System
Source: http://www.rodsbooks.com/gdisk/gptfdisk-0.7.2.tar.gz
Source: http://www.rodsbooks.com/gdisk/gptfdisk-0.8.0.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

%description

Partitioning software for GPT disks and to repair MBR
disks. The gdisk and sgdisk utilities (in the gdisk
package) are GPT-enabled partitioning tools; the
fixparts utility (in the fixparts package) fixes some
problems with MBR disks that can be created by buggy
partitioning software.
Partitioning software for GPT disks and to repair MBR disks. The gdisk,
cgdisk, and sgdisk utilities (in the gdisk package) are GPT-enabled
partitioning tools; the fixparts utility (in the fixparts package) fixes
some problems with MBR disks that can be created by buggy partitioning
software.

%package -n gdisk

Expand All @@ -41,9 +40,11 @@ rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/sbin
install -Dp -m0755 gdisk $RPM_BUILD_ROOT/usr/sbin
install -Dp -m0755 sgdisk $RPM_BUILD_ROOT/usr/sbin
install -Dp -m0755 cgdisk $RPM_BUILD_ROOT/usr/sbin
install -Dp -m0755 fixparts $RPM_BUILD_ROOT/usr/sbin
install -Dp -m0644 gdisk.8 $RPM_BUILD_ROOT/%{_mandir}/man8/gdisk.8
install -Dp -m0644 sgdisk.8 $RPM_BUILD_ROOT/%{_mandir}/man8/sgdisk.8
install -Dp -m0644 cgdisk.8 $RPM_BUILD_ROOT/%{_mandir}/man8/cgdisk.8
install -Dp -m0644 fixparts.8 $RPM_BUILD_ROOT/%{_mandir}/man8/fixparts.8

%clean
Expand All @@ -54,8 +55,10 @@ rm -rf $RPM_BUILD_ROOT
%doc NEWS COPYING README
/usr/sbin/gdisk
/usr/sbin/sgdisk
/usr/sbin/cgdisk
%doc %{_mandir}/man8/gdisk.8*
%doc %{_mandir}/man8/sgdisk.8*
%doc %{_mandir}/man8/cgdisk.8*

%package -n fixparts

Expand All @@ -77,5 +80,5 @@ provides a few additional partition manipulation features.


%changelog
* Sun Jun 26 2011 R Smith <[email protected]> - 0.7.2
- Created spec file for 0.7.2 release
* Sat Sep 10 2011 R Smith <[email protected]> - 0.8.0
- Created spec file for 0.8.0 release
13 changes: 10 additions & 3 deletions diskio-unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ uint32_t DiskIO::GetNumSecsPerTrack(void) {

// Resync disk caches so the OS uses the new partition table. This code varies
// a lot from one OS to another.
void DiskIO::DiskSync(void) {
int i, platformFound = 0;
// Returns 1 on success, 0 if the kernel continues to use the old partition table.
// (Note that for most OSes, the default of 0 is returned because I've not yet
// looked into how to test for success in the underlying system calls...)
int DiskIO::DiskSync(void) {
int i, retval = 0, platformFound = 0;

// If disk isn't open, try to open it....
if (!isOpen) {
Expand Down Expand Up @@ -233,16 +236,20 @@ void DiskIO::DiskSync(void) {
sleep(1); // Theoretically unnecessary, but ioctl() fails sometimes if omitted....
fsync(fd);
i = ioctl(fd, BLKRRPART);
if (i)
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";
} else {
retval = 1;
} // if/else
platformFound++;
#endif
if (platformFound == 0)
cerr << "Warning: Platform not recognized!\n";
if (platformFound > 1)
cerr << "\nWarning: We seem to be running on multiple platforms!\n";
} // if (isOpen)
return retval;
} // DiskIO::DiskSync()

// Seek to the specified sector. Returns 1 on success, 0 on failure.
Expand Down
6 changes: 5 additions & 1 deletion diskio-windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ uint32_t DiskIO::GetNumSecsPerTrack(void) {

// Resync disk caches so the OS uses the new partition table. This code varies
// a lot from one OS to another.
void DiskIO::DiskSync(void) {
// Returns 1 on success, 0 if the kernel continues to use the old partition table.
int DiskIO::DiskSync(void) {
DWORD i;
GET_LENGTH_INFORMATION buf;
int retval = 0;

// If disk isn't open, try to open it....
if (!openForWrite) {
Expand All @@ -174,12 +176,14 @@ void DiskIO::DiskSync(void) {
} else {
cout << "Disk synchronization succeeded! The computer should now use the new\n"
<< "partition table.\n";
retval = 1;
} // if/else
} else {
cout << "Unable to open the disk for synchronization operation! The computer will\n"
<< "continue to use the old partition table until you reboot or remove and\n"
<< "re-insert the disk!\n";
} // if (isOpen)
return retval;
} // DiskIO::DiskSync()

// Seek to the specified sector. Returns 1 on success, 0 on failure.
Expand Down
2 changes: 1 addition & 1 deletion diskio.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DiskIO {
int Seek(uint64_t sector);
int Read(void* buffer, int numBytes);
int Write(void* buffer, int numBytes);
void DiskSync(void); // resync disk caches to use new partitions
int DiskSync(void); // resync disk caches to use new partitions
int GetBlockSize(void);
uint32_t GetNumHeads(void);
uint32_t GetNumSecsPerTrack(void);
Expand Down
5 changes: 3 additions & 2 deletions fixparts.8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Copyright 2011 Roderick W. Smith ([email protected])
.\" May be distributed under the GNU General Public License
.TH "FIXPARTS" "8" "0.7.2" "Roderick W. Smith" "FixParts Manual"
.TH "FIXPARTS" "8" "0.8.0" "Roderick W. Smith" "FixParts Manual"
.SH "NAME"
fixparts \- MBR partition table repair utility
.SH "SYNOPSIS"
Expand Down Expand Up @@ -202,7 +202,7 @@ see a summary of available options.
.PP

.SH "BUGS"
As of June 2011 (version 0.7.2), \fBfixparts\fR
As of September 2011 (version 0.8.0), \fBfixparts\fR
should be considered beta software. Known bugs and limitations include:

.TP
Expand Down Expand Up @@ -266,6 +266,7 @@ Contributors:

.SH "SEE ALSO"
\fBcfdisk (8)\fR,
\fBcgdisk (8)\fR,
\fBfdisk (8)\fR,
\fBmkfs (8)\fR,
\fBparted (8)\fR,
Expand Down
29 changes: 13 additions & 16 deletions gdisk.8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Copyright 2011 Roderick W. Smith ([email protected])
.\" May be distributed under the GNU General Public License
.TH "GDISK" "8" "0.7.2" "Roderick W. Smith" "GPT fdisk Manual"
.TH "GDISK" "8" "0.8.0" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME"
gdisk \- Interactive GUID partition table (GPT) manipulator
.SH "SYNOPSIS"
Expand Down Expand Up @@ -93,7 +93,7 @@ and in whatever sizes are desired.
.B *
Boot disks for EFI\-based systems require an \fIEFI System
Partition\fR (\fBgdisk\fR internal code 0xEF00) formatted as FAT\-32.
The recommended size of this partition is between 100 and 200 MiB.
The recommended size of this partition is between 100 and 300 MiB.
Boot\-related files are stored here. (Note that GNU Parted identifies
such partitions as having the "boot flag" set.)

Expand Down Expand Up @@ -467,15 +467,15 @@ option on the main menu.
.TP
.B l
Change the sector alignment value. Disks with more logical sectors per
physical sectors (such as some Western Digital models introduced in
December of 2009) and some RAID configurations can suffer performance
problems if partitions are not aligned properly for their internal data
structures. On new disks, GPT fdisk attempts to align partitions on
2048\-sector (1MiB) boundaries by default, which optimizes performance for
both of these disk types. On pre\-partitioned disks, GPT fdisk attempts to
identify the alignment value used on that disk, but will set 8-sector
alignment on disks larger than 300 GB even if lesser alignment values are
detected. In either case, it can be changed by using this option.
physical sectors (such as modern Advanced Format drives), some RAID
configurations, and many SSD devices, can suffer performance problems if
partitions are not aligned properly for their internal data structures. On
new disks, GPT fdisk attempts to align partitions on 2048\-sector (1MiB)
boundaries by default, which optimizes performance for all of these disk
types. On pre\-partitioned disks, GPT fdisk attempts to identify the
alignment value used on that disk, but will set 8-sector alignment on disks
larger than 300 GB even if lesser alignment values are detected. In either
case, it can be changed by using this option.

.TP
.B m
Expand Down Expand Up @@ -561,7 +561,7 @@ entering data. When only one option is possible, \fBgdisk\fR
usually bypasses the prompt entirely.

.SH "BUGS"
As of June 2011 (version 0.7.2), \fBgdisk\fR
As of September 2011 (version 0.8.0), \fBgdisk\fR
should be considered beta software. Known bugs and limitations include:

.TP
Expand Down Expand Up @@ -649,10 +649,6 @@ options in this case.

.PP

The support for big\-endian CPUs (PowerPC, for example) is new, as of
version 0.3.5. I advise using caution on such CPUs, particularly with the
more obscure features of the program.

.SH "AUTHORS"
Primary author: Roderick W. Smith ([email protected])

Expand All @@ -671,6 +667,7 @@ Contributors:

.SH "SEE ALSO"
\fBcfdisk (8)\fR,
\fBcgdisk (8)\fR,
\fBfdisk (8)\fR,
\fBmkfs (8)\fR,
\fBparted (8)\fR,
Expand Down
Loading

0 comments on commit a17fe69

Please sign in to comment.