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
41
42
43
44
45
46
47
|
#include "project.h"
void
entry_write (DISK * d, GPT_header * h, int n, GPT_entry * e)
{
uint8_t buf[SECTOR_SIZE];
uint64_t lba = GPT_ENTRY_LBA (h, n);
disk_read (d, buf, lba, 1);
memcpy (&buf[GPT_ENTRY_OFFSET (h, n)], e, sizeof (*e));
disk_write (d, buf, lba, 1);
}
GPT_entry
entry_read (DISK * d, GPT_header * h, int n)
{
uint8_t buf[SECTOR_SIZE];
GPT_entry e;
disk_read (d, buf, GPT_ENTRY_LBA (h, n), 1);
memcpy (&e, &buf[GPT_ENTRY_OFFSET (h, n)], sizeof (e));
return e;
}
int
entry_empty (GPT_entry * e)
{
GUID empty = GUID_TYPE_EMPTY;
return !guid_cmp (&e->type, &empty);
}
void
entry_show (GPT_entry * e)
{
char name[sizeof (e->name) + 1];
utf16_to_ascii (e->name, sizeof (e->name), name, sizeof (name));
printf (" Name %s\n", name);
printf (" Flags %16x Label %s\n", (int) e->flags,
guid_to_a (e->label));
printf (" Start %10lld End %10lld Type %s\n", (long long) e->start,
(long long) e->end, guid_to_a (e->type));
}
|