aboutsummaryrefslogtreecommitdiffstats
path: root/src/header.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/header.c')
-rw-r--r--src/header.c80
1 files changed, 43 insertions, 37 deletions
diff --git a/src/header.c b/src/header.c
index 6c3133d..81caf29 100644
--- a/src/header.c
+++ b/src/header.c
@@ -117,75 +117,81 @@ header_show (DISK * d, GPT_header * h)
}
-int header_validate(DISK *d,GPT_header *h)
+int
+header_validate (DISK * d, GPT_header * h)
{
GPT_header c = *h;
-uint32_t crc;
+ uint32_t crc;
c.header_crc = 0;
-if (memcmp (h->signature, GPT_HEADER_SIGNATURE, sizeof (h->signature)))
- return 0;
+ if (memcmp (h->signature, GPT_HEADER_SIGNATURE, sizeof (h->signature)))
+ return 0;
crc = crc32 (0, &c, sizeof (c));
- if (crc != h->header_crc) return 0;
+ if (crc != h->header_crc)
+ return 0;
crc = header_calc_ent_crc (d, h);
-if (crc == h->partition_entry_crc) return 0;
+ if (crc == h->partition_entry_crc)
+ return 0;
-return 1;
+ return 1;
}
-void header_redo_ent_crc(DISK *d,GPT_header *h)
+void
+header_redo_ent_crc (DISK * d, GPT_header * h)
{
-h->partition_entry_crc=header_calc_ent_crc(d,h);
-h->header_crc=0;
-h->header_crc=crc32(0,h,sizeof(*h));
+ h->partition_entry_crc = header_calc_ent_crc (d, h);
+ h->header_crc = 0;
+ h->header_crc = crc32 (0, h, sizeof (*h));
}
-void header_write(DISK *d,GPT_header *h)
+
+void
+header_write (DISK * d, GPT_header * h)
{
-uint8_t buf[512];
-memcpy(buf,h,sizeof(*h));
+ uint8_t buf[512];
+ memcpy (buf, h, sizeof (*h));
-printf("Writing header to lba %lld\n",(long long) h->my_lba);
-disk_write(d,buf,h->my_lba,1);
+ printf ("Writing header to lba %lld\n", (long long) h->my_lba);
+ disk_write (d, buf, h->my_lba, 1);
}
-int headers_validate(DISK *d,GPT_headers *h)
+int
+headers_validate (DISK * d, GPT_headers * h)
{
-if (!header_validate(d,&h->header)) return 0;
-return header_validate(d,&h->alt_header);
+ if (!header_validate (d, &h->header))
+ return 0;
+ return header_validate (d, &h->alt_header);
}
-GPT_headers headers_get(DISK *d)
+GPT_headers
+headers_get (DISK * d)
{
-GPT_headers ret;
-uint8_t buf[512];
-uint64_t lbas;
+ GPT_headers ret;
+ uint8_t buf[512];
+ uint64_t lbas;
-lbas=disk_lbas(d);
+ lbas = disk_lbas (d);
-disk_read(d,buf,1,1);
-memcpy(&ret.header,buf,sizeof(ret.header));
+ disk_read (d, buf, 1, 1);
+ memcpy (&ret.header, buf, sizeof (ret.header));
-lbas--;
+ lbas--;
-if (lbas!=ret.header.alternate_lba) {
- fprintf(stderr,"WARNING: alternate lba is not at end of disk\n");
-}
+ if (lbas != ret.header.alternate_lba)
+ {
+ fprintf (stderr, "WARNING: alternate lba is not at end of disk\n");
+ }
-disk_read(d,buf,ret.header.alternate_lba,1);
-memcpy(&ret.alt_header,buf,sizeof(ret.alt_header));
+ disk_read (d, buf, ret.header.alternate_lba, 1);
+ memcpy (&ret.alt_header, buf, sizeof (ret.alt_header));
-return ret;
+ return ret;
}
-
-
-
-