From 54cb1cced0d77fd5f36a37d45fbb5f50a00e906a Mon Sep 17 00:00:00 2001 From: james Date: Mon, 10 Sep 2012 08:28:34 +0000 Subject: *** empty log message *** --- src/Makefile.am | 7 +++++-- src/gpt.c | 17 ++++++++++++++--- src/guid.c | 27 +++++++++++++++++++++++++++ version-files | 2 ++ version-md5sums | 1 + version-micro | 2 +- 6 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c39b9a1..d68413b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,9 +5,12 @@ # Copyright (c) 2007 James McKenzie , # All rights reserved. # -# $Id: Makefile.am,v 1.9 2011/08/07 11:33:43 james Exp $ +# $Id: Makefile.am,v 1.10 2012/09/10 08:28:34 james Exp $ # # $Log: Makefile.am,v $ +# Revision 1.10 2012/09/10 08:28:34 james +# *** empty log message *** +# # Revision 1.9 2011/08/07 11:33:43 james # add support for repairing half a table # @@ -43,7 +46,7 @@ noinst_HEADERS = disk.h gpt.h guid.h project.h prototypes.h bin_PROGRAMS = gpt -SRCS=gpt.c version.c util.c guid.c crc.c header.c disk.c pmbr.c show.c entry.c new.c modify.c sync.c fixup.c +SRCS=gpt.c version.c util.c guid.c crc.c header.c disk.c pmbr.c show.c entry.c new.c modify.c sync.c fixup.c dump.c gpt_SOURCES = ${SRCS} gpt_LDADD = diff --git a/src/gpt.c b/src/gpt.c index bcdebaa..373ff02 100644 --- a/src/gpt.c +++ b/src/gpt.c @@ -6,10 +6,13 @@ * */ -static char rcsid[] = "$Id: gpt.c,v 1.22 2012/03/11 11:31:24 james Exp $"; +static char rcsid[] = "$Id: gpt.c,v 1.23 2012/09/10 08:28:35 james Exp $"; /* * $Log: gpt.c,v $ + * Revision 1.23 2012/09/10 08:28:35 james + * *** empty log message *** + * * Revision 1.22 2012/03/11 11:31:24 james * *** empty log message *** * @@ -106,7 +109,10 @@ usage (void) " type or a hexadecimal GUID\n" "gpt -d disk-device -c fill the PMBR with entries taken from\n" " the first few GPT entries, using dark\n" - " voodoo\n"); + " voodoo\n" + "gpt -d disk-device -q read the first GPT, repair it and write the alternate GPT\n" + "gpt -d disk-device -Q print commands which will re-create the parition table\n" + "gpt -d disk-device -C test partition table and give result in exit code\n"); exit (1); } @@ -127,7 +133,7 @@ main (int argc, char *argv[]) fprintf (stderr, "sizeof(off_t)=%d\n", sizeof (off_t)); - while ((c = getopt (argc, argv, "Cqd:hlsef:g:unac")) != EOF) + while ((c = getopt (argc, argv, "CQqd:hlsef:g:unac")) != EOF) { switch (c) { @@ -190,6 +196,11 @@ main (int argc, char *argv[]) fixup (d); disk_reread_kernel_table (d); return 0; + case 'Q': + if (!d) + usage(); + dump_out(d); + return 0; case 'n': if (!d) usage (); diff --git a/src/guid.c b/src/guid.c index 40f83f0..1e7192b 100644 --- a/src/guid.c +++ b/src/guid.c @@ -72,6 +72,33 @@ guid_to_a (GUID g) return ret; } +char * +guid_to_a_simple (GUID g) +{ + char *ret = malloc (GUIDTOARETSIZE); + struct known_struct *ptr = known_guids; + + + while (ptr->name) + { + if (!guid_cmp (&g, &ptr->g)) + { + strcpy (ret, ptr->name); + return ret; + } + ptr++; + } + + snprintf (ret, GUIDTOARETSIZE, + "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", + g.d[3], g.d[2], g.d[1], g.d[0], g.d[5], g.d[4], g.d[7], g.d[6], + g.d[8], g.d[9], g.d[10], g.d[11], g.d[12], g.d[13], g.d[14], + g.d[15]); + + return ret; +} + + int a_to_guid (char *a, GUID * g) { diff --git a/version-files b/version-files index 57db44c..bdbf1a2 100644 --- a/version-files +++ b/version-files @@ -1,7 +1,9 @@ src/crc.c src/disk.c src/disk.h +src/dump.c src/entry.c +src/fixup.c src/gpt.c src/gpt.h src/guid.c diff --git a/version-md5sums b/version-md5sums index ca8437f..9b7c4aa 100644 --- a/version-md5sums +++ b/version-md5sums @@ -2,3 +2,4 @@ 95b82ac0870dc040a8a810114160e7c7 1.0.2 5354ab7faedaed53200e62f9e7afd371 1.0.3 9d1eae74ea64fd014fdd10eac7b92792 1.0.4 +1bb820923e65d23cb351da2d7f72588b 1.0.5 diff --git a/version-micro b/version-micro index b8626c4..7ed6ff8 100644 --- a/version-micro +++ b/version-micro @@ -1 +1 @@ -4 +5 -- cgit v1.2.3