Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/gpt fix build breakage for systems that do not have DIO...
details: https://anonhg.NetBSD.org/src/rev/e79072941fbd
branches: trunk
changeset: 341919:e79072941fbd
user: jnemeth <jnemeth%NetBSD.org@localhost>
date: Sun Nov 29 13:24:28 2015 +0000
description:
fix build breakage for systems that do not have DIOCG{SECTOR,MEDIA}SIZE
diffstat:
sbin/gpt/gpt.c | 44 +++++++++++++++++---------------------------
1 files changed, 17 insertions(+), 27 deletions(-)
diffs (63 lines):
diff -r dea9aaa1f64b -r e79072941fbd sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c Sun Nov 29 09:10:05 2015 +0000
+++ b/sbin/gpt/gpt.c Sun Nov 29 13:24:28 2015 +0000
@@ -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.42 2015/11/29 00:14:46 christos Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.43 2015/11/29 13:24:28 jnemeth Exp $");
#endif
#include <sys/param.h>
@@ -486,34 +486,24 @@
}
if ((sb.st_mode & S_IFMT) != S_IFREG) {
- 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;
- }
+#ifdef DIOCGSECTORSIZE
+ if ((secsz == 0 && ioctl(fd, DIOCGSECTORSIZE, &secsz) == -1) ||
+ (mediasz == 0 && ioctl(fd, DIOCGMEDIASIZE, &mediasz) == -1)) {
+ if (!quiet)
+ warn("Cannot get sector/media size for `%s'",
+ 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 (getdisksize(device_name, &secsz, &mediasz) == -1) {
+ if (!quiet)
+ warn("Cannot get sector/media size for `%s'",
+ device_name);
+ goto close;
}
+#endif
+ if (secsz == 0 || mediasz == 0)
+ errx(1, "Please specify sector/media size");
} else {
if (secsz == 0)
secsz = 512; /* Fixed size for files. */
Home |
Main Index |
Thread Index |
Old Index