diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-31 22:26:53 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-31 22:26:53 +0000 |
commit | 422e2e4a6457cc777b90a1fbd24fa64b8ae946de (patch) | |
tree | a82f9cc6a6dbfc4eb3371ef95e0883f492899841 /sbin/pdisk/partition_map.c | |
parent | 969c2f87560a07a60266b34f808d4556a120c096 (diff) |
Use delete_entry()/create_entry() in delete_partition_from_map() instead of
trying to be clever and tweaking the existing entry into a free space
entry by manual manipulation of the fields.
Diffstat (limited to 'sbin/pdisk/partition_map.c')
-rw-r--r-- | sbin/pdisk/partition_map.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c index 22e53db3d2c..000fb32dcb1 100644 --- a/sbin/pdisk/partition_map.c +++ b/sbin/pdisk/partition_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: partition_map.c,v 1.95 2016/01/31 22:12:35 krw Exp $ */ +/* $OpenBSD: partition_map.c,v 1.96 2016/01/31 22:26:52 krw Exp $ */ /* * partition_map.c - partition map routines @@ -448,6 +448,9 @@ renumber_disk_addresses(struct partition_map *map) void delete_partition_from_map(struct entry *entry) { + struct partition_map *map; + uint32_t base, length, address; + if (strncasecmp(entry->dpme_type, kMapType, DPISTRLEN) == 0) { printf("Can't delete entry for the map itself\n"); return; @@ -465,13 +468,13 @@ delete_partition_from_map(struct entry *entry) remove_driver(entry); /* update block0 if necessary */ } - memset(entry->dpme_name, 0, sizeof(entry->dpme_name)); - memset(entry->dpme_type, 0, sizeof(entry->dpme_type)); - strlcpy(entry->dpme_type, kFreeType, sizeof(entry->dpme_type)); - entry->dpme_lblock_start = 0; - entry->dpme_lblocks = 0; - dpme_init_flags(entry); + map = entry->the_map; + base = entry->dpme_pblock_start; + length = entry->dpme_pblocks; + address = entry->disk_address; + delete_entry(entry); + entry = create_entry(map, address, "" , kFreeType, base, length); combine_entry(entry); renumber_disk_addresses(entry->the_map); entry->the_map->changed = 1; |