summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/pdisk/dump.c20
-rw-r--r--sbin/pdisk/dump.h3
-rw-r--r--sbin/pdisk/pdisk.c31
3 files changed, 17 insertions, 37 deletions
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index 6954de6290b..0620f1aa3ab 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.37 2016/01/18 21:50:53 krw Exp $ */
+/* $OpenBSD: dump.c,v 1.38 2016/01/19 14:50:40 krw Exp $ */
/*
* dump.c - dumping partition maps
@@ -53,24 +53,6 @@ int get_max_base_or_length(struct partition_map_header *);
int get_max_name_string_length(struct partition_map_header *);
int get_max_type_string_length(struct partition_map_header *);
-int
-dump(char *name)
-{
- struct partition_map_header *map;
- int junk;
-
- map = open_partition_map(name, &junk);
- if (map == NULL) {
- return 0;
- }
- dump_partition_map(map, 1);
-
- close_partition_map(map);
-
- return 1;
-}
-
-
void
dump_block_zero(struct partition_map_header * map)
{
diff --git a/sbin/pdisk/dump.h b/sbin/pdisk/dump.h
index 6e6f4bba5d8..3a1837a7f5e 100644
--- a/sbin/pdisk/dump.h
+++ b/sbin/pdisk/dump.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.h,v 1.11 2016/01/18 21:50:53 krw Exp $ */
+/* $OpenBSD: dump.h,v 1.12 2016/01/19 14:50:40 krw Exp $ */
/*
* dump.h - dumping partition maps
@@ -32,7 +32,6 @@
#include "partition_map.h"
-int dump(char *);
void dump_block(unsigned char *, int);
void dump_partition_map(struct partition_map_header *, int);
void full_dump_partition_entry(struct partition_map_header *, int);
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c
index d3e706c77b8..0780297a017 100644
--- a/sbin/pdisk/pdisk.c
+++ b/sbin/pdisk/pdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pdisk.c,v 1.50 2016/01/19 12:25:28 krw Exp $ */
+/* $OpenBSD: pdisk.c,v 1.51 2016/01/19 14:50:40 krw Exp $ */
/*
* pdisk - an editor for Apple format partition tables
@@ -72,7 +72,8 @@ __dead static void usage(void);
int
main(int argc, char **argv)
{
- int c, name_index;
+ struct partition_map_header *map;
+ int c, junk;
if (sizeof(struct dpme) != DEV_BSIZE) {
errx(1, "Size of partition map entry (%zu) is not equal "
@@ -99,23 +100,21 @@ main(int argc, char **argv)
}
}
- name_index = optind;
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 1)
+ usage();
if (lflag) {
- if (name_index < argc) {
- while (name_index < argc) {
- dump(argv[name_index++]);
- }
- } else {
- usage();
- }
- } else if (name_index < argc) {
- while (name_index < argc) {
- edit(argv[name_index++]);
+ map = open_partition_map(*argv, &junk);
+ if (map) {
+ dump_partition_map(map, 1);
+ close_partition_map(map);
}
- } else {
- usage();
- }
+ } else
+ edit(*argv);
+
return 0;
}