Changeset View
Changeset View
Standalone View
Standalone View
stand/common/part.c
Context not available. | |||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/vtoc.h> | #include <sys/vtoc.h> | ||||
#include <fs/cd9660/iso.h> | |||||
#include <crc32.h> | #include <crc32.h> | ||||
#include <part.h> | #include <part.h> | ||||
#include <uuid.h> | #include <uuid.h> | ||||
Context not available. | |||||
{ PART_LINUX, "Linux" }, | { PART_LINUX, "Linux" }, | ||||
{ PART_LINUX_SWAP, "Linux swap" }, | { PART_LINUX_SWAP, "Linux swap" }, | ||||
{ PART_DOS, "DOS/Windows" }, | { PART_DOS, "DOS/Windows" }, | ||||
{ PART_ISO9660, "ISO9660" }, | |||||
}; | }; | ||||
const char * | const char * | ||||
Context not available. | |||||
} | } | ||||
#endif /* LOADER_VTOC8_SUPPORT */ | #endif /* LOADER_VTOC8_SUPPORT */ | ||||
#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / table->sectorsize) | |||||
static struct ptable * | |||||
ptable_iso9660read(struct ptable *table, void *dev, diskread_t dread) | |||||
{ | |||||
uint8_t *buf; | |||||
struct iso_primary_descriptor *vd; | |||||
struct pentry *entry; | |||||
buf = malloc(table->sectorsize); | |||||
if (buf == NULL) | |||||
return (table); | |||||
if (dread(dev, buf, 1, cdb2devb(16)) != 0) { | |||||
DEBUG("read failed"); | |||||
ptable_close(table); | |||||
table = NULL; | |||||
goto out; | |||||
} | |||||
vd = (struct iso_primary_descriptor *)buf; | |||||
if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) | |||||
goto out; | |||||
entry = malloc(sizeof(*entry)); | |||||
if (entry == NULL) | |||||
goto out; | |||||
entry->part.start = 0; | |||||
entry->part.end = table->sectors; | |||||
entry->part.type = PART_ISO9660; | |||||
entry->part.index = 0; | |||||
STAILQ_INSERT_TAIL(&table->entries, entry, entry); | |||||
table->type = PTABLE_ISO9660; | |||||
out: | |||||
free(buf); | |||||
return (table); | |||||
} | |||||
struct ptable * | struct ptable * | ||||
ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, | ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, | ||||
diskread_t *dread) | diskread_t *dread) | ||||
Context not available. | |||||
table->type = PTABLE_NONE; | table->type = PTABLE_NONE; | ||||
STAILQ_INIT(&table->entries); | STAILQ_INIT(&table->entries); | ||||
if (ptable_iso9660read(table, dev, dread) != NULL) { | |||||
if (table->type == PTABLE_ISO9660) | |||||
goto out; | |||||
} | |||||
#ifdef LOADER_VTOC8_SUPPORT | #ifdef LOADER_VTOC8_SUPPORT | ||||
if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { | if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { | ||||
if (ptable_vtoc8read(table, dev, dread) == NULL) { | if (ptable_vtoc8read(table, dev, dread) == NULL) { | ||||
Context not available. |