#ifndef PMDK_POOL_HDR_H
#define PMDK_POOL_HDR_H 1
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
#include "uuid.h"
#define ALIGNMENT_DESC_BITS 4
struct arch_flags {
uint64_t alignment_desc;
uint8_t machine_class;
uint8_t data;
uint8_t reserved[4];
uint16_t machine;
};
#define PMDK_MACHINE_CLASS_64 2
#define PMDK_MACHINE_X86_64 62
#define PMDK_MACHINE_AARCH64 183
#define PMDK_DATA_LE 1
#define PMDK_DATA_BE 2
#define POOL_HDR_SIG_LEN 8
struct pool_hdr {
char signature[POOL_HDR_SIG_LEN];
uint32_t major;
uint32_t compat_features;
uint32_t incompat_features;
uint32_t ro_compat_features;
uuid_t poolset_uuid;
uuid_t uuid;
uuid_t prev_part_uuid;
uuid_t next_part_uuid;
uuid_t prev_repl_uuid;
uuid_t next_repl_uuid;
uint64_t crtime;
struct arch_flags arch_flags;
unsigned char unused[3944];
uint64_t checksum;
};
#define POOL_HDR_SIZE (sizeof(struct pool_hdr))
#define POOL_DESC_SIZE 4096
void util_convert2le_hdr(struct pool_hdr *hdrp);
void util_convert2h_hdr_nocheck(struct pool_hdr *hdrp);
int util_convert_hdr(struct pool_hdr *hdrp);
int util_convert_hdr_remote(struct pool_hdr *hdrp);
void util_get_arch_flags(struct arch_flags *arch_flags);
int util_check_arch_flags(const struct arch_flags *arch_flags);
int util_feature_check(struct pool_hdr *hdrp, uint32_t incompat,
uint32_t ro_compat, uint32_t compat);
#define DESC_MASK ((1 << ALIGNMENT_DESC_BITS) - 1)
#define alignment_of(t) offsetof(struct { char c; t x; }, x)
#define alignment_desc_of(t) (((uint64_t)alignment_of(t) - 1) & DESC_MASK)
#define alignment_desc()\
(alignment_desc_of(char) << 0 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(short) << 1 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(int) << 2 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(long) << 3 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(long long) << 4 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(size_t) << 5 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(off_t) << 6 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(float) << 7 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(double) << 8 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(long double) << 9 * ALIGNMENT_DESC_BITS) |\
(alignment_desc_of(void *) << 10 * ALIGNMENT_DESC_BITS)
#define POOL_FEAT_NOHDRS 0x0001
#endif