fce85dd7 |
/* |
e1cbc270 |
* Copyright (C) 2014-2019 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
fce85dd7 |
*
* Authors: Kevin Lin <klin@sourcefire.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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 to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef __GPT_H
#define __GPT_H
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
|
e030ba4f |
#include "clamav-types.h" |
fce85dd7 |
#include "others.h"
/* GPT sector size is normally 512 bytes be can be set to much larger
* values. Sector size for GPT can be found by the offset the GPT header
* signature is located (marking the beginning of the second sector.
*/ |
08fef61f |
#define GPT_SIGNATURE 0x4546492050415254ULL |
00acb79c |
#define GPT_SIGNATURE_STR "EFI PART" |
fce85dd7 |
#define GPT_PRIMARY_HDR_LBA 1
#define GPT_HDR_RESERVED 0
#ifndef HAVE_ATTRIB_PACKED
#define __attribute__(x)
#endif
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack 1
#endif
/* 92-byte gpt_header, these are little endian */
struct gpt_header { |
288057e9 |
uint64_t signature __attribute__((packed));
uint32_t revision __attribute__((packed));
uint32_t headerSize __attribute__((packed)); /* should be 92 bytes */
uint32_t headerCRC32 __attribute__((packed));
uint32_t reserved __attribute__((packed)); /* this MUST be zero */ |
fce85dd7 |
/* LBA values should be 1 and the last sector index */ |
288057e9 |
uint64_t currentLBA __attribute__((packed));
uint64_t backupLBA __attribute__((packed)); |
fce85dd7 |
/* data not including the gpt_header and partition table */ |
288057e9 |
uint64_t firstUsableLBA __attribute__((packed));
uint64_t lastUsableLBA __attribute__((packed)); |
fce85dd7 |
uint8_t DiskGUID[16];
/* partition table information */ |
288057e9 |
uint64_t tableStartLBA __attribute__((packed));
uint32_t tableNumEntries __attribute__((packed));
uint32_t tableEntrySize __attribute__((packed));
uint32_t tableCRC32 __attribute__((packed)); |
fce85dd7 |
/* zeroes fill remainder of sector (420 bytes in 512 sector size) */
};
/* 128-byte partition entry, part of an array of 128+ entries, in little_endian */
struct gpt_partition_entry {
uint8_t typeGUID[16];
uint8_t uniqueGUID[16]; |
288057e9 |
uint64_t firstLBA __attribute__((packed));
uint64_t lastLBA __attribute__((packed));
uint64_t attributes __attribute__((packed));
uint16_t name[36] __attribute__((packed)); |
fce85dd7 |
};
#ifdef HAVE_PRAGMA_PACK
#pragma pack()
#endif
#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack
#endif
|
00acb79c |
size_t gpt_detect_size(fmap_t *map);
int cli_scangpt(cli_ctx *ctx, size_t sectorsize); |
fce85dd7 |
#endif |