aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/disk.c1
-rw-r--r--src/dump.c10
-rw-r--r--src/fixup.c14
-rw-r--r--src/gpt.c27
-rw-r--r--src/guid.c2
-rw-r--r--src/prototypes.h87
-rw-r--r--src/set_flag.c29
-rw-r--r--src/sync.c5
8 files changed, 108 insertions, 67 deletions
diff --git a/src/disk.c b/src/disk.c
index b9db2fe..b6bf854 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -51,6 +51,7 @@ disk_read (DISK * d, void *buf, uint64_t lba, int lbas)
// abort ();
}
}
+
void
disk_write (DISK * d, void *buf, uint64_t lba, int lbas)
{
diff --git a/src/dump.c b/src/dump.c
index fa9e02c..5426e8c 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -1,7 +1,8 @@
#include "project.h"
-void dump_out(DISK *d)
+void
+dump_out (DISK * d)
{
GPT_headers h;
int i;
@@ -15,14 +16,13 @@ void dump_out(DISK *d)
if (!entry_empty (&e))
{
- utf16_to_ascii (e.name, sizeof (e.name), name, sizeof (name));
+ utf16_to_ascii (e.name, sizeof (e.name), name, sizeof (name));
- printf("gpt -d ${DISK} -a %d \"%s\" \"%s\" %lld %lld\n",
- i,name,guid_to_a_simple (e.type),e.start,e.end);
+ printf ("gpt -d ${DISK} -a %d \"%s\" \"%s\" %lld %lld\n",
+ i, name, guid_to_a_simple (e.type), e.start, e.end);
}
}
}
-
diff --git a/src/fixup.c b/src/fixup.c
index af7b6d6..8b3116d 100644
--- a/src/fixup.c
+++ b/src/fixup.c
@@ -3,15 +3,15 @@
int
-fixup (DISK * d)
+fixup (DISK * d)
{
GPT_headers h;
- int i;
+ int i;
h = headers_get_one (d);
-
+
for (i = 0; i < h.header.n_partition_entries; ++i)
{
@@ -20,13 +20,13 @@ fixup (DISK * d)
GPT_entry e = entry_read (d, &h.header, i);
- entry_write (d, &h.header, i, &e);
+ entry_write (d, &h.header, i, &e);
- entry_write (d, &h.alt_header, i, &e);
+ entry_write (d, &h.alt_header, i, &e);
}
- header_redo_ent_crc (d, &h.header);
+ header_redo_ent_crc (d, &h.header);
header_write (d, &h.header);
header_redo_ent_crc (d, &h.alt_header);
@@ -34,5 +34,5 @@ fixup (DISK * d)
- return 0;
+ return 0;
}
diff --git a/src/gpt.c b/src/gpt.c
index f13047e..d72744b 100644
--- a/src/gpt.c
+++ b/src/gpt.c
@@ -6,10 +6,13 @@
*
*/
-static char rcsid[] = "$Id: gpt.c,v 1.24 2013/09/14 08:54:25 james Exp $";
+static char rcsid[] = "$Id: gpt.c,v 1.25 2013/09/14 08:56:36 james Exp $";
/*
* $Log: gpt.c,v $
+ * Revision 1.25 2013/09/14 08:56:36 james
+ * *** empty log message ***
+ *
* Revision 1.24 2013/09/14 08:54:25 james
* add lvm, raid, new ext3 to sync
*
@@ -151,7 +154,7 @@ main (int argc, char *argv[])
if (n)
n = header_check_crc (d, &h.header);
}
- printf("%d\n",n);
+ printf ("%d\n", n);
return n ? 0 : -1;
case 'd':
@@ -187,14 +190,14 @@ main (int argc, char *argv[])
e = entry_read (d, &h.header, n);
printf ("%lld\n", e.end);
return 0;
- case 'b':
+ case 'b':
n = atoi (optarg);
- set_flag (d, n,0);
- return 0;
- case 'B':
+ set_flag (d, n, 0);
+ return 0;
+ case 'B':
n = atoi (optarg);
- set_flag (d, n,1);
- return 0;
+ set_flag (d, n, 1);
+ return 0;
case 'g':
h = headers_get (d);
n = atoi (optarg);
@@ -208,10 +211,10 @@ main (int argc, char *argv[])
disk_reread_kernel_table (d);
return 0;
case 'Q':
- if (!d)
- usage();
- dump_out(d);
- return 0;
+ if (!d)
+ usage ();
+ dump_out (d);
+ return 0;
case 'n':
if (!d)
usage ();
diff --git a/src/guid.c b/src/guid.c
index 1e7192b..50122b3 100644
--- a/src/guid.c
+++ b/src/guid.c
@@ -84,7 +84,7 @@ guid_to_a_simple (GUID g)
if (!guid_cmp (&g, &ptr->g))
{
strcpy (ret, ptr->name);
- return ret;
+ return ret;
}
ptr++;
}
diff --git a/src/prototypes.h b/src/prototypes.h
index 64545b5..796902f 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -1,54 +1,61 @@
/* gpt.c */
-void usage(void);
-int main(int argc, char *argv[]);
+void usage (void);
+int main (int argc, char *argv[]);
/* version.c */
-char *get_version(void);
+char *get_version (void);
/* util.c */
-void hexdump(FILE *f, uint8_t *data, int s, int l);
-void utf16_to_ascii(void *_u16, int u16_len, void *_u8, int u8_len);
-void ascii_to_utf16(void *_u8, int u8_len, void *_u16, int u16_len);
+void hexdump (FILE * f, uint8_t * data, int s, int l);
+void utf16_to_ascii (void *_u16, int u16_len, void *_u8, int u8_len);
+void ascii_to_utf16 (void *_u8, int u8_len, void *_u16, int u16_len);
/* guid.c */
-int guid_cmp(GUID *a, GUID *b);
-char *guid_to_a(GUID g);
-int a_to_guid(char *a, GUID *g);
-GUID guid_random(void);
+int guid_cmp (GUID * a, GUID * b);
+char *guid_to_a (GUID g);
+char *guid_to_a_simple (GUID g);
+int a_to_guid (char *a, GUID * g);
+GUID guid_random (void);
/* crc.c */
-uint32_t crc32(uint32_t crc, const void *_buf, int len);
+uint32_t crc32 (uint32_t crc, const void *_buf, int len);
/* header.c */
-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);
-void header_write(DISK *d, GPT_header *h);
-int headers_validate(DISK *d, GPT_headers *h);
-GPT_headers headers_get(DISK *d);
-GPT_headers headers_get_one(DISK *d);
+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);
+void header_write (DISK * d, GPT_header * h);
+int headers_validate (DISK * d, GPT_headers * h);
+GPT_headers headers_get (DISK * d);
+GPT_headers headers_get_one (DISK * d);
/* disk.c */
-DISK *disk_open(char *fn);
-void disk_read(DISK *d, void *buf, uint64_t lba, int lbas);
-void disk_write(DISK *d, void *buf, uint64_t lba, int lbas);
-uint64_t disk_lbas(DISK *d);
-int disk_reread_kernel_table(DISK *d);
+DISK *disk_open (char *fn);
+void disk_read (DISK * d, void *buf, uint64_t lba, int lbas);
+void disk_write (DISK * d, void *buf, uint64_t lba, int lbas);
+uint64_t disk_lbas (DISK * d);
+int disk_reread_kernel_table (DISK * d);
/* pmbr.c */
-void mbr_entry_show(MBR_entry *e);
-void mbr_show(MBR *m);
-MBR mbr_new(uint64_t lbas);
-void mbr_entry_from_gpt_entry(MBR_entry *m, GPT_header *h, GPT_entry *g, int bootable, uint8_t type);
+void mbr_entry_show (MBR_entry * e);
+void mbr_show (MBR * m);
+MBR mbr_new (uint64_t lbas);
+void mbr_entry_from_gpt_entry (MBR_entry * m, GPT_header * h, GPT_entry * g,
+ int bootable, uint8_t type);
/* show.c */
-void show(DISK *d);
+void show (DISK * d);
/* entry.c */
-void entry_write(DISK *d, GPT_header *h, int n, GPT_entry *e);
-GPT_entry entry_read(DISK *d, GPT_header *h, int n);
-int entry_empty(GPT_entry *e);
-void entry_show(GPT_entry *e);
+void entry_write (DISK * d, GPT_header * h, int n, GPT_entry * e);
+GPT_entry entry_read (DISK * d, GPT_header * h, int n);
+int entry_empty (GPT_entry * e);
+void entry_show (GPT_entry * e);
/* new.c */
-void new(DISK *d);
+void new (DISK * d);
/* modify.c */
-int modify(DISK *d, int n, char *name, char *type_guid, uint64_t start, uint64_t end, char *part_guid);
+int modify (DISK * d, int n, char *name, char *type_guid, uint64_t start,
+ uint64_t end, char *part_guid);
/* sync.c */
-void sync_tables(DISK *d);
+void sync_tables (DISK * d);
/* fixup.c */
-int fixup(DISK *d);
+int fixup (DISK * d);
+/* dump.c */
+void dump_out (DISK * d);
+/* set_flag.c */
+int set_flag (DISK * d, int n, int f);
diff --git a/src/set_flag.c b/src/set_flag.c
new file mode 100644
index 0000000..f28c67e
--- /dev/null
+++ b/src/set_flag.c
@@ -0,0 +1,29 @@
+#include "project.h"
+
+
+
+int
+set_flag (DISK * d, int n, int f)
+{
+ GPT_headers h;
+ GPT_entry e = { 0 };
+
+ h = headers_get (d);
+
+ e = entry_read (d, &h.header, n);
+
+
+ e.flags = f;
+ entry_show (&e);
+
+/*Odd order because efi says so*/
+
+ entry_write (d, &h.header, n, &e);
+ header_redo_ent_crc (d, &h.header);
+ header_write (d, &h.header);
+
+ entry_write (d, &h.alt_header, n, &e);
+ header_redo_ent_crc (d, &h.alt_header);
+ header_write (d, &h.alt_header);
+ return 0;
+}
diff --git a/src/sync.c b/src/sync.c
index 0aee0a6..8eafd1c 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -15,7 +15,7 @@ sync_tables (DISK * d)
GUID guid_swap = GUID_TYPE_LINUX_SWAP;
GUID guid_hfs = GUID_TYPE_APPLE_HFS;
GUID guid_efi = GUID_TYPE_SYSTEM;
- GUID guid_new_ext3= GUID_TYPE_NEW_LINUX_EXT3;
+ GUID guid_new_ext3 = GUID_TYPE_NEW_LINUX_EXT3;
GUID guid_raid = GUID_TYPE_LINUX_RAID;
GUID guid_lvm = GUID_TYPE_LINUX_LVM;
int mbr_entry = 0;
@@ -41,7 +41,8 @@ sync_tables (DISK * d)
{
type = MBR_PARTITION_TYPE_EFI;
}
- else if (!guid_cmp (&e.type, &guid_ext3) || !guid_cmp (&e.type, &guid_new_ext3))
+ else if (!guid_cmp (&e.type, &guid_ext3)
+ || !guid_cmp (&e.type, &guid_new_ext3))
{
type = MBR_PARTITION_TYPE_LINUX;
}