aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <james>2012-03-11 11:30:50 +0000
committerjames <james>2012-03-11 11:30:50 +0000
commit762907fd59a7458bea74109d37e0f12e8c937a93 (patch)
treef0c176980b4c90b5657dd198aeabcd5431cddfa1
parent9f69f2163178203ce5dc4abb5a909be1338ec5b0 (diff)
downloadgpt-762907fd59a7458bea74109d37e0f12e8c937a93.tar.gz
gpt-762907fd59a7458bea74109d37e0f12e8c937a93.tar.bz2
gpt-762907fd59a7458bea74109d37e0f12e8c937a93.zip
*** empty log message ***
-rw-r--r--src/gpt.c6
-rw-r--r--src/header.c33
-rw-r--r--src/prototypes.h1
3 files changed, 32 insertions, 8 deletions
diff --git a/src/gpt.c b/src/gpt.c
index 4a03379..bcdebaa 100644
--- a/src/gpt.c
+++ b/src/gpt.c
@@ -6,10 +6,13 @@
*
*/
-static char rcsid[] = "$Id: gpt.c,v 1.21 2012/03/11 11:30:50 james Exp $";
+static char rcsid[] = "$Id: gpt.c,v 1.22 2012/03/11 11:31:24 james Exp $";
/*
* $Log: gpt.c,v $
+ * Revision 1.22 2012/03/11 11:31:24 james
+ * *** empty log message ***
+ *
* Revision 1.21 2012/03/11 11:30:50 james
* *** empty log message ***
*
@@ -139,6 +142,7 @@ main (int argc, char *argv[])
if (n)
n = header_check_crc (d, &h.header);
}
+ printf("%d\n",n);
return n ? 0 : -1;
case 'd':
diff --git a/src/header.c b/src/header.c
index e4a7e15..1d5ef3e 100644
--- a/src/header.c
+++ b/src/header.c
@@ -67,6 +67,25 @@ header_calc_ent_crc (DISK * d, GPT_header * h)
}
+int
+header_check_crc (DISK * d, GPT_header * h)
+{
+ GPT_header c = *h;
+ uint32_t crc;
+
+ c.header_crc = 0;
+ crc = crc32 (0, &c, sizeof (c));
+
+ if (crc != h->header_crc)
+ return 0;
+
+ crc = header_calc_ent_crc (d, h);
+
+
+
+ return ! !(crc == h->partition_entry_crc);
+}
+
void
header_show (DISK * d, GPT_header * h)
{
@@ -211,17 +230,17 @@ headers_get_one (DISK * d)
disk_read (d, buf, 1, 1);
memcpy (&ret.header, buf, sizeof (ret.header));
- table_size=ret.header.first_usable_lba;
+ table_size = ret.header.first_usable_lba;
- ret.header.last_usable_lba=lbas-table_size;
+ ret.header.last_usable_lba = lbas - table_size;
- ret.alt_header=ret.header;
+ ret.alt_header = ret.header;
- ret.header.alternate_lba=lbas-1;
+ ret.header.alternate_lba = lbas - 1;
- ret.alt_header.alternate_lba=1;
- ret.alt_header.my_lba=lbas-1;
- ret.alt_header.partition_entry_lba = (lbas - table_size)+1;
+ ret.alt_header.alternate_lba = 1;
+ ret.alt_header.my_lba = lbas - 1;
+ ret.alt_header.partition_entry_lba = (lbas - table_size) + 1;
diff --git a/src/prototypes.h b/src/prototypes.h
index 0f4144e..64545b5 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -18,6 +18,7 @@ uint32_t crc32(uint32_t crc, const void *_buf, int len);
void header_calc_crc(GPT_header *h);
GPT_header header_new(GUID disk_guid, uint64_t lbas, int alt);
uint32_t header_calc_ent_crc(DISK *d, GPT_header *h);
+int header_check_crc(DISK *d, GPT_header *h);
void header_show(DISK *d, GPT_header *h);
int header_validate(DISK *d, GPT_header *h);
void header_redo_ent_crc(DISK *d, GPT_header *h);