0.6.8 release

This commit is contained in:
srs5694
2010-05-23 13:07:19 -04:00
parent 8b6f476ee5
commit 8f1b2d6edc
7 changed files with 80 additions and 48 deletions

View File

@@ -1,11 +1,11 @@
Summary: An fdisk-like partitioning tool for GPT disks Summary: An fdisk-like partitioning tool for GPT disks
Name: gdisk Name: gdisk
Version: 0.6.7 Version: 0.6.8
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/gdisk-0.6.7.tgz Source: http://www.rodsbooks.com/gdisk/gdisk-0.6.8.tgz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%description %description
@@ -34,11 +34,11 @@ rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root -) %defattr(-,root,root -)
%doc CHANGELOG COPYING README %doc NEWS COPYING README
/sbin/gdisk /sbin/gdisk
/sbin/sgdisk /sbin/sgdisk
%doc %{_mandir}/man8* %doc %{_mandir}/man8*
%changelog %changelog
* Sat May 1 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.7 * Sun May 23 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.8
- Created spec file for 0.6.7 release - Created spec file for 0.6.8 release

View File

@@ -39,6 +39,7 @@ void DiskIO::MakeRealName(void) {
// work. // work.
int DiskIO::OpenForRead(void) { int DiskIO::OpenForRead(void) {
int shouldOpen = 1; int shouldOpen = 1;
struct stat64 st;
if (isOpen) { // file is already open if (isOpen) { // file is already open
if (openForWrite) { if (openForWrite) {
@@ -61,8 +62,22 @@ int DiskIO::OpenForRead(void) {
isOpen = 0; isOpen = 0;
openForWrite = 0; openForWrite = 0;
} else { } else {
isOpen = 1; isOpen = 0;
openForWrite = 0; openForWrite = 0;
if (fstat64(fd, &st) == 0) {
if (S_ISDIR(st.st_mode))
cerr << "The specified path is a directory!\n";
#ifndef __FreeBSD__
else if (S_ISCHR(st.st_mode))
cerr << "The specified path is a character device!\n";
#endif
else if (S_ISFIFO(st.st_mode))
cerr << "The specified path is a FIFO!\n";
else if (S_ISSOCK(st.st_mode))
cerr << "The specified path is a socket!\n";
else
isOpen = 1;
} // if (fstat64()...)
} // if/else } // if/else
} // if } // if

View File

@@ -1,6 +1,6 @@
.\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com) .\" Copyright 2010 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.6.7" "Roderick W. Smith" "GPT fdisk Manual" .TH "GDISK" "8" "0.6.8" "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"
@@ -648,6 +648,8 @@ Contributors:
* David Hubbard (david.c.hubbard@gmail.com) * David Hubbard (david.c.hubbard@gmail.com)
* One anonymous contributor
.SH "SEE ALSO" .SH "SEE ALSO"
\fBcfdisk (8)\fR, \fBcfdisk (8)\fR,
\fBfdisk (8)\fR, \fBfdisk (8)\fR,

5
gpt.cc
View File

@@ -30,10 +30,13 @@
using namespace std; using namespace std;
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#define log2(x) (log(x) / M_LN2) #define log2(x) (log(x) / M_LN2)
#endif // __FreeBSD__ #endif // __FreeBSD__
#ifdef _MSC_VER
#define log2(x) (log((double) x) / log(2.0))
#endif // Microsoft Visual C++
/**************************************** /****************************************
* * * *

2
gpt.h
View File

@@ -16,7 +16,7 @@
#ifndef __GPTSTRUCTS #ifndef __GPTSTRUCTS
#define __GPTSTRUCTS #define __GPTSTRUCTS
#define GPTFDISK_VERSION "0.6.8-pre2" #define GPTFDISK_VERSION "0.6.8"
// Constants used by GPTData::PartsToMBR(). MBR_EMPTY must be the lowest- // Constants used by GPTData::PartsToMBR(). MBR_EMPTY must be the lowest-
// numbered value to refer to partition numbers. (Most will be 0 or positive, // numbered value to refer to partition numbers. (Most will be 0 or positive,

80
guid.cc
View File

@@ -55,6 +55,8 @@ GUIDData & GUIDData::operator=(const GUIDData & orig) {
// than 36 characters long, this function assumes the input GUID has // than 36 characters long, this function assumes the input GUID has
// been compressed by removal of separators. In either event, there's // been compressed by removal of separators. In either event, there's
// little in the way of sanity checking, so garbage in = garbage out! // little in the way of sanity checking, so garbage in = garbage out!
// One special case: If the first character is 'r' or 'R', a random
// GUID is assigned.
GUIDData & GUIDData::operator=(const string & orig) { GUIDData & GUIDData::operator=(const string & orig) {
string copy, fragment; string copy, fragment;
size_t len; size_t len;
@@ -63,45 +65,51 @@ GUIDData & GUIDData::operator=(const string & orig) {
size_t shortSegs[6] = {0, 8, 12, 16, 20, 32}; size_t shortSegs[6] = {0, 8, 12, 16, 20, 32};
size_t *segStart = longSegs; // Assume there are separators between segments size_t *segStart = longSegs; // Assume there are separators between segments
Zero(); // If first character is an 'R' or 'r', set a random GUID; otherwise,
// try to parse it as a real GUID
if ((orig[0] == 'R') || (orig[0] == 'r')) {
Randomize();
} else {
Zero();
// Delete stray spaces.... // Delete stray spaces....
copy = DeleteSpaces(orig); copy = DeleteSpaces(orig);
// If length is too short, assume there are no separators between segments // If length is too short, assume there are no separators between segments
len = copy.length(); len = copy.length();
if (len < 36) { if (len < 36) {
segStart = shortSegs; segStart = shortSegs;
}; };
// Extract data fragments at fixed locations and convert to // Extract data fragments at fixed locations and convert to
// integral types.... // integral types....
if (len >= segStart[1]) { if (len >= segStart[1]) {
uuidData[3] = StrToHex(copy, 0); uuidData[3] = StrToHex(copy, 0);
uuidData[2] = StrToHex(copy, 2); uuidData[2] = StrToHex(copy, 2);
uuidData[1] = StrToHex(copy, 4); uuidData[1] = StrToHex(copy, 4);
uuidData[0] = StrToHex(copy, 6); uuidData[0] = StrToHex(copy, 6);
} // if } // if
if (len >= segStart[2]) { if (len >= segStart[2]) {
uuidData[5] = StrToHex(copy, segStart[1]); uuidData[5] = StrToHex(copy, segStart[1]);
uuidData[4] = StrToHex(copy, segStart[1] + 2); uuidData[4] = StrToHex(copy, segStart[1] + 2);
} // if } // if
if (len >= segStart[3]) { if (len >= segStart[3]) {
uuidData[7] = StrToHex(copy, segStart[2]); uuidData[7] = StrToHex(copy, segStart[2]);
uuidData[6] = StrToHex(copy, segStart[2] + 2); uuidData[6] = StrToHex(copy, segStart[2] + 2);
} // if } // if
if (len >= segStart[4]) { if (len >= segStart[4]) {
uuidData[8] = StrToHex(copy, segStart[3]); uuidData[8] = StrToHex(copy, segStart[3]);
uuidData[9] = StrToHex(copy, segStart[3] + 2); uuidData[9] = StrToHex(copy, segStart[3] + 2);
} // if } // if
if (len >= segStart[5]) { if (len >= segStart[5]) {
uuidData[10] = StrToHex(copy, segStart[4]); uuidData[10] = StrToHex(copy, segStart[4]);
uuidData[11] = StrToHex(copy, segStart[4] + 2); uuidData[11] = StrToHex(copy, segStart[4] + 2);
uuidData[12] = StrToHex(copy, segStart[4] + 4); uuidData[12] = StrToHex(copy, segStart[4] + 4);
uuidData[13] = StrToHex(copy, segStart[4] + 6); uuidData[13] = StrToHex(copy, segStart[4] + 6);
uuidData[14] = StrToHex(copy, segStart[4] + 8); uuidData[14] = StrToHex(copy, segStart[4] + 8);
uuidData[15] = StrToHex(copy, segStart[4] + 10); uuidData[15] = StrToHex(copy, segStart[4] + 10);
} // if } // if
} // if/else randomize/set value
return *this; return *this;
} // GUIDData::operator=(const string & orig) } // GUIDData::operator=(const string & orig)

View File

@@ -1,6 +1,6 @@
.\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com) .\" Copyright 2010 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.6.7" "Roderick W. Smith" "GPT fdisk Manual" .TH "SGDISK" "8" "0.6.8" "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"
@@ -365,11 +365,13 @@ high compared to the likelihood of problems with an MBR conversion.
.TP .TP
.B \-u, \-\-partition-guid=partnum:guid .B \-u, \-\-partition-guid=partnum:guid
Set the partition unique GUID for an individual partition. Set the partition unique GUID for an individual partition. The GUID may be
a complete GUID or 'R' to set a random GUID.
.TP .TP
.B \-U, \-\-disk-guid=guid .B \-U, \-\-disk-guid=guid
Set the GUID for the disk. Set the GUID for the disk. The GUID may be a complete GUID or 'R' to set a
random GUID.
.TP .TP
.B \-\-usage .B \-\-usage
@@ -530,6 +532,8 @@ Contributors:
* David Hubbard (david.c.hubbard@gmail.com) * David Hubbard (david.c.hubbard@gmail.com)
* One anonymous contributor
.SH "SEE ALSO" .SH "SEE ALSO"
\fBcfdisk (8)\fR, \fBcfdisk (8)\fR,
\fBfdisk (8)\fR, \fBfdisk (8)\fR,