aboutsummaryrefslogtreecommitdiffstats
path: root/src/modify.c
blob: 3632ec7b0badb93ad1b267577a8e3aab14353471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "project.h"



int
modify (DISK * d, int n, char *name, char *type_guid, uint64_t start,
        uint64_t end)
{
  GPT_headers h;
  GPT_entry e = { 0 };

  h = headers_get (d);

  if (a_to_guid (type_guid, &e.type))
    {
      fprintf (stderr, "GUID type %s was not parsed\n", type_guid);
      exit (1);
    }
  printf ("guid=%s became=%s\n", type_guid, guid_to_a (e.type));
  e.label = guid_random ();
  e.start = start;
  e.end = end;


  ascii_to_utf16 (name, -1, e.name, sizeof (e.name));


  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;
}