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
Name: gdisk
Version: 0.6.7
Version: 0.6.8
Release: 1%{?dist}
License: GPLv2
URL: http://www.rodsbooks.com/gdisk
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)
%description
@@ -34,11 +34,11 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root -)
%doc CHANGELOG COPYING README
%doc NEWS COPYING README
/sbin/gdisk
/sbin/sgdisk
%doc %{_mandir}/man8*
%changelog
* Sat May 1 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.7
- Created spec file for 0.6.7 release
* Sun May 23 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.8
- Created spec file for 0.6.8 release

View File

@@ -39,6 +39,7 @@ void DiskIO::MakeRealName(void) {
// work.
int DiskIO::OpenForRead(void) {
int shouldOpen = 1;
struct stat64 st;
if (isOpen) { // file is already open
if (openForWrite) {
@@ -61,8 +62,22 @@ int DiskIO::OpenForRead(void) {
isOpen = 0;
openForWrite = 0;
} else {
isOpen = 1;
isOpen = 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

View File

@@ -1,6 +1,6 @@
.\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" 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"
gdisk \- Interactive GUID partition table (GPT) manipulator
.SH "SYNOPSIS"
@@ -648,6 +648,8 @@ Contributors:
* David Hubbard (david.c.hubbard@gmail.com)
* One anonymous contributor
.SH "SEE ALSO"
\fBcfdisk (8)\fR,
\fBfdisk (8)\fR,

5
gpt.cc
View File

@@ -30,10 +30,13 @@
using namespace std;
#ifdef __FreeBSD__
#ifdef __FreeBSD__
#define log2(x) (log(x) / M_LN2)
#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
#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-
// 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
// been compressed by removal of separators. In either event, there's
// 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) {
string copy, fragment;
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 *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....
copy = DeleteSpaces(orig);
// Delete stray spaces....
copy = DeleteSpaces(orig);
// If length is too short, assume there are no separators between segments
len = copy.length();
if (len < 36) {
segStart = shortSegs;
};
// If length is too short, assume there are no separators between segments
len = copy.length();
if (len < 36) {
segStart = shortSegs;
};
// Extract data fragments at fixed locations and convert to
// integral types....
if (len >= segStart[1]) {
uuidData[3] = StrToHex(copy, 0);
uuidData[2] = StrToHex(copy, 2);
uuidData[1] = StrToHex(copy, 4);
uuidData[0] = StrToHex(copy, 6);
} // if
if (len >= segStart[2]) {
uuidData[5] = StrToHex(copy, segStart[1]);
uuidData[4] = StrToHex(copy, segStart[1] + 2);
} // if
if (len >= segStart[3]) {
uuidData[7] = StrToHex(copy, segStart[2]);
uuidData[6] = StrToHex(copy, segStart[2] + 2);
} // if
if (len >= segStart[4]) {
uuidData[8] = StrToHex(copy, segStart[3]);
uuidData[9] = StrToHex(copy, segStart[3] + 2);
} // if
if (len >= segStart[5]) {
uuidData[10] = StrToHex(copy, segStart[4]);
uuidData[11] = StrToHex(copy, segStart[4] + 2);
uuidData[12] = StrToHex(copy, segStart[4] + 4);
uuidData[13] = StrToHex(copy, segStart[4] + 6);
uuidData[14] = StrToHex(copy, segStart[4] + 8);
uuidData[15] = StrToHex(copy, segStart[4] + 10);
} // if
// Extract data fragments at fixed locations and convert to
// integral types....
if (len >= segStart[1]) {
uuidData[3] = StrToHex(copy, 0);
uuidData[2] = StrToHex(copy, 2);
uuidData[1] = StrToHex(copy, 4);
uuidData[0] = StrToHex(copy, 6);
} // if
if (len >= segStart[2]) {
uuidData[5] = StrToHex(copy, segStart[1]);
uuidData[4] = StrToHex(copy, segStart[1] + 2);
} // if
if (len >= segStart[3]) {
uuidData[7] = StrToHex(copy, segStart[2]);
uuidData[6] = StrToHex(copy, segStart[2] + 2);
} // if
if (len >= segStart[4]) {
uuidData[8] = StrToHex(copy, segStart[3]);
uuidData[9] = StrToHex(copy, segStart[3] + 2);
} // if
if (len >= segStart[5]) {
uuidData[10] = StrToHex(copy, segStart[4]);
uuidData[11] = StrToHex(copy, segStart[4] + 2);
uuidData[12] = StrToHex(copy, segStart[4] + 4);
uuidData[13] = StrToHex(copy, segStart[4] + 6);
uuidData[14] = StrToHex(copy, segStart[4] + 8);
uuidData[15] = StrToHex(copy, segStart[4] + 10);
} // if
} // if/else randomize/set value
return *this;
} // GUIDData::operator=(const string & orig)

View File

@@ -1,6 +1,6 @@
.\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" 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"
sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix
.SH "SYNOPSIS"
@@ -365,11 +365,13 @@ high compared to the likelihood of problems with an MBR conversion.
.TP
.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
.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
.B \-\-usage
@@ -530,6 +532,8 @@ Contributors:
* David Hubbard (david.c.hubbard@gmail.com)
* One anonymous contributor
.SH "SEE ALSO"
\fBcfdisk (8)\fR,
\fBfdisk (8)\fR,