summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2016-01-21 01:37:18 +0000
committerkrw <krw@openbsd.org>2016-01-21 01:37:18 +0000
commit90bc44060a4ca7d3f6ebf35ad05e6a0b0705de6c (patch)
treeb27fa3cfca607aed11a536860c29c29fa185c8f7
parentAdd Approx APPUSB300NANO V1. V2 uses a different chipset. (diff)
downloadwireguard-openbsd-90bc44060a4ca7d3f6ebf35ad05e6a0b0705de6c.tar.xz
wireguard-openbsd-90bc44060a4ca7d3f6ebf35ad05e6a0b0705de6c.zip
Don't try to be cute by silently opening a disk read-only when R/W
access was requested. Just complain when the R/W open fails. Make failure messages consistent.
-rw-r--r--sbin/pdisk/partition_map.c17
-rw-r--r--sbin/pdisk/validate.c4
2 files changed, 8 insertions, 13 deletions
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index 23089801e96..e52f9d67fc9 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.40 2016/01/18 17:57:35 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.41 2016/01/21 01:37:18 krw Exp $ */
/*
* partition_map.c - partition map routines
@@ -95,17 +95,12 @@ open_partition_map(char *name, int *valid_file)
fd = open_file_as_media(name, (rflag) ? O_RDONLY : O_RDWR);
if (fd == -1) {
- fd = open_file_as_media(name, O_RDONLY);
- if (fd == -1) {
- warn("can't open file '%s'", name);
- *valid_file = 0;
- return NULL;
- } else {
- writable = 0;
- }
- } else {
- writable = 1;
+ warn("can't open file '%s' for %sing", name, (rflag) ?
+ "read" : "writ");
+ *valid_file = 0;
+ return NULL;
}
+ writable = !rflag;
*valid_file = 1;
map = malloc(sizeof(struct partition_map_header));
diff --git a/sbin/pdisk/validate.c b/sbin/pdisk/validate.c
index d80964cbda8..d7be94f58b9 100644
--- a/sbin/pdisk/validate.c
+++ b/sbin/pdisk/validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: validate.c,v 1.27 2016/01/18 17:57:35 krw Exp $ */
+/* $OpenBSD: validate.c,v 1.28 2016/01/21 01:37:18 krw Exp $ */
/*
* validate.c -
@@ -312,7 +312,7 @@ validate_map(struct partition_map_header * map)
}
the_fd = open_file_as_media(name, O_RDONLY);
if (the_fd == -1) {
- warn("can't open file '%s'", name);
+ warn("can't open file '%s' for reading", name);
free(name);
return;
}