Changeset View
Changeset View
Standalone View
Standalone View
head/sys/boot/common/part.c
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | static struct parttypes { | ||||
{ PART_LINUX, "Linux" }, | { PART_LINUX, "Linux" }, | ||||
{ PART_LINUX_SWAP, "Linux swap" }, | { PART_LINUX_SWAP, "Linux swap" }, | ||||
{ PART_DOS, "DOS/Windows" }, | { PART_DOS, "DOS/Windows" }, | ||||
}; | }; | ||||
const char * | const char * | ||||
parttype2str(enum partition_type type) | parttype2str(enum partition_type type) | ||||
{ | { | ||||
int i; | size_t i; | ||||
for (i = 0; i < sizeof(ptypes) / sizeof(ptypes[0]); i++) | for (i = 0; i < sizeof(ptypes) / sizeof(ptypes[0]); i++) | ||||
if (ptypes[i].type == type) | if (ptypes[i].type == type) | ||||
return (ptypes[i].desc); | return (ptypes[i].desc); | ||||
return (ptypes[0].desc); | return (ptypes[0].desc); | ||||
} | } | ||||
#ifdef LOADER_GPT_SUPPORT | #ifdef LOADER_GPT_SUPPORT | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, uint64_t lba_last, | ||||
return (hdr); | return (hdr); | ||||
} | } | ||||
static int | static int | ||||
gpt_checktbl(const struct gpt_hdr *hdr, u_char *tbl, size_t size, | gpt_checktbl(const struct gpt_hdr *hdr, u_char *tbl, size_t size, | ||||
uint64_t lba_last) | uint64_t lba_last) | ||||
{ | { | ||||
struct gpt_ent *ent; | struct gpt_ent *ent; | ||||
int i, cnt; | uint32_t i, cnt; | ||||
cnt = size / hdr->hdr_entsz; | cnt = size / hdr->hdr_entsz; | ||||
if (hdr->hdr_entries <= cnt) { | if (hdr->hdr_entries <= cnt) { | ||||
cnt = hdr->hdr_entries; | cnt = hdr->hdr_entries; | ||||
/* Check CRC only when buffer size is enough for table. */ | /* Check CRC only when buffer size is enough for table. */ | ||||
if (hdr->hdr_crc_table != | if (hdr->hdr_crc_table != | ||||
crc32(tbl, hdr->hdr_entries * hdr->hdr_entsz)) { | crc32(tbl, hdr->hdr_entries * hdr->hdr_entsz)) { | ||||
DEBUG("GPT table's CRC doesn't match"); | DEBUG("GPT table's CRC doesn't match"); | ||||
Show All 14 Lines | |||||
static struct ptable* | static struct ptable* | ||||
ptable_gptread(struct ptable *table, void *dev, diskread_t dread) | ptable_gptread(struct ptable *table, void *dev, diskread_t dread) | ||||
{ | { | ||||
struct pentry *entry; | struct pentry *entry; | ||||
struct gpt_hdr *phdr, hdr; | struct gpt_hdr *phdr, hdr; | ||||
struct gpt_ent *ent; | struct gpt_ent *ent; | ||||
u_char *buf, *tbl; | u_char *buf, *tbl; | ||||
uint64_t offset; | uint64_t offset; | ||||
int pri, sec, i; | int pri, sec; | ||||
size_t size; | size_t size, i; | ||||
buf = malloc(table->sectorsize); | buf = malloc(table->sectorsize); | ||||
if (buf == NULL) | if (buf == NULL) | ||||
return (NULL); | return (NULL); | ||||
tbl = malloc(table->sectorsize * MAXTBLSZ); | tbl = malloc(table->sectorsize * MAXTBLSZ); | ||||
if (tbl == NULL) { | if (tbl == NULL) { | ||||
free(buf); | free(buf); | ||||
return (NULL); | return (NULL); | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | mbr_parttype(uint8_t type) | ||||
case 0x0b: | case 0x0b: | ||||
case 0x0c: | case 0x0c: | ||||
case 0x0e: | case 0x0e: | ||||
return (PART_DOS); | return (PART_DOS); | ||||
} | } | ||||
return (PART_UNKNOWN); | return (PART_UNKNOWN); | ||||
} | } | ||||
struct ptable* | static struct ptable* | ||||
ptable_ebrread(struct ptable *table, void *dev, diskread_t dread) | ptable_ebrread(struct ptable *table, void *dev, diskread_t dread) | ||||
{ | { | ||||
struct dos_partition *dp; | struct dos_partition *dp; | ||||
struct pentry *e1, *entry; | struct pentry *e1, *entry; | ||||
uint32_t start, end, offset; | uint32_t start, end, offset; | ||||
u_char *buf; | u_char *buf; | ||||
int i, index; | int i, index; | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | bsd_parttype(uint8_t type) | ||||
case FS_VINUM: | case FS_VINUM: | ||||
return (PART_FREEBSD_VINUM); | return (PART_FREEBSD_VINUM); | ||||
case FS_ZFS: | case FS_ZFS: | ||||
return (PART_FREEBSD_ZFS); | return (PART_FREEBSD_ZFS); | ||||
} | } | ||||
return (PART_UNKNOWN); | return (PART_UNKNOWN); | ||||
} | } | ||||
struct ptable* | static struct ptable* | ||||
ptable_bsdread(struct ptable *table, void *dev, diskread_t dread) | ptable_bsdread(struct ptable *table, void *dev, diskread_t dread) | ||||
{ | { | ||||
struct disklabel *dl; | struct disklabel *dl; | ||||
struct partition *part; | struct partition *part; | ||||
struct pentry *entry; | struct pentry *entry; | ||||
u_char *buf; | u_char *buf; | ||||
uint32_t raw_offset; | uint32_t raw_offset; | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 414 Lines • Show Last 20 Lines |