aboutsummaryrefslogtreecommitdiffstats
path: root/src/new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/new.c')
-rw-r--r--src/new.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/src/new.c b/src/new.c
index d8c177f..2d603ff 100644
--- a/src/new.c
+++ b/src/new.c
@@ -3,45 +3,46 @@
-void new(DISK *d)
+void
+new (DISK * d)
{
-uint8_t buf[SECTOR_SIZE];
+ uint8_t buf[SECTOR_SIZE];
-MBR m;
-GPT_header h,alt_h;
-GPT_entry e={0};
-GUID disk_guid;
-uint64_t lbas;
-int n;
+ MBR m;
+ GPT_header h, alt_h;
+ GPT_entry e = { 0 };
+ GUID disk_guid;
+ uint64_t lbas;
+ int n;
-lbas=disk_lbas(d);
+ lbas = disk_lbas (d);
-disk_guid=guid_random();
+ disk_guid = guid_random ();
-m=mbr_new(lbas);
-memcpy(buf,&m,sizeof(m));
-disk_write(d,buf,0,1);
+ m = mbr_new (lbas);
+ memcpy (buf, &m, sizeof (m));
+ disk_write (d, buf, 0, 1);
-h=header_new ( disk_guid, lbas,0);
-alt_h=header_new(disk_guid,lbas,1);
+ h = header_new (disk_guid, lbas, 0);
+ alt_h = header_new (disk_guid, lbas, 1);
-for (n=0;n<h.n_partition_entries;++n) {
-entry_write(d,&h,n,&e);
-entry_write(d,&alt_h,n,&e);
-}
+ for (n = 0; n < h.n_partition_entries; ++n)
+ {
+ entry_write (d, &h, n, &e);
+ entry_write (d, &alt_h, n, &e);
+ }
-h.partition_entry_crc=header_calc_ent_crc(d,&h);
-alt_h.partition_entry_crc=header_calc_ent_crc(d,&alt_h);
+ h.partition_entry_crc = header_calc_ent_crc (d, &h);
+ alt_h.partition_entry_crc = header_calc_ent_crc (d, &alt_h);
-header_calc_crc(&h);
-header_calc_crc(&alt_h);
+ header_calc_crc (&h);
+ header_calc_crc (&alt_h);
-memcpy(buf,&h,sizeof(h));
-disk_write(d,buf,h.my_lba,1);
+ memcpy (buf, &h, sizeof (h));
+ disk_write (d, buf, h.my_lba, 1);
-memcpy(buf,&alt_h,sizeof(alt_h));
-disk_write(d,buf,alt_h.my_lba,1);
+ memcpy (buf, &alt_h, sizeof (alt_h));
+ disk_write (d, buf, alt_h.my_lba, 1);
}
-