diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-25 23:43:21 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-25 23:43:21 +0000 |
commit | eafb7020b9a54c63dd1305c97ed2e2806fb889d0 (patch) | |
tree | 489ad44a2deb1dbad10e18384c012d634e9995fb /sbin/pdisk/dump.c | |
parent | f328a01c230196112e7fbd3ce504abc1d910fa07 (diff) |
Use new read/write_block0 and read/write_dpme which handle any
endian or alignment issues forcefully. Removes need for convert_*
functions so unhook convert.c from build. read/write_block become
static functions inside file_media.c.
Tweak struct block0 to stop trying to handle alignment issues by clever
declaration. Rely on the new functions to accurately translate between
on-disk and in-memory layouts.
Enables pdisk to work on amd64 and likely other architectures if
it's ever desirable. Does bring back DEV_BSIZE to pdisk.c since the
in-memory structure will *not* be 512 bytes on other archs.
Diffstat (limited to 'sbin/pdisk/dump.c')
-rw-r--r-- | sbin/pdisk/dump.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c index 58aa072768a..1b5ee4d4585 100644 --- a/sbin/pdisk/dump.c +++ b/sbin/pdisk/dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.c,v 1.52 2016/01/25 21:51:23 krw Exp $ */ +/* $OpenBSD: dump.c,v 1.53 2016/01/25 23:43:20 krw Exp $ */ /* * dump.c - dumping partition maps @@ -61,11 +61,10 @@ dump_block_zero(struct partition_map_header *map) printf("\nDevice block size=%u, Number of Blocks=%u (%1.1f%c)\n", p->sbBlkSize, p->sbBlkCount, value, prefix); - printf("DeviceType=0x%x, DeviceId=0x%x\n", - p->sbDevType, p->sbDevId); + printf("DeviceType=0x%x, DeviceId=0x%x\n", p->sbDevType, p->sbDevId); if (p->sbDrvrCount > 0) { printf("Drivers-\n"); - m = (struct ddmap *)p->sbMap; + m = p->sbDDMap; for (i = 0; i < p->sbDrvrCount; i++) { printf("%d: %3u @ %u, ", i + 1, m[i].ddSize, m[i].ddBlock); @@ -202,7 +201,7 @@ show_data_structures(struct partition_map_header *map) } else { printf("%u driver%s-\n", zp->sbDrvrCount, (zp->sbDrvrCount > 1) ? "s" : ""); - m = (struct ddmap *)zp->sbMap; + m = zp->sbDDMap; for (i = 0; i < zp->sbDrvrCount; i++) { printf("%u: @ %u for %u, type=0x%x\n", i + 1, m[i].ddBlock, m[i].ddSize, m[i].ddType); @@ -243,8 +242,8 @@ show_data_structures(struct partition_map_header *map) printf("%2ld: ", entry->disk_address); printf("%7u ", p->dpme_boot_block); printf("%7u ", p->dpme_boot_bytes); - printf("%8x ", (uint32_t) p->dpme_load_addr); - printf("%8x ", (uint32_t) p->dpme_goto_addr); + printf("%8x ", p->dpme_load_addr); + printf("%8x ", p->dpme_goto_addr); printf("%8x ", p->dpme_checksum); printf("%.32s", p->dpme_processor_id); printf("\n"); @@ -308,14 +307,11 @@ full_dump_partition_entry(struct partition_map_header *map, int ix) printf(" start address: 0x%08x\n", p->dpme_goto_addr); printf(" checksum: 0x%08x\n", p->dpme_checksum); printf(" processor: '%.32s'\n", p->dpme_processor_id); - printf("dpme_reserved_1 -"); + printf("dpme_reserved_3 -"); dump_block(p->dpme_reserved_1, sizeof(p->dpme_reserved_1)); - printf("dpme_reserved_2 -"); dump_block(p->dpme_reserved_2, sizeof(p->dpme_reserved_2)); - printf("dpme_reserved_3 -"); dump_block(p->dpme_reserved_3, sizeof(p->dpme_reserved_3)); - printf("dpme_reserved_4 -"); - dump_block(p->dpme_reserved_3, sizeof(p->dpme_reserved_4)); + dump_block(p->dpme_reserved_4, sizeof(p->dpme_reserved_4)); } @@ -373,6 +369,7 @@ full_dump_block_zero(struct partition_map_header *map) return; } zp = map->block0; + m = zp->sbDDMap; printf(" signature: 0x%x\n", zp->sbSig); printf(" size of a block: %u\n", zp->sbBlkSize); @@ -381,18 +378,15 @@ full_dump_block_zero(struct partition_map_header *map) printf(" device id: 0x%x\n", zp->sbDevId); printf(" data: 0x%x\n", zp->sbData); printf(" driver count: %u\n", zp->sbDrvrCount); - m = (struct ddmap *)zp->sbMap; - for (i = 0; &m[i].ddType < &zp->sbMap[247]; i++) { - if (m[i].ddBlock == 0 && m[i].ddSize == 0 && m[i].ddType == 0) { + for (i = 0; i < 8; i++) { + if (m[i].ddBlock == 0 && m[i].ddSize == 0 && m[i].ddType == 0) break; - } printf(" driver %3u block: %u\n", i + 1, m[i].ddBlock); printf(" size in blocks: %u\n", m[i].ddSize); printf(" driver type: 0x%x\n", m[i].ddType); } printf("remainder of block -"); - dump_block((unsigned char *)&m[i].ddBlock, (&zp->sbMap[247] - - ((unsigned short *)&m[i].ddBlock)) * 2); + dump_block(zp->sbReserved, sizeof(zp->sbReserved)); } int |