2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2017 Intel Corporation.
|
2017-06-01 05:02:54 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* GPT internal Interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPDK_INTERNAL_GPT_H
|
|
|
|
#define SPDK_INTERNAL_GPT_H
|
|
|
|
|
2017-07-21 19:49:09 +00:00
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
|
2017-06-01 05:02:54 +00:00
|
|
|
#include "spdk/gpt_spec.h"
|
2023-01-13 23:13:35 +00:00
|
|
|
#include "spdk/log.h"
|
|
|
|
|
|
|
|
#define SPDK_GPT_PART_TYPE_GUID SPDK_GPT_GUID(0x6527994e, 0x2c5a, 0x4eec, 0x9613, 0x8f5944074e8b)
|
|
|
|
|
|
|
|
/* PART_TYPE_GUID_OLD partitions will be constructed as bdevs with one fewer block than expected.
|
|
|
|
* See GitHub issue #2801.
|
|
|
|
*/
|
|
|
|
#ifdef REGISTER_GUID_DEPRECATION
|
|
|
|
/* Register the deprecation in the header file, to make it clear to readers that this GUID
|
|
|
|
* shouldn't be used for new SPDK GPT partitions. We will never actually log this deprecation
|
|
|
|
* though, since we are not recommending that users try to migrate existing partitions with the
|
|
|
|
* old GUID to the new GUID. Wrap it in this REGISTER_GUID_DEPRECATION flag to avoid defining
|
|
|
|
* this deprecation in multiple compilation units.
|
|
|
|
*/
|
|
|
|
SPDK_LOG_DEPRECATION_REGISTER(old_gpt_guid, "old gpt guid", "Never", 0)
|
|
|
|
#endif
|
|
|
|
#define SPDK_GPT_PART_TYPE_GUID_OLD SPDK_GPT_GUID(0x7c5222bd, 0x8f5d, 0x4087, 0x9c00, 0xbf9843c7b58c)
|
2017-06-01 05:02:54 +00:00
|
|
|
|
|
|
|
#define SPDK_GPT_BUFFER_SIZE 32768 /* 32KB */
|
2017-07-07 17:51:47 +00:00
|
|
|
#define SPDK_GPT_GUID_EQUAL(x,y) (memcmp(x, y, sizeof(struct spdk_gpt_guid)) == 0)
|
2017-06-01 05:02:54 +00:00
|
|
|
|
2019-01-19 06:56:14 +00:00
|
|
|
enum spdk_gpt_parse_phase {
|
|
|
|
SPDK_GPT_PARSE_PHASE_INVALID = 0,
|
|
|
|
SPDK_GPT_PARSE_PHASE_PRIMARY,
|
|
|
|
SPDK_GPT_PARSE_PHASE_SECONDARY,
|
|
|
|
};
|
|
|
|
|
2017-06-01 05:02:54 +00:00
|
|
|
struct spdk_gpt {
|
2019-01-19 06:56:14 +00:00
|
|
|
uint8_t parse_phase;
|
2017-06-01 05:02:54 +00:00
|
|
|
unsigned char *buf;
|
2017-10-23 18:59:27 +00:00
|
|
|
uint64_t buf_size;
|
2017-06-01 05:02:54 +00:00
|
|
|
uint64_t lba_start;
|
|
|
|
uint64_t lba_end;
|
|
|
|
uint64_t total_sectors;
|
|
|
|
uint32_t sector_size;
|
|
|
|
struct spdk_gpt_header *header;
|
|
|
|
struct spdk_gpt_partition_entry *partitions;
|
|
|
|
};
|
|
|
|
|
2020-05-10 07:22:54 +00:00
|
|
|
int gpt_parse_mbr(struct spdk_gpt *gpt);
|
|
|
|
int gpt_parse_partition_table(struct spdk_gpt *gpt);
|
2017-06-01 05:02:54 +00:00
|
|
|
|
|
|
|
#endif /* SPDK_INTERNAL_GPT_H */
|