Module Name:    src
Committed By:   christos
Date:           Sun Nov 29 00:14:46 UTC 2015

Modified Files:
        src/sbin/gpt: add.c backup.c biosboot.c create.c destroy.c gpt.c gpt.h
            header.c label.c migrate.c recover.c remove.c resize.c resizedisk.c
            restore.c set.c show.c type.c unset.c

Log Message:
merge the create errors in one place and fix them.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sbin/gpt/add.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/gpt/backup.c src/sbin/gpt/restore.c
cvs rdiff -u -r1.14 -r1.15 src/sbin/gpt/biosboot.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/create.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/gpt/destroy.c src/sbin/gpt/recover.c \
    src/sbin/gpt/resizedisk.c src/sbin/gpt/type.c
cvs rdiff -u -r1.41 -r1.42 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.2 -r1.3 src/sbin/gpt/header.c
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/label.c
cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/migrate.c src/sbin/gpt/show.c
cvs rdiff -u -r1.16 -r1.17 src/sbin/gpt/remove.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/gpt/resize.c
cvs rdiff -u -r1.5 -r1.6 src/sbin/gpt/set.c src/sbin/gpt/unset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.27 src/sbin/gpt/add.c:1.28
--- src/sbin/gpt/add.c:1.27	Tue Sep 30 13:59:59 2014
+++ src/sbin/gpt/add.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.27 2014/09/30 17:59:59 christos Exp $");
+__RCSID("$NetBSD: add.c,v 1.28 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -272,11 +272,9 @@ cmd_add(int argc, char *argv[])
 	}
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		if (alignment % secsz != 0) {
 			warnx("Alignment must be a multiple of sector size;");

Index: src/sbin/gpt/backup.c
diff -u src/sbin/gpt/backup.c:1.8 src/sbin/gpt/backup.c:1.9
--- src/sbin/gpt/backup.c:1.8	Tue Sep 30 13:59:59 2014
+++ src/sbin/gpt/backup.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: backup.c,v 1.8 2014/09/30 17:59:59 christos Exp $");
+__RCSID("$NetBSD: backup.c,v 1.9 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/bootblock.h>
@@ -296,11 +296,9 @@ cmd_backup(int argc, char *argv[])
 		usage_backup();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 		backup();
 
 		gpt_close(fd);
Index: src/sbin/gpt/restore.c
diff -u src/sbin/gpt/restore.c:1.8 src/sbin/gpt/restore.c:1.9
--- src/sbin/gpt/restore.c:1.8	Tue Jun 16 19:18:55 2015
+++ src/sbin/gpt/restore.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: restore.c,v 1.8 2015/06/16 23:18:55 christos Exp $");
+__RCSID("$NetBSD: restore.c,v 1.9 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -403,11 +403,9 @@ cmd_restore(int argc, char *argv[])
 		usage_restore();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		restore(fd);
 

Index: src/sbin/gpt/biosboot.c
diff -u src/sbin/gpt/biosboot.c:1.14 src/sbin/gpt/biosboot.c:1.15
--- src/sbin/gpt/biosboot.c:1.14	Fri Oct  3 16:30:06 2014
+++ src/sbin/gpt/biosboot.c	Sat Nov 28 19:14:46 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosboot.c,v 1.14 2014/10/03 20:30:06 christos Exp $ */
+/*	$NetBSD: biosboot.c,v 1.15 2015/11/29 00:14:46 christos Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$NetBSD: biosboot.c,v 1.14 2014/10/03 20:30:06 christos Exp $");
+__RCSID("$NetBSD: biosboot.c,v 1.15 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/stat.h>
@@ -335,12 +335,10 @@ cmd_biosboot(int argc, char *argv[])
 	close:
 		close(fd);
 
-		fd = gpt_open(dev);
+		fd = gpt_open(dev, 0);
 	next:
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		if (fd == -1)
 			continue;
-		}
 
 		biosboot(fd);
 

Index: src/sbin/gpt/create.c
diff -u src/sbin/gpt/create.c:1.12 src/sbin/gpt/create.c:1.13
--- src/sbin/gpt/create.c:1.12	Fri Oct  3 16:30:06 2014
+++ src/sbin/gpt/create.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: create.c,v 1.12 2014/10/03 20:30:06 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.13 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -235,11 +235,9 @@ cmd_create(int argc, char *argv[])
 		usage_create();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], force);
+		if (fd == -1)
 			continue;
-		}
 
 		create(fd);
 

Index: src/sbin/gpt/destroy.c
diff -u src/sbin/gpt/destroy.c:1.6 src/sbin/gpt/destroy.c:1.7
--- src/sbin/gpt/destroy.c:1.6	Mon Sep 29 17:04:34 2014
+++ src/sbin/gpt/destroy.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/destroy.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: destroy.c,v 1.6 2014/09/29 21:04:34 christos Exp $");
+__RCSID("$NetBSD: destroy.c,v 1.7 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -49,8 +49,9 @@ __RCSID("$NetBSD: destroy.c,v 1.6 2014/0
 #include "gpt.h"
 
 static int recoverable;
+static int force;
 
-const char destroymsg[] = "destroy [-r] device ...";
+const char destroymsg[] = "destroy [-rf] device ...";
 
 __dead static void
 usage_destroy(void)
@@ -95,8 +96,11 @@ cmd_destroy(int argc, char *argv[])
 {
 	int ch, fd;
 
-	while ((ch = getopt(argc, argv, "r")) != -1) {
+	while ((ch = getopt(argc, argv, "fr")) != -1) {
 		switch(ch) {
+		case 'f':
+			force = 1;
+			break;
 		case 'r':
 			recoverable = 1;
 			break;
@@ -109,11 +113,9 @@ cmd_destroy(int argc, char *argv[])
 		usage_destroy();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], force);
+		if (fd == -1)
 			continue;
-		}
 
 		destroy(fd);
 
Index: src/sbin/gpt/recover.c
diff -u src/sbin/gpt/recover.c:1.6 src/sbin/gpt/recover.c:1.7
--- src/sbin/gpt/recover.c:1.6	Wed Jun 17 21:37:23 2015
+++ src/sbin/gpt/recover.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/recover.c,v 1.8 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: recover.c,v 1.6 2015/06/18 01:37:23 jnemeth Exp $");
+__RCSID("$NetBSD: recover.c,v 1.7 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -181,11 +181,9 @@ cmd_recover(int argc, char *argv[])
 		usage_recover();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		recover(fd);
 
Index: src/sbin/gpt/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.6 src/sbin/gpt/resizedisk.c:1.7
--- src/sbin/gpt/resizedisk.c:1.6	Tue Sep 30 23:52:42 2014
+++ src/sbin/gpt/resizedisk.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resizedisk.c,v 1.6 2014/10/01 03:52:42 jnemeth Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.7 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/bootblock.h>
@@ -267,11 +267,9 @@ cmd_resizedisk(int argc, char *argv[])
 		usage_resizedisk();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		if (size % secsz != 0) {
 			warnx("Size in bytes must be a multiple of sector "
Index: src/sbin/gpt/type.c
diff -u src/sbin/gpt/type.c:1.6 src/sbin/gpt/type.c:1.7
--- src/sbin/gpt/type.c:1.6	Sun Dec  7 04:51:42 2014
+++ src/sbin/gpt/type.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: type.c,v 1.6 2014/12/07 09:51:42 mlelstv Exp $");
+__RCSID("$NetBSD: type.c,v 1.7 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -228,11 +228,9 @@ cmd_type(int argc, char *argv[])
 		usage_type();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		chtype(fd);
 

Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.41 src/sbin/gpt/gpt.c:1.42
--- src/sbin/gpt/gpt.c:1.41	Mon Nov  2 21:19:24 2015
+++ src/sbin/gpt/gpt.c	Sat Nov 28 19:14:46 2015
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.41 2015/11/03 02:19:24 jnemeth Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.42 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -49,6 +49,7 @@ __RCSID("$NetBSD: gpt.c,v 1.41 2015/11/0
 #include <fcntl.h>
 #include <paths.h>
 #include <stddef.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -67,7 +68,7 @@ off_t	mediasz;
 u_int	parts;
 u_int	secsz;
 
-int	readonly, verbose;
+int	readonly, verbose, quiet;
 
 static uint32_t crc32_tab[] = {
 	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@@ -283,13 +284,15 @@ gpt_mbr(int fd, off_t lba)
 	unsigned int i, pmbr;
 
 	mbr = gpt_read(fd, lba, 1);
-	if (mbr == NULL)
+	if (mbr == NULL) {
+		if (!quiet)
+			warn("%s: read failed", device_name);
 		return (-1);
+	}
 
 	if (mbr->mbr_sig != htole16(MBR_SIG)) {
 		if (verbose)
-			warnx("%s: MBR not found at sector %llu", device_name,
-			    (long long)lba);
+			gpt_msg("MBR not found at sector %ju", (uintmax_t)lba);
 		free(mbr);
 		return (0);
 	}
@@ -309,20 +312,19 @@ gpt_mbr(int fd, off_t lba)
 			break;
 	}
 	if (pmbr && i == 4 && lba == 0) {
-		if (pmbr != 1)
-			warnx("%s: Suspicious PMBR at sector %llu",
-			    device_name, (long long)lba);
+		if (pmbr != 1 && !quiet)
+			warnx("%s: Suspicious PMBR at sector %ju",
+			    device_name, (uintmax_t)lba);
 		else if (verbose > 1)
-			warnx("%s: PMBR at sector %llu", device_name,
-			    (long long)lba);
+			gpt_msg("PMBR at sector %ju", (uintmax_t)lba);
 		p = map_add(lba, 1LL, MAP_TYPE_PMBR, mbr);
 		return ((p == NULL) ? -1 : 0);
 	}
-	if (pmbr)
-		warnx("%s: Suspicious MBR at sector %llu", device_name,
-		    (long long)lba);
+	if (pmbr && !quiet)
+		warnx("%s: Suspicious MBR at sector %ju", device_name,
+		    (uintmax_t)lba);
 	else if (verbose > 1)
-		warnx("%s: MBR at sector %llu", device_name, (long long)lba);
+		gpt_msg("MBR at sector %ju", (uintmax_t)lba);
 
 	p = map_add(lba, 1LL, MAP_TYPE_MBR, mbr);
 	if (p == NULL)
@@ -343,9 +345,9 @@ gpt_mbr(int fd, off_t lba)
 		/* start is relative to the offset of the MBR itself. */
 		start += lba;
 		if (verbose > 2)
-			warnx("%s: MBR part: type=%d, start=%llu, size=%llu",
-			    device_name, mbr->mbr_part[i].part_typ,
-			    (long long)start, (long long)size);
+			gpt_msg("MBR part: type=%d, start=%ju, size=%ju",
+			    mbr->mbr_part[i].part_typ,
+			    (uintmax_t)start, (uintmax_t)size);
 		if (mbr->mbr_part[i].part_typ != MBR_PTYPE_EXT_LBA) {
 			m = map_add(start, size, MAP_TYPE_MBR_PART, p);
 			if (m == NULL)
@@ -461,7 +463,7 @@ gpt_gpt(int fd, off_t lba, int found)
 }
 
 int
-gpt_open(const char *dev)
+gpt_open(const char *dev, int flags)
 {
 	struct stat sb;
 	int fd, mode, found;
@@ -470,27 +472,48 @@ gpt_open(const char *dev)
 
 	device_arg = device_name = dev;
 	fd = opendisk(dev, mode, device_path, sizeof(device_path), 0);
-	if (fd == -1)
+	if (fd == -1) {
+		if (!quiet)
+			warn("Cannot open `%s'", device_name);
 		return -1;
-	if (strncmp(device_path, _PATH_DEV, strlen(_PATH_DEV)) == 0)
-		device_name = device_path + strlen(_PATH_DEV);
-	else
-		device_name = device_path;
+	}
+	device_name = device_path;
 
-	if (fstat(fd, &sb) == -1)
+	if (fstat(fd, &sb) == -1) {
+		if (!quiet)
+			warn("Cannot stat `%s'", device_name);
 		goto close;
+	}
 
 	if ((sb.st_mode & S_IFMT) != S_IFREG) {
-#ifdef DIOCGSECTORSIZE
-		if ((secsz == 0 && ioctl(fd, DIOCGSECTORSIZE, &secsz) == -1) ||
-		    (mediasz == 0 && ioctl(fd, DIOCGMEDIASIZE, &mediasz) == -1))
-			goto close;
-#else
-		if (getdisksize(device_name, &secsz, &mediasz) == -1)
-			goto close;
-#endif
-		if (secsz == 0 || mediasz == 0)
-			errx(1, "Please specify sector/media size");
+		if (secsz == 0) {
+			if (ioctl(fd, DIOCGSECTORSIZE, &secsz) == -1) {
+				if (!quiet)
+					warn("Cannot get sector size for `%s'",
+					    device_name);
+				goto close;
+			}
+			if (secsz == 0) {
+				if (!quiet)
+					warnx("Sector size for `%s' can't be 0",
+					    device_name);
+				goto close;
+			}
+		}
+		if (mediasz == 0) {
+			if (ioctl(fd, DIOCGMEDIASIZE, &mediasz) == -1) {
+				if (!quiet)
+					warn("Cannot get media size for `%s'",
+					device_name);
+				goto close;
+			}
+			if (mediasz == 0) {
+				if (!quiet)
+					warnx("Media size for `%s' can't be 0",
+					    device_name);
+				goto close;
+			}
+		}
 	} else {
 		if (secsz == 0)
 			secsz = 512;	/* Fixed size for files. */
@@ -510,14 +533,16 @@ gpt_open(const char *dev)
 	 * we don't have to worry about it later.
 	 */
 	if (mediasz / secsz < 6) {
-		errno = ENODEV;
+		if (!quiet)
+			warnx("Need 6 sectors on '%s' we have %llu",
+			    device_name, (unsigned long long)(mediasz / secsz));
 		goto close;
 	}
 
-	if (verbose)
-		warnx("%s: mediasize=%llu; sectorsize=%u; blocks=%llu",
-		    device_name, (long long)mediasz, secsz,
-		    (long long)(mediasz / secsz));
+	if (verbose) {
+		gpt_msg("mediasize=%ju; sectorsize=%u; blocks=%ju",
+		    (uintmax_t)mediasz, secsz, (uintmax_t)(mediasz / secsz));
+	}
 
 	map_init(mediasz / secsz);
 
@@ -542,6 +567,17 @@ gpt_close(int fd)
 	close(fd);
 }
 
+void
+gpt_msg(const char *fmt, ...)
+{
+	va_list ap;
+	printf("%s: ", device_name);
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+	printf("\n");
+}
+
 static struct {
 	int (*fptr)(int, char *[]);
 	const char *name;
@@ -659,7 +695,7 @@ main(int argc, char *argv[])
 	int ch, i;
 
 	/* Get the generic options */
-	while ((ch = getopt(argc, argv, "m:p:rs:v")) != -1) {
+	while ((ch = getopt(argc, argv, "m:p:qrs:v")) != -1) {
 		switch(ch) {
 		case 'm':
 			if (mediasz > 0)
@@ -678,6 +714,9 @@ main(int argc, char *argv[])
 		case 'r':
 			readonly = 1;
 			break;
+		case 'q':
+			quiet = 1;
+			break;
 		case 's':
 			if (secsz > 0)
 				usage();

Index: src/sbin/gpt/gpt.h
diff -u src/sbin/gpt/gpt.h:1.19 src/sbin/gpt/gpt.h:1.20
--- src/sbin/gpt/gpt.h:1.19	Mon Nov  2 21:19:24 2015
+++ src/sbin/gpt/gpt.h	Sat Nov 28 19:14:46 2015
@@ -65,14 +65,15 @@ extern const char *device_name;
 extern off_t mediasz;
 extern u_int parts;
 extern u_int secsz;
-extern int readonly, verbose;
+extern int readonly, verbose, quiet;
 
 uint32_t crc32(const void *, size_t);
 void	gpt_close(int);
 int	gpt_gpt(int, off_t, int);
-int	gpt_open(const char *);
+int	gpt_open(const char *, int);
 void*	gpt_read(int, off_t, size_t);
 int	gpt_write(int, map_t *);
+void	gpt_msg(const char *, ...) __printflike(1, 2);
 
 uint8_t *utf16_to_utf8(uint16_t *);
 void	utf8_to_utf16(const uint8_t *, uint16_t *, size_t);
@@ -105,4 +106,6 @@ int	getdisksize(const char *, u_int *, o
 # define getdisksize(a, b, c) 0
 #endif
 
+#define GPT_FORCE 1
+
 #endif /* _GPT_H_ */

Index: src/sbin/gpt/header.c
diff -u src/sbin/gpt/header.c:1.2 src/sbin/gpt/header.c:1.3
--- src/sbin/gpt/header.c:1.2	Mon Nov 16 07:24:13 2015
+++ src/sbin/gpt/header.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$NetBSD: header.c,v 1.2 2015/11/16 12:24:13 jnemeth Exp $");
+__RCSID("$NetBSD: header.c,v 1.3 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -134,11 +134,9 @@ cmd_header(int argc, char *argv[])
 		usage_header();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 		header();
 
 		gpt_close(fd);

Index: src/sbin/gpt/label.c
diff -u src/sbin/gpt/label.c:1.18 src/sbin/gpt/label.c:1.19
--- src/sbin/gpt/label.c:1.18	Tue Sep 30 13:59:59 2014
+++ src/sbin/gpt/label.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: label.c,v 1.18 2014/09/30 17:59:59 christos Exp $");
+__RCSID("$NetBSD: label.c,v 1.19 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -259,11 +259,9 @@ cmd_label(int argc, char *argv[])
 		usage_label();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		label(fd);
 

Index: src/sbin/gpt/migrate.c
diff -u src/sbin/gpt/migrate.c:1.21 src/sbin/gpt/migrate.c:1.22
--- src/sbin/gpt/migrate.c:1.21	Fri Oct  3 16:30:06 2014
+++ src/sbin/gpt/migrate.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: migrate.c,v 1.21 2014/10/03 20:30:06 christos Exp $");
+__RCSID("$NetBSD: migrate.c,v 1.22 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -459,11 +459,9 @@ cmd_migrate(int argc, char *argv[])
 		usage_migrate();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		migrate(fd);
 
Index: src/sbin/gpt/show.c
diff -u src/sbin/gpt/show.c:1.21 src/sbin/gpt/show.c:1.22
--- src/sbin/gpt/show.c:1.21	Tue Sep 30 18:56:36 2014
+++ src/sbin/gpt/show.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: show.c,v 1.21 2014/09/30 22:56:36 jnemeth Exp $");
+__RCSID("$NetBSD: show.c,v 1.22 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -255,11 +255,9 @@ cmd_show(int argc, char *argv[])
 		usage_show();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		if (entry > 0)
 			show_one();

Index: src/sbin/gpt/remove.c
diff -u src/sbin/gpt/remove.c:1.16 src/sbin/gpt/remove.c:1.17
--- src/sbin/gpt/remove.c:1.16	Tue Sep 30 13:59:59 2014
+++ src/sbin/gpt/remove.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: remove.c,v 1.16 2014/09/30 17:59:59 christos Exp $");
+__RCSID("$NetBSD: remove.c,v 1.17 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -219,11 +219,9 @@ cmd_remove(int argc, char *argv[])
 		usage_remove();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		rem(fd);
 

Index: src/sbin/gpt/resize.c
diff -u src/sbin/gpt/resize.c:1.11 src/sbin/gpt/resize.c:1.12
--- src/sbin/gpt/resize.c:1.11	Tue Sep 30 13:59:59 2014
+++ src/sbin/gpt/resize.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resize.c,v 1.11 2014/09/30 17:59:59 christos Exp $");
+__RCSID("$NetBSD: resize.c,v 1.12 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -236,11 +236,9 @@ cmd_resize(int argc, char *argv[])
 		usage_resize();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		if (alignment % secsz != 0) {
 			warnx("Alignment must be a multiple of sector size;");

Index: src/sbin/gpt/set.c
diff -u src/sbin/gpt/set.c:1.5 src/sbin/gpt/set.c:1.6
--- src/sbin/gpt/set.c:1.5	Tue Sep 30 14:00:00 2014
+++ src/sbin/gpt/set.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: set.c,v 1.5 2014/09/30 18:00:00 christos Exp $");
+__RCSID("$NetBSD: set.c,v 1.6 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -174,11 +174,9 @@ cmd_set(int argc, char *argv[])
 		usage_set();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		set(fd);
 
Index: src/sbin/gpt/unset.c
diff -u src/sbin/gpt/unset.c:1.5 src/sbin/gpt/unset.c:1.6
--- src/sbin/gpt/unset.c:1.5	Tue Sep 30 14:00:00 2014
+++ src/sbin/gpt/unset.c	Sat Nov 28 19:14:46 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: unset.c,v 1.5 2014/09/30 18:00:00 christos Exp $");
+__RCSID("$NetBSD: unset.c,v 1.6 2015/11/29 00:14:46 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -174,11 +174,9 @@ cmd_unset(int argc, char *argv[])
 		usage_unset();
 
 	while (optind < argc) {
-		fd = gpt_open(argv[optind++]);
-		if (fd == -1) {
-			warn("unable to open device '%s'", device_name);
+		fd = gpt_open(argv[optind++], 0);
+		if (fd == -1)
 			continue;
-		}
 
 		unset(fd);
 

Reply via email to