summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2016-01-27 14:47:53 +0000
committerkrw <krw@openbsd.org>2016-01-27 14:47:53 +0000
commitc579b49faeabaca842292aa989b468ffcc555277 (patch)
treef3239fcfbfa4651dd1b8392f7367dfa7b3caa8ae
parentappease mandoc lint, no difference in output (diff)
downloadwireguard-openbsd-c579b49faeabaca842292aa989b468ffcc555277.tar.xz
wireguard-openbsd-c579b49faeabaca842292aa989b468ffcc555277.zip
We do not support logical_block != physical_block. Remove logical_block
field and left over code that checks for logical != physical. Removes confusion with dmpe fields lblock_start and lblocks, which have nothing to do with block sizes! lblock_start is the block offset within the partition where the data actually starts. and lblocks is the number of blocks of data within the partition. Both are in units of *physical blocks*, a.k.a. disk sectors.
-rw-r--r--sbin/pdisk/dump.c17
-rw-r--r--sbin/pdisk/partition_map.c22
-rw-r--r--sbin/pdisk/partition_map.h7
-rw-r--r--sbin/pdisk/pdisk.c4
4 files changed, 16 insertions, 34 deletions
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index 6cea590dad7..d893657871f 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.57 2016/01/27 00:03:52 krw Exp $ */
+/* $OpenBSD: dump.c,v 1.58 2016/01/27 14:47:53 krw Exp $ */
/*
* dump.c - dumping partition maps
@@ -49,7 +49,6 @@ dump_block_zero(struct partition_map_header *map)
struct block0 *p;
struct ddmap *m;
double value;
- long t;
int i, prefix;
p = map->block0;
@@ -68,14 +67,6 @@ dump_block_zero(struct partition_map_header *map)
for (i = 0; i < p->sbDrvrCount; i++) {
printf("%d: %3u @ %u, ", i + 1, m[i].ddSize,
m[i].ddBlock);
- if (map->logical_block != p->sbBlkSize) {
- t = (m[i].ddSize * p->sbBlkSize) /
- map->logical_block;
- printf("(%lu@", t);
- t = m[i].ddBlock * p->sbBlkSize /
- map->logical_block;
- printf("%lu) ", t);
- }
printf("type=0x%x\n", m[i].ddType);
}
}
@@ -90,7 +81,7 @@ dump_partition_map(struct partition_map_header *map)
int digits, max_type_length, max_name_length;
printf("\nPartition map (with %d byte blocks) on '%s'\n",
- map->logical_block, map->name);
+ map->physical_block, map->name);
digits = number_of_digits(get_max_base_or_length(map));
if (digits < 6)
@@ -150,7 +141,7 @@ dump_partition_entry(struct partition_map *entry, int type_length,
printf("@~%-*u", digits, p->dpme_pblock_start +
p->dpme_lblock_start);
- bytes = ((double) size) * map->logical_block;
+ bytes = ((double) size) * map->physical_block;
adjust_value_and_compute_prefix(&bytes, &j);
if (j != ' ' && j != 'K')
printf(" (%#5.1f%c)", bytes, j);
@@ -170,7 +161,7 @@ show_data_structures(struct partition_map_header *map)
printf("Header:\n");
printf("map %d blocks out of %d, media %lu blocks (%d byte blocks)\n",
map->blocks_in_map, map->maximum_in_map, map->media_size,
- map->logical_block);
+ map->physical_block);
printf("Map is%s writable", rflag ? " not" : "");
printf(" and has%s been changed\n", (map->changed) ? "" : " not");
printf("\n");
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index 0ba92790ba9..a824a0ef2f1 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.70 2016/01/27 14:19:59 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.71 2016/01/27 14:47:53 krw Exp $ */
/*
* partition_map.c - partition map routines
@@ -87,7 +87,6 @@ open_partition_map(int fd, char *name, uint64_t mediasz, uint32_t sectorsz)
map->disk_order = NULL;
map->base_order = NULL;
map->physical_block = sectorsz;
- map->logical_block = sectorsz;
map->blocks_in_map = 0;
map->maximum_in_map = -1;
@@ -308,7 +307,6 @@ create_partition_map(int fd, char *name, u_int64_t mediasz, uint32_t sectorsz)
map->base_order = NULL;
map->physical_block = sectorsz;
- map->logical_block = sectorsz;
map->blocks_in_map = 0;
map->maximum_in_map = -1;
@@ -617,23 +615,20 @@ contains_driver(struct partition_map *entry)
struct partition_map_header *map;
struct block0 *p;
struct ddmap *m;
- int i, f;
+ int i;
uint32_t start;
map = entry->the_map;
p = map->block0;
if (p->sbSig != BLOCK0_SIGNATURE)
return 0;
- if (map->logical_block > p->sbBlkSize)
- return 0;
- f = p->sbBlkSize / map->logical_block;
if (p->sbDrvrCount > 0) {
m = p->sbDDMap;
for (i = 0; i < p->sbDrvrCount; i++) {
start = m[i].ddBlock;
- if (entry->dpme->dpme_pblock_start <= f * start &&
- f * (start + m[i].ddSize) <=
+ if (entry->dpme->dpme_pblock_start <= start &&
+ (start + m[i].ddSize) <=
(entry->dpme->dpme_pblock_start +
entry->dpme->dpme_pblocks))
return 1;
@@ -955,21 +950,18 @@ remove_driver(struct partition_map *entry)
struct partition_map_header *map;
struct block0 *p;
struct ddmap *m;
- int i, j, f;
+ int i, j;
uint32_t start;
map = entry->the_map;
p = map->block0;
if (p->sbSig != BLOCK0_SIGNATURE)
return;
- if (map->logical_block > p->sbBlkSize)
- return;
/*
* compute the factor to convert the block numbers in block0
* into partition map block numbers.
*/
- f = p->sbBlkSize / map->logical_block;
if (p->sbDrvrCount > 0) {
m = p->sbDDMap;
for (i = 0; i < p->sbDrvrCount; i++) {
@@ -979,8 +971,8 @@ remove_driver(struct partition_map *entry)
* zap the driver if it is wholly contained in the
* partition
*/
- if (entry->dpme->dpme_pblock_start <= f * start &&
- f * (start + m[i].ddSize) <=
+ if (entry->dpme->dpme_pblock_start <= start &&
+ (start + m[i].ddSize) <=
(entry->dpme->dpme_pblock_start
+ entry->dpme->dpme_pblocks)) {
/* delete this driver */
diff --git a/sbin/pdisk/partition_map.h b/sbin/pdisk/partition_map.h
index 158cda6f057..8a411d1c268 100644
--- a/sbin/pdisk/partition_map.h
+++ b/sbin/pdisk/partition_map.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.h,v 1.29 2016/01/24 01:38:32 krw Exp $ */
+/* $OpenBSD: partition_map.h,v 1.30 2016/01/27 14:47:53 krw Exp $ */
/*
* partition_map.h - partition map routines
@@ -37,11 +37,10 @@ struct partition_map_header {
struct block0 *block0;
int fd;
int changed;
- int physical_block; /* must be == sbBlockSize */
- int logical_block; /* must be <= physical_block */
+ int physical_block;
int blocks_in_map;
int maximum_in_map;
- unsigned long media_size; /* in logical_blocks */
+ unsigned long media_size; /* in physical blocks */
};
struct partition_map {
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c
index c0d3f462410..8451b4e759f 100644
--- a/sbin/pdisk/pdisk.c
+++ b/sbin/pdisk/pdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pdisk.c,v 1.73 2016/01/27 14:19:59 krw Exp $ */
+/* $OpenBSD: pdisk.c,v 1.74 2016/01/27 14:47:53 krw Exp $ */
/*
* pdisk - an editor for Apple format partition tables
@@ -311,7 +311,7 @@ get_size_argument(long *number, struct partition_map_header *map)
if (get_number_argument("Length in blocks: ", number) == 0) {
bad_input("Bad length");
} else {
- multiple = get_multiplier(map->logical_block);
+ multiple = get_multiplier(map->physical_block);
if (multiple == 0) {
bad_input("Bad multiplier");
} else if (multiple != 1) {