[975e7e9] | 1 | /*
|
---|
[3faa03d] | 2 | * Copyright (c) 2015 Jiri Svoboda
|
---|
[975e7e9] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup bd
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[3faa03d] | 35 | #ifndef LIBLABEL_STD_GPT_H_
|
---|
| 36 | #define LIBLABEL_STD_GPT_H_
|
---|
[975e7e9] | 37 |
|
---|
[8d2dd7f2] | 38 | #include <stdint.h>
|
---|
[975e7e9] | 39 |
|
---|
[603c1d1f] | 40 | enum {
|
---|
| 41 | /** Block address of primary GPT header. */
|
---|
| 42 | gpt_hdr_ba = 1,
|
---|
| 43 |
|
---|
| 44 | /** Minimum size of partition table in bytes, required by std. */
|
---|
| 45 | gpt_ptable_min_size = 16384,
|
---|
| 46 |
|
---|
| 47 | /** GPT revision */
|
---|
| 48 | gpt_revision = 0x00010000
|
---|
| 49 | };
|
---|
[975e7e9] | 50 |
|
---|
| 51 | /** GPT header */
|
---|
| 52 | typedef struct {
|
---|
| 53 | uint8_t efi_signature[8];
|
---|
| 54 | uint32_t revision;
|
---|
| 55 | uint32_t header_size;
|
---|
| 56 | uint32_t header_crc32;
|
---|
| 57 | uint32_t reserved;
|
---|
| 58 | uint64_t my_lba;
|
---|
| 59 | uint64_t alternate_lba;
|
---|
| 60 | uint64_t first_usable_lba;
|
---|
| 61 | uint64_t last_usable_lba;
|
---|
| 62 | uint8_t disk_guid[16];
|
---|
| 63 | uint64_t entry_lba;
|
---|
| 64 | uint32_t num_entries;
|
---|
| 65 | uint32_t entry_size;
|
---|
| 66 | uint32_t pe_array_crc32;
|
---|
| 67 | } __attribute__((packed)) gpt_header_t;
|
---|
| 68 |
|
---|
| 69 | /** GPT partition entry */
|
---|
| 70 | typedef struct {
|
---|
| 71 | uint8_t part_type[16];
|
---|
| 72 | uint8_t part_id[16];
|
---|
| 73 | uint64_t start_lba;
|
---|
| 74 | uint64_t end_lba;
|
---|
| 75 | uint64_t attributes;
|
---|
| 76 | uint16_t part_name[36];
|
---|
| 77 | } __attribute__((packed)) gpt_entry_t;
|
---|
| 78 |
|
---|
[f57ccb5] | 79 | /** Microsoft Basic Data Partition */
|
---|
| 80 | #define GPT_MS_BASIC_DATA "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"
|
---|
| 81 | /** Linux Filesystem Data */
|
---|
| 82 | #define GPT_LINUX_FS_DATA "0FC63DAF-8483-4772-8E79-3D69D8477DE4"
|
---|
| 83 | /** I could not find any definition of Minix GUID partition type.
|
---|
| 84 | * This is a randomly generated UUID */
|
---|
| 85 | #define GPT_MINIX_FAKE "8308e350-4e2d-46c7-8e3b-24b07e8ac674"
|
---|
| 86 |
|
---|
[975e7e9] | 87 | #endif
|
---|
| 88 |
|
---|
| 89 | /** @}
|
---|
| 90 | */
|
---|