summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/pdisk/dpme.h20
-rw-r--r--sbin/pdisk/dump.c67
-rw-r--r--sbin/pdisk/file_media.c94
-rw-r--r--sbin/pdisk/file_media.h6
-rw-r--r--sbin/pdisk/partition_map.c117
-rw-r--r--sbin/pdisk/partition_map.h20
6 files changed, 140 insertions, 184 deletions
diff --git a/sbin/pdisk/dpme.h b/sbin/pdisk/dpme.h
index c314d0f84b6..e3cc84fd1e7 100644
--- a/sbin/pdisk/dpme.h
+++ b/sbin/pdisk/dpme.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dpme.h,v 1.24 2016/01/28 13:01:33 krw Exp $ */
+/* $OpenBSD: dpme.h,v 1.25 2016/01/29 22:51:43 krw Exp $ */
/*
* dpme.h - Disk Partition Map Entry (dpme)
@@ -47,24 +47,6 @@
#define DPISTRLEN 32
-struct ddmap {
- uint32_t ddBlock; /* 1st driver's starting sbBlkSize block */
- uint16_t ddSize; /* size of 1st driver (512-byte blks) */
- uint16_t ddType; /* system type (1 for Mac+) */
-};
-
-struct block0 {
- uint16_t sbSig; /* "ER" */
- uint16_t sbBlkSize; /* physical block size of device */
- uint32_t sbBlkCount; /* # of physical blocks on device */
- uint16_t sbDevType; /* device type */
- uint16_t sbDevId; /* device id */
- uint32_t sbData; /* not used */
- uint16_t sbDrvrCount; /* driver descriptor count */
- struct ddmap sbDDMap[8]; /* driver descriptor map*/
- uint8_t sbReserved[430];
-};
-
/*
* Each partition map entry (blocks 1 through n) has this format
*/
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index e1d1db85e01..7e813607c24 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.66 2016/01/29 17:22:44 krw Exp $ */
+/* $OpenBSD: dump.c,v 1.67 2016/01/29 22:51:43 krw Exp $ */
/*
* dump.c - dumping partition maps
@@ -48,23 +48,21 @@ int get_max_type_string_length(struct partition_map *);
void
dump_block_zero(struct partition_map *map)
{
- struct block0 *p;
struct ddmap *m;
double value;
int i, prefix;
- p = map->block0;
-
- value = ((double) p->sbBlkCount) * p->sbBlkSize;
+ value = ((double)map->sbBlkCount) * map->sbBlkSize;
adjust_value_and_compute_prefix(&value, &prefix);
printf("\nDevice block size=%u, Number of Blocks=%u (%1.1f%c)\n",
- p->sbBlkSize, p->sbBlkCount, value, prefix);
+ map->sbBlkSize, map->sbBlkCount, value, prefix);
- printf("DeviceType=0x%x, DeviceId=0x%x\n", p->sbDevType, p->sbDevId);
- if (p->sbDrvrCount > 0) {
+ printf("DeviceType=0x%x, DeviceId=0x%x\n", map->sbDevType,
+ map->sbDevId);
+ if (map->sbDrvrCount > 0) {
printf("Drivers-\n");
- m = p->sbDDMap;
- for (i = 0; i < p->sbDrvrCount; i++) {
+ m = map->sbDDMap;
+ for (i = 0; i < map->sbDrvrCount; i++) {
printf("%d: %3u @ %u, ", i + 1, m[i].ddSize,
m[i].ddBlock);
printf("type=0x%x\n", m[i].ddType);
@@ -133,7 +131,6 @@ void
show_data_structures(struct partition_map *map)
{
struct entry *entry;
- struct block0 *zp;
struct ddmap *m;
struct dpme *p;
int i;
@@ -146,21 +143,19 @@ show_data_structures(struct partition_map *map)
printf(" and has%s been changed\n", (map->changed) ? "" : " not");
printf("\n");
- zp = map->block0;
-
printf("Block0:\n");
- printf("signature 0x%x", zp->sbSig);
- printf("Block size=%u, Number of Blocks=%u\n", zp->sbBlkSize,
- zp->sbBlkCount);
- printf("DeviceType=0x%x, DeviceId=0x%x, sbData=0x%x\n", zp->sbDevType,
- zp->sbDevId, zp->sbData);
- if (zp->sbDrvrCount == 0) {
+ printf("signature 0x%x", map->sbSig);
+ printf("Block size=%u, Number of Blocks=%u\n", map->sbBlkSize,
+ map->sbBlkCount);
+ printf("DeviceType=0x%x, DeviceId=0x%x, sbData=0x%x\n", map->sbDevType,
+ map->sbDevId, map->sbData);
+ if (map->sbDrvrCount == 0) {
printf("No drivers\n");
} else {
- printf("%u driver%s-\n", zp->sbDrvrCount,
- (zp->sbDrvrCount > 1) ? "s" : "");
- m = zp->sbDDMap;
- for (i = 0; i < zp->sbDrvrCount; i++) {
+ printf("%u driver%s-\n", map->sbDrvrCount,
+ (map->sbDrvrCount > 1) ? "s" : "");
+ m = map->sbDDMap;
+ for (i = 0; i < map->sbDrvrCount; i++) {
printf("%u: @ %u for %u, type=0x%x\n", i + 1,
m[i].ddBlock, m[i].ddSize, m[i].ddType);
}
@@ -307,24 +302,18 @@ dump_block(unsigned char *addr, int len)
void
full_dump_block_zero(struct partition_map *map)
{
- struct block0 *zp;
struct ddmap *m;
int i;
- if (map->block0 == NULL) {
- printf("No block zero\n");
- return;
- }
- zp = map->block0;
- m = zp->sbDDMap;
-
- printf(" signature: 0x%x\n", zp->sbSig);
- printf(" size of a block: %u\n", zp->sbBlkSize);
- printf(" number of blocks: %u\n", zp->sbBlkCount);
- printf(" device type: 0x%x\n", zp->sbDevType);
- printf(" device id: 0x%x\n", zp->sbDevId);
- printf(" data: 0x%x\n", zp->sbData);
- printf(" driver count: %u\n", zp->sbDrvrCount);
+ m = map->sbDDMap;
+
+ printf(" signature: 0x%x\n", map->sbSig);
+ printf(" size of a block: %u\n", map->sbBlkSize);
+ printf(" number of blocks: %u\n", map->sbBlkCount);
+ printf(" device type: 0x%x\n", map->sbDevType);
+ printf(" device id: 0x%x\n", map->sbDevId);
+ printf(" data: 0x%x\n", map->sbData);
+ printf(" driver count: %u\n", map->sbDrvrCount);
for (i = 0; i < 8; i++) {
if (m[i].ddBlock == 0 && m[i].ddSize == 0 && m[i].ddType == 0)
break;
@@ -333,7 +322,7 @@ full_dump_block_zero(struct partition_map *map)
printf(" driver type: 0x%x\n", m[i].ddType);
}
printf("remainder of block -");
- dump_block(zp->sbReserved, sizeof(zp->sbReserved));
+ dump_block(map->sbReserved, sizeof(map->sbReserved));
}
int
diff --git a/sbin/pdisk/file_media.c b/sbin/pdisk/file_media.c
index 567fc1ab347..cef889ffae1 100644
--- a/sbin/pdisk/file_media.c
+++ b/sbin/pdisk/file_media.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file_media.c,v 1.44 2016/01/28 13:01:33 krw Exp $ */
+/* $OpenBSD: file_media.c,v 1.45 2016/01/29 22:51:43 krw Exp $ */
/*
* file_media.c -
@@ -28,6 +28,7 @@
*/
#include <sys/param.h> /* DEV_BSIZE */
+#include <sys/queue.h>
#include <err.h>
#include <stdio.h>
@@ -36,6 +37,7 @@
#include <unistd.h>
#include "dpme.h"
+#include "partition_map.h"
#include "file_media.h"
struct ddmap_ondisk {
@@ -114,7 +116,7 @@ write_block(int fd, uint64_t sector, void *address)
}
int
-read_block0(int fd, struct block0 *block0)
+read_block0(int fd, struct partition_map *map)
{
struct block0_ondisk *block0_ondisk;
struct ddmap_ondisk ddmap_ondisk;
@@ -127,42 +129,42 @@ read_block0(int fd, struct block0 *block0)
if (read_block(fd, 0, block0_ondisk) == 0)
return 0;
- memcpy(&block0->sbSig, block0_ondisk->sbSig,
- sizeof(block0->sbSig));
- block0->sbSig = betoh16(block0->sbSig);
- memcpy(&block0->sbBlkSize, block0_ondisk->sbBlkSize,
- sizeof(block0->sbBlkSize));
- block0->sbBlkSize = betoh16(block0->sbBlkSize);
- memcpy(&block0->sbBlkCount, block0_ondisk->sbBlkCount,
- sizeof(block0->sbBlkCount));
- block0->sbBlkCount = betoh32(block0->sbBlkCount);
- memcpy(&block0->sbDevType, block0_ondisk->sbDevType,
- sizeof(block0->sbDevType));
- block0->sbDevType = betoh16(block0->sbDevType);
- memcpy(&block0->sbDevId, block0_ondisk->sbDevId,
- sizeof(block0->sbDevId));
- block0->sbDevId = betoh16(block0->sbDevId);
- memcpy(&block0->sbData, block0_ondisk->sbData,
- sizeof(block0->sbData));
- block0->sbData = betoh32(block0->sbData);
- memcpy(&block0->sbDrvrCount, block0_ondisk->sbDrvrCount,
- sizeof(block0->sbDrvrCount));
- block0->sbDrvrCount = betoh16(block0->sbDrvrCount);
+ memcpy(&map->sbSig, block0_ondisk->sbSig,
+ sizeof(map->sbSig));
+ map->sbSig = betoh16(map->sbSig);
+ memcpy(&map->sbBlkSize, block0_ondisk->sbBlkSize,
+ sizeof(map->sbBlkSize));
+ map->sbBlkSize = betoh16(map->sbBlkSize);
+ memcpy(&map->sbBlkCount, block0_ondisk->sbBlkCount,
+ sizeof(map->sbBlkCount));
+ map->sbBlkCount = betoh32(map->sbBlkCount);
+ memcpy(&map->sbDevType, block0_ondisk->sbDevType,
+ sizeof(map->sbDevType));
+ map->sbDevType = betoh16(map->sbDevType);
+ memcpy(&map->sbDevId, block0_ondisk->sbDevId,
+ sizeof(map->sbDevId));
+ map->sbDevId = betoh16(map->sbDevId);
+ memcpy(&map->sbData, block0_ondisk->sbData,
+ sizeof(map->sbData));
+ map->sbData = betoh32(map->sbData);
+ memcpy(&map->sbDrvrCount, block0_ondisk->sbDrvrCount,
+ sizeof(map->sbDrvrCount));
+ map->sbDrvrCount = betoh16(map->sbDrvrCount);
for (i = 0; i < 8; i++) {
memcpy(&ddmap_ondisk,
- block0->sbDDMap+i*sizeof(struct ddmap_ondisk),
+ map->sbDDMap+i*sizeof(struct ddmap_ondisk),
sizeof(ddmap_ondisk));
- memcpy(&block0->sbDDMap[i].ddBlock, &ddmap_ondisk.ddBlock,
- sizeof(block0->sbDDMap[i].ddBlock));
- block0->sbDDMap[i].ddBlock =
- betoh32(block0->sbDDMap[i].ddBlock);
- memcpy(&block0->sbDDMap[i].ddSize, &ddmap_ondisk.ddSize,
- sizeof(block0->sbDDMap[i].ddSize));
- block0->sbDDMap[i].ddSize = betoh16(block0->sbDDMap[i].ddSize);
- memcpy(&block0->sbDDMap[i].ddType, &ddmap_ondisk.ddType,
- sizeof(block0->sbDDMap[i].ddType));
- block0->sbDDMap[i].ddType = betoh32(block0->sbDDMap[i].ddType);
+ memcpy(&map->sbDDMap[i].ddBlock, &ddmap_ondisk.ddBlock,
+ sizeof(map->sbDDMap[i].ddBlock));
+ map->sbDDMap[i].ddBlock =
+ betoh32(map->sbDDMap[i].ddBlock);
+ memcpy(&map->sbDDMap[i].ddSize, &ddmap_ondisk.ddSize,
+ sizeof(map->sbDDMap[i].ddSize));
+ map->sbDDMap[i].ddSize = betoh16(map->sbDDMap[i].ddSize);
+ memcpy(&map->sbDDMap[i].ddType, &ddmap_ondisk.ddType,
+ sizeof(map->sbDDMap[i].ddType));
+ map->sbDDMap[i].ddType = betoh32(map->sbDDMap[i].ddType);
}
free(block0_ondisk);
@@ -170,7 +172,7 @@ read_block0(int fd, struct block0 *block0)
}
int
-write_block0(int fd, struct block0 *block0)
+write_block0(int fd, struct partition_map *map)
{
struct block0_ondisk *block0_ondisk;
struct ddmap_ondisk ddmap_ondisk;
@@ -182,39 +184,39 @@ write_block0(int fd, struct block0 *block0)
if (block0_ondisk == NULL)
return 0;
- tmp16 = htobe16(block0->sbSig);
+ tmp16 = htobe16(map->sbSig);
memcpy(block0_ondisk->sbSig, &tmp16,
sizeof(block0_ondisk->sbSig));
- tmp16 = htobe16(block0->sbBlkSize);
+ tmp16 = htobe16(map->sbBlkSize);
memcpy(block0_ondisk->sbBlkSize, &tmp16,
sizeof(block0_ondisk->sbBlkSize));
- tmp32 = htobe32(block0->sbBlkCount);
+ tmp32 = htobe32(map->sbBlkCount);
memcpy(block0_ondisk->sbBlkCount, &tmp32,
sizeof(block0_ondisk->sbBlkCount));
- tmp16 = htobe16(block0->sbDevType);
+ tmp16 = htobe16(map->sbDevType);
memcpy(block0_ondisk->sbDevType, &tmp16,
sizeof(block0_ondisk->sbDevType));
- tmp16 = htobe16(block0->sbDevId);
+ tmp16 = htobe16(map->sbDevId);
memcpy(block0_ondisk->sbDevId, &tmp16,
sizeof(block0_ondisk->sbDevId));
- tmp32 = htobe32(block0->sbData);
+ tmp32 = htobe32(map->sbData);
memcpy(block0_ondisk->sbData, &tmp32,
sizeof(block0_ondisk->sbData));
- tmp16 = htobe16(block0->sbDrvrCount);
+ tmp16 = htobe16(map->sbDrvrCount);
memcpy(block0_ondisk->sbDrvrCount, &tmp16,
sizeof(block0_ondisk->sbDrvrCount));
for (i = 0; i < 8; i++) {
- tmp32 = htobe32(block0->sbDDMap[i].ddBlock);
+ tmp32 = htobe32(map->sbDDMap[i].ddBlock);
memcpy(ddmap_ondisk.ddBlock, &tmp32,
sizeof(ddmap_ondisk.ddBlock));
- tmp16 = htobe16(block0->sbDDMap[i].ddSize);
+ tmp16 = htobe16(map->sbDDMap[i].ddSize);
memcpy(&ddmap_ondisk.ddSize, &tmp16,
sizeof(ddmap_ondisk.ddSize));
- tmp16 = betoh32(block0->sbDDMap[i].ddType);
+ tmp16 = betoh32(map->sbDDMap[i].ddType);
memcpy(&ddmap_ondisk.ddType, &tmp16,
sizeof(ddmap_ondisk.ddType));
- memcpy(block0->sbDDMap+i*sizeof(struct ddmap_ondisk),
+ memcpy(map->sbDDMap+i*sizeof(struct ddmap_ondisk),
&ddmap_ondisk, sizeof(ddmap_ondisk));
}
diff --git a/sbin/pdisk/file_media.h b/sbin/pdisk/file_media.h
index bd997fc66f6..889913c6c78 100644
--- a/sbin/pdisk/file_media.h
+++ b/sbin/pdisk/file_media.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file_media.h,v 1.18 2016/01/25 23:43:20 krw Exp $ */
+/* $OpenBSD: file_media.h,v 1.19 2016/01/29 22:51:43 krw Exp $ */
/*
* file_media.h -
@@ -30,8 +30,8 @@
#ifndef __file_media__
#define __file_media__
-int read_block0(int, struct block0 *);
-int write_block0(int, struct block0 *);
+int read_block0(int, struct partition_map *);
+int write_block0(int, struct partition_map *);
int read_dpme(int, uint64_t, struct dpme *);
int write_dpme(int, uint64_t, struct dpme *);
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index 47d1bffb1e4..076e1f94ec9 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.86 2016/01/29 17:34:08 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.87 2016/01/29 22:51:43 krw Exp $ */
/*
* partition_map.c - partition map routines
@@ -54,7 +54,6 @@ enum add_action {
};
int add_data_to_map(struct dpme *, long, struct partition_map *);
-int coerce_block0(struct partition_map *);
int contains_driver(struct entry *);
void combine_entry(struct entry *);
struct dpme *create_dpme(const char *, const char *, uint32_t, uint32_t);
@@ -92,33 +91,27 @@ open_partition_map(int fd, char *name, uint64_t mediasz, uint32_t sectorsz)
else
map->media_size = mediasz;
- map->block0 = malloc(sizeof(struct block0));
- if (map->block0 == NULL) {
- warn("can't allocate memory for block zero buffer");
- free(map);
- return NULL;
- }
- if (read_block0(map->fd, map->block0) == 0) {
+ if (read_block0(map->fd, map) == 0) {
warnx("Can't read block 0 from '%s'", name);
free_partition_map(map);
return NULL;
}
- if (map->block0->sbSig == BLOCK0_SIGNATURE &&
- map->block0->sbBlkSize == sectorsz &&
- map->block0->sbBlkCount == mediasz) {
+ if (map->sbSig == BLOCK0_SIGNATURE &&
+ map->sbBlkSize == sectorsz &&
+ map->sbBlkCount == mediasz) {
if (read_partition_map(map) == 0)
return map;
} else {
- if (map->block0->sbSig != BLOCK0_SIGNATURE)
+ if (map->sbSig != BLOCK0_SIGNATURE)
warnx("Block 0 signature: Expected 0x%04x, "
"got 0x%04x", BLOCK0_SIGNATURE,
- map->block0->sbSig);
- else if (map->block0->sbBlkSize != sectorsz)
+ map->sbSig);
+ else if (map->sbBlkSize != sectorsz)
warnx("Block 0 sbBlkSize (%u) != sector size (%u)",
- map->block0->sbBlkSize, sectorsz);
- else if (map->block0->sbBlkCount != mediasz)
+ map->sbBlkSize, sectorsz);
+ else if (map->sbBlkCount != mediasz)
warnx("Block 0 sbBlkCount (%u) != media size (%llu)",
- map->block0->sbBlkCount,
+ map->sbBlkCount,
(unsigned long long)mediasz);
}
@@ -146,7 +139,6 @@ free_partition_map(struct partition_map *map)
struct entry *entry;
if (map) {
- free(map->block0);
while (!LIST_EMPTY(&map->disk_order)) {
entry = LIST_FIRST(&map->disk_order);
LIST_REMOVE(entry, disk_entry);
@@ -251,7 +243,7 @@ write_partition_map(struct partition_map *map)
struct entry *entry;
int result;
- result = write_block0(map->fd, map->block0);
+ result = write_block0(map->fd, map);
if (result == 0)
warn("Unable to write block zero");
@@ -312,31 +304,27 @@ create_partition_map(int fd, char *name, u_int64_t mediasz, uint32_t sectorsz)
map->maximum_in_map = -1;
map->media_size = mediasz;
- map->block0 = calloc(1, sizeof(struct block0));
- if (map->block0 == NULL) {
- warn("can't allocate memory for block zero buffer");
+ map->sbSig = BLOCK0_SIGNATURE;
+ map->sbBlkSize = map->physical_block;
+ map->sbBlkCount = map->media_size;
+
+ dpme = calloc(1, sizeof(struct dpme));
+ if (dpme == NULL) {
+ warn("can't allocate memory for initial dpme");
} else {
- coerce_block0(map);
+ dpme->dpme_signature = DPME_SIGNATURE;
+ dpme->dpme_map_entries = 1;
+ dpme->dpme_pblock_start = 1;
+ dpme->dpme_pblocks = map->media_size - 1;
+ strlcpy(dpme->dpme_type, kFreeType, sizeof(dpme->dpme_type));
+ dpme_init_flags(dpme);
- dpme = calloc(1, sizeof(struct dpme));
- if (dpme == NULL) {
- warn("can't allocate memory for disk buffers");
+ if (add_data_to_map(dpme, 1, map) == 0) {
+ free(dpme);
} else {
- dpme->dpme_signature = DPME_SIGNATURE;
- dpme->dpme_map_entries = 1;
- dpme->dpme_pblock_start = 1;
- dpme->dpme_pblocks = map->media_size - 1;
- strlcpy(dpme->dpme_type, kFreeType,
- sizeof(dpme->dpme_type));
- dpme_init_flags(dpme);
-
- if (add_data_to_map(dpme, 1, map) == 0) {
- free(dpme);
- } else {
- add_partition_to_map("Apple", kMapType,
- 1, (map->media_size <= 128 ? 2 : 63), map);
- return map;
- }
+ add_partition_to_map("Apple", kMapType, 1,
+ (map->media_size <= 128 ? 2 : 63), map);
+ return map;
}
}
@@ -346,25 +334,6 @@ create_partition_map(int fd, char *name, u_int64_t mediasz, uint32_t sectorsz)
int
-coerce_block0(struct partition_map *map)
-{
- struct block0 *p;
-
- p = map->block0;
- if (p->sbSig != BLOCK0_SIGNATURE) {
- p->sbSig = BLOCK0_SIGNATURE;
- p->sbBlkSize = map->physical_block;
- p->sbBlkCount = map->media_size;
- p->sbDevType = 0;
- p->sbDevId = 0;
- p->sbData = 0;
- p->sbDrvrCount = 0;
- }
- return 0;
-}
-
-
-int
add_partition_to_map(const char *name, const char *dptype, uint32_t base,
uint32_t length, struct partition_map *map)
{
@@ -550,17 +519,15 @@ int
contains_driver(struct entry *entry)
{
struct partition_map *map;
- struct block0 *p;
- struct ddmap *m;
+ struct ddmap *m;
int i;
uint32_t start;
map = entry->the_map;
- p = map->block0;
- if (p->sbDrvrCount > 0) {
- m = p->sbDDMap;
- for (i = 0; i < p->sbDrvrCount; i++) {
+ if (map->sbDrvrCount > 0) {
+ m = map->sbDDMap;
+ for (i = 0; i < map->sbDrvrCount; i++) {
start = m[i].ddBlock;
if (entry->dpme->dpme_pblock_start <= start &&
(start + m[i].ddSize) <=
@@ -853,20 +820,19 @@ doit:
void
remove_driver(struct entry *entry)
{
- struct block0 *p;
+ struct partition_map *map;
struct ddmap *m;
int i, j;
uint32_t start;
- p = entry->the_map->block0;
-
/*
* compute the factor to convert the block numbers in block0
* into partition map block numbers.
*/
- if (p->sbDrvrCount > 0) {
- m = p->sbDDMap;
- for (i = 0; i < p->sbDrvrCount; i++) {
+ map = entry->the_map;
+ if (map->sbDrvrCount > 0) {
+ m = map->sbDDMap;
+ for (i = 0; i < map->sbDrvrCount; i++) {
start = m[i].ddBlock;
/*
@@ -882,7 +848,8 @@ remove_driver(struct entry *entry)
* by copying down later ones and zapping the
* last
*/
- for (j = i + 1; j < p->sbDrvrCount; j++, i++) {
+ for (j = i + 1; j < map->sbDrvrCount; j++,
+ i++) {
m[i].ddBlock = m[i].ddBlock;
m[i].ddSize = m[j].ddSize;
m[i].ddType = m[j].ddType;
@@ -890,7 +857,7 @@ remove_driver(struct entry *entry)
m[i].ddBlock = 0;
m[i].ddSize = 0;
m[i].ddType = 0;
- p->sbDrvrCount -= 1;
+ map->sbDrvrCount -= 1;
return; /* XXX if we continue we will delete
* other drivers? */
}
diff --git a/sbin/pdisk/partition_map.h b/sbin/pdisk/partition_map.h
index d4dc50092b9..0efb2b3feae 100644
--- a/sbin/pdisk/partition_map.h
+++ b/sbin/pdisk/partition_map.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.h,v 1.35 2016/01/29 15:06:37 krw Exp $ */
+/* $OpenBSD: partition_map.h,v 1.36 2016/01/29 22:51:43 krw Exp $ */
/*
* partition_map.h - partition map routines
@@ -30,19 +30,35 @@
#ifndef __partition_map__
#define __partition_map__
+struct ddmap {
+ uint32_t ddBlock; /* 1st driver's starting sbBlkSize block */
+ uint16_t ddSize; /* size of 1st driver (512-byte blks) */
+ uint16_t ddType; /* system type (1 for Mac+) */
+};
+
struct entry;
struct partition_map {
LIST_HEAD(, entry) disk_order;
LIST_HEAD(, entry) base_order;
char *name;
- struct block0 *block0;
int fd;
int changed;
int physical_block;
int blocks_in_map;
int maximum_in_map;
unsigned long media_size; /* in physical blocks */
+
+ /* On-disk block 0 data. */
+ uint16_t sbSig; /* "ER" */
+ uint16_t sbBlkSize; /* physical block size of device */
+ uint32_t sbBlkCount; /* # of physical blocks on device */
+ uint16_t sbDevType; /* device type */
+ uint16_t sbDevId; /* device id */
+ uint32_t sbData; /* not used */
+ uint16_t sbDrvrCount; /* driver descriptor count */
+ struct ddmap sbDDMap[8]; /* driver descriptor map*/
+ uint8_t sbReserved[430];
};
struct entry {