summaryrefslogtreecommitdiffstats
path: root/src/partgpt.h
blob: 115b07310cc00ea26b8e7752e62b2405da3406dc (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*

    File: partgpt.h

    Copyright (C) 2007-2008 Christophe GRENIER <grenier@cgsecurity.org>

    This software is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write the Free Software Foundation, Inc., 51
    Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

 */
#ifndef _PARTGPT_H
#define	_PARTGPT_H
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_GPT)

struct gpt_hdr
{
  char		hdr_sig[8];                     /* 0x00 */
#define	GPT_HDR_SIG		"EFI PART"
  uint32_t	hdr_revision;                   /* 0x08 */
#define	GPT_HDR_REVISION	0x00010000
  uint32_t	hdr_size;                       /* 0x0c */
  uint32_t	hdr_crc_self;                   /* 0x10 */
  uint32_t	__reserved;                     /* 0x14 */
  uint64_t	hdr_lba_self;                   /* 0x18 */
  uint64_t	hdr_lba_alt;                    /* 0x20 */
  uint64_t	hdr_lba_start;                  /* 0x28 */
  uint64_t	hdr_lba_end;                    /* 0x30 */
  efi_guid_t hdr_guid;                          /* 0x38 disk GUID */
  uint64_t	hdr_lba_table;                  /* 0x48 */
  uint32_t	hdr_entries;                    /* 0x50 */
  uint32_t	hdr_entsz;                      /* 0x54 */
  uint32_t	hdr_crc_table;                  /* 0x58 */
  uint8_t 	padding[420];                   /* 0x5c */
} __attribute__ ((gcc_struct, __packed__));

struct gpt_ent
{
  efi_guid_t ent_type;
  efi_guid_t ent_uuid;
  uint64_t	ent_lba_start;
  uint64_t	ent_lba_end;
  uint64_t	ent_attr;
#define	GPT_ENT_ATTR_PLATFORM		(1ULL << 0)
  uint8_t	ent_name[72];		/* UNICODE-16 */
};

struct systypes_gtp {
  const efi_guid_t part_type;
  const char *name;
};

/*@
  @ requires valid_disk(disk_car);
  @ requires \valid_read(disk_car);
  @ requires valid_list_part(list_part);
  @ requires \valid(current_cmd);
  @ requires separation: \separated(disk_car, list_part, current_cmd, *current_cmd);
  @ requires valid_read_string(*current_cmd);
  @*/
// ensures  valid_list_part(\result);
// ensures  valid_read_string(*current_cmd);
list_part_t *add_partition_gpt_cli(const disk_t *disk_car, list_part_t *list_part, char **current_cmd);

/*@
  @ requires \valid_read(disk_car);
  @ requires valid_disk(disk_car);
  @ requires \valid(list_part);
  @ requires valid_list_part(list_part);
  @ requires separation: \separated(disk_car, list_part);
  @*/
int write_part_gpt(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose);

#endif
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
#endif /* _PARTGPT_H */