summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2010-05-23 13:07:19 -0400
committersrs5694 <srs5694@users.sourceforge.net>2010-05-23 13:07:19 -0400
commit8f1b2d6edcb4ab45c8cf80c6e58c5c776d2e550e (patch)
tree2a3a3e4f8c717ab156615d3f6e054d10a65746f9
parent8b6f476ee5b17e4a0efeb0240a5e7a134d1e1fab (diff)
downloadsgdisk-8f1b2d6edcb4ab45c8cf80c6e58c5c776d2e550e.tar.gz
0.6.8 release
-rw-r--r--current.spec10
-rw-r--r--diskio-unix.cc17
-rw-r--r--gdisk.84
-rw-r--r--gpt.cc5
-rw-r--r--gpt.h2
-rw-r--r--guid.cc86
-rw-r--r--sgdisk.810
7 files changed, 83 insertions, 51 deletions
diff --git a/current.spec b/current.spec
index 8e8592a..b9b1341 100644
--- a/current.spec
+++ b/current.spec
@@ -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
diff --git a/diskio-unix.cc b/diskio-unix.cc
index 7d24301..b20f161 100644
--- a/diskio-unix.cc
+++ b/diskio-unix.cc
@@ -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
diff --git a/gdisk.8 b/gdisk.8
index 1a93c38..ce4cda8 100644
--- a/gdisk.8
+++ b/gdisk.8
@@ -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,
diff --git a/gpt.cc b/gpt.cc
index 4292035..213774e 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -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++
/****************************************
* *
diff --git a/gpt.h b/gpt.h
index f2399b4..235c7af 100644
--- a/gpt.h
+++ b/gpt.h
@@ -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,
diff --git a/guid.cc b/guid.cc
index 07fd733..9a55765 100644
--- a/guid.cc
+++ b/guid.cc
@@ -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();
-
- // 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;
- };
-
- // 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 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);
+
+ // 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
+ } // if/else randomize/set value
return *this;
} // GUIDData::operator=(const string & orig)
diff --git a/sgdisk.8 b/sgdisk.8
index 6a3a0b1..63c8cf5 100644
--- a/sgdisk.8
+++ b/sgdisk.8
@@ -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,