summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-01-21 02:52:53 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-01-21 02:52:53 +0000
commitad79220a1f6a61284080bbcf35e395b17d1f205b (patch)
treece0fac9eecfe41cc699cc3b6dc00cc54854578ed
parent52f25cff94390ba90d00c04f05997fda19c3d7b8 (diff)
Nuke 'writable' field now that it is always in sync with 'rflag'. Since
(!rflag && writable == 0) can't be true remove those warning blocks and simply leave the not-writable warning when attempting to write the map. Always show 'w' in the help and rely on the check and warning in do_write_partition_map() so the user always gets a message.
-rw-r--r--sbin/pdisk/dump.c5
-rw-r--r--sbin/pdisk/partition_map.c7
-rw-r--r--sbin/pdisk/partition_map.h3
-rw-r--r--sbin/pdisk/pdisk.c32
4 files changed, 9 insertions, 38 deletions
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index 0620f1aa3ab..51eee0825a0 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.38 2016/01/19 14:50:40 krw Exp $ */
+/* $OpenBSD: dump.c,v 1.39 2016/01/21 02:52:52 krw Exp $ */
/*
* dump.c - dumping partition maps
@@ -206,8 +206,7 @@ show_data_structures(struct partition_map_header * map)
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);
- printf("Map is%s writable", (map->writable) ? kStringEmpty :
- kStringNot);
+ printf("Map is%s writable", rflag ? kStringNot : kStringEmpty);
printf(", but%s changed", (map->changed) ? kStringEmpty : kStringNot);
printf(" and has%s been written\n", (map->written) ? kStringEmpty :
kStringNot);
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index e52f9d67fc9..26da73bc588 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.41 2016/01/21 01:37:18 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.42 2016/01/21 02:52:52 krw Exp $ */
/*
* partition_map.c - partition map routines
@@ -91,7 +91,7 @@ struct partition_map_header *
open_partition_map(char *name, int *valid_file)
{
struct partition_map_header *map;
- int fd, writable;
+ int fd;
fd = open_file_as_media(name, (rflag) ? O_RDONLY : O_RDWR);
if (fd == -1) {
@@ -100,7 +100,6 @@ open_partition_map(char *name, int *valid_file)
*valid_file = 0;
return NULL;
}
- writable = !rflag;
*valid_file = 1;
map = malloc(sizeof(struct partition_map_header));
@@ -110,7 +109,6 @@ open_partition_map(char *name, int *valid_file)
return NULL;
}
map->name = name;
- map->writable = (rflag) ? 0 : writable;
map->changed = 0;
map->written = 0;
map->disk_order = NULL;
@@ -367,7 +365,6 @@ create_partition_map(char *name, struct partition_map_header * oldmap)
return NULL;
}
map->name = name;
- map->writable = (rflag) ? 0 : 1;
map->changed = 1;
map->disk_order = NULL;
map->base_order = NULL;
diff --git a/sbin/pdisk/partition_map.h b/sbin/pdisk/partition_map.h
index d8d86b1b6cb..acfabff8991 100644
--- a/sbin/pdisk/partition_map.h
+++ b/sbin/pdisk/partition_map.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.h,v 1.19 2016/01/18 17:57:35 krw Exp $ */
+/* $OpenBSD: partition_map.h,v 1.20 2016/01/21 02:52:52 krw Exp $ */
/*
* partition_map.h - partition map routines
@@ -39,7 +39,6 @@ struct partition_map_header {
struct partition_map * base_order;
struct block0 *misc;
int fd;
- int writable;
int changed;
int written;
int physical_block; /* must be == sbBlockSize */
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c
index ff34e266fd5..f1880d0b16e 100644
--- a/sbin/pdisk/pdisk.c
+++ b/sbin/pdisk/pdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pdisk.c,v 1.54 2016/01/19 23:44:47 krw Exp $ */
+/* $OpenBSD: pdisk.c,v 1.55 2016/01/21 02:52:52 krw Exp $ */
/*
* pdisk - an editor for Apple format partition tables
@@ -172,9 +172,7 @@ edit(char *name)
printf(" r reorder partition entry in map\n");
printf(" s change size of partition map\n");
printf(" t change a partition's type\n");
- if (!rflag) {
- printf(" w write the partition table\n");
- }
+ printf(" w write the partition table\n");
if (dflag) {
printf(" x extra extensions for experts\n");
}
@@ -237,11 +235,7 @@ edit(char *name)
break;
case 'W':
case 'w':
- if (!rflag) {
- do_write_partition_map(map);
- } else {
- goto do_error;
- }
+ do_write_partition_map(map);
break;
default:
do_error:
@@ -265,9 +259,6 @@ do_create_partition(struct partition_map_header * map, int get_type)
bad_input("No partition map exists");
return;
}
- if (!rflag && map->writable == 0) {
- printf("The map is not writable.\n");
- }
if (get_base_argument(&base, map) == 0) {
return;
}
@@ -371,9 +362,6 @@ do_rename_partition(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (!rflag && map->writable == 0) {
- printf("The map is not writable.\n");
- }
if (get_number_argument("Partition number: ", &ix, kDefault) == 0) {
bad_input("Bad partition number");
return;
@@ -406,9 +394,6 @@ do_change_type(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (!rflag && map->writable == 0) {
- printf("The map is not writable.\n");
- }
if (get_number_argument("Partition number: ", &ix, kDefault) == 0) {
bad_input("Bad partition number");
return;
@@ -443,9 +428,6 @@ do_delete_partition(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (!rflag && map->writable == 0) {
- printf("The map is not writable.\n");
- }
if (get_number_argument("Partition number: ", &ix, kDefault) == 0) {
bad_input("Bad partition number");
return;
@@ -469,9 +451,6 @@ do_reorder(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (!rflag && map->writable == 0) {
- printf("The map is not writable.\n");
- }
if (get_number_argument("Partition number: ", &old_index, kDefault) ==
0) {
bad_input("Bad partition number");
@@ -496,7 +475,7 @@ do_write_partition_map(struct partition_map_header * map)
bad_input("The map has not been changed.");
return;
}
- if (map->writable == 0) {
+ if (rflag) {
bad_input("The map is not writable.");
return;
}
@@ -592,9 +571,6 @@ do_change_map_size(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (!rflag && map->writable == 0) {
- printf("The map is not writable.\n");
- }
if (get_number_argument("New size: ", &size, kDefault) == 0) {
bad_input("Bad size");
return;