Module Name: src
Committed By: christos
Date: Thu Dec 3 02:02:43 UTC 2015
Modified Files:
src/sbin/gpt: Makefile add.c biosboot.c create.c gpt.c gpt.h gpt_uuid.c
header.c main.c migrate.c recover.c resize.c resizedisk.c restore.c
set.c show.c unset.c
Log Message:
WARNS=6
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/gpt/Makefile src/sbin/gpt/create.c
cvs rdiff -u -r1.38 -r1.39 src/sbin/gpt/add.c
cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/biosboot.c
cvs rdiff -u -r1.58 -r1.59 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.11 -r1.12 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/gpt/header.c
cvs rdiff -u -r1.5 -r1.6 src/sbin/gpt/main.c
cvs rdiff -u -r1.26 -r1.27 src/sbin/gpt/migrate.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/recover.c src/sbin/gpt/resizedisk.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/resize.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/restore.c
cvs rdiff -u -r1.10 -r1.11 src/sbin/gpt/set.c src/sbin/gpt/unset.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/gpt/show.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/Makefile
diff -u src/sbin/gpt/Makefile:1.17 src/sbin/gpt/Makefile:1.18
--- src/sbin/gpt/Makefile:1.17 Tue Dec 1 04:05:33 2015
+++ src/sbin/gpt/Makefile Wed Dec 2 21:02:43 2015
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.17 2015/12/01 09:05:33 christos Exp $
+# $NetBSD: Makefile,v 1.18 2015/12/03 02:02:43 christos Exp $
# $FreeBSD: src/sbin/gpt/Makefile,v 1.7 2005/09/01 02:49:20 marcel Exp $
.include <bsd.own.mk>
+WARNS=6
PROG= gpt
SRCS= add.c biosboot.c create.c destroy.c gpt.c header.c label.c map.c \
main.c migrate.c recover.c remove.c resize.c resizedisk.c \
Index: src/sbin/gpt/create.c
diff -u src/sbin/gpt/create.c:1.17 src/sbin/gpt/create.c:1.18
--- src/sbin/gpt/create.c:1.17 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/create.c Wed Dec 2 21:02:43 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.17 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.18 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -138,7 +138,8 @@ cmd_create(gpt_t gpt, int argc, char *ar
primary_only = 1;
break;
case 'p':
- parts = atoi(optarg);
+ if (gpt_uint_get(&parts) == -1)
+ return -1;
break;
default:
return usage();
Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.38 src/sbin/gpt/add.c:1.39
--- src/sbin/gpt/add.c:1.38 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/add.c Wed Dec 2 21:02:43 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.38 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: add.c,v 1.39 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -72,8 +72,9 @@ ent_set(struct gpt_ent *ent, const map_t
const uint8_t *xname)
{
gpt_uuid_copy(ent->ent_type, xtype);
- ent->ent_lba_start = htole64(map->map_start);
- ent->ent_lba_end = htole64(map->map_start + map->map_size - 1LL);
+ ent->ent_lba_start = htole64((uint64_t)map->map_start);
+ ent->ent_lba_end = htole64((uint64_t)(map->map_start +
+ map->map_size - 1LL));
if (xname == NULL)
return;
utf8_to_utf16(xname, ent->ent_name, __arraycount(ent->ent_name));
@@ -193,7 +194,7 @@ cmd_add(gpt_t gpt, int argc, char *argv[
if (optind != argc)
return usage();
- if ((sectors = gpt_check_ais(gpt, alignment, ~0, size)) == -1)
+ if ((sectors = gpt_check_ais(gpt, alignment, ~0U, size)) == -1)
return -1;
return add(gpt, alignment, block, sectors, size, entry, name, type);
Index: src/sbin/gpt/biosboot.c
diff -u src/sbin/gpt/biosboot.c:1.21 src/sbin/gpt/biosboot.c:1.22
--- src/sbin/gpt/biosboot.c:1.21 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/biosboot.c Wed Dec 2 21:02:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: biosboot.c,v 1.21 2015/12/03 01:07:28 christos Exp $ */
+/* $NetBSD: biosboot.c,v 1.22 2015/12/03 02:02:43 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.21 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: biosboot.c,v 1.22 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/stat.h>
@@ -126,7 +126,7 @@ read_boot(gpt_t gpt, const char *bootpat
goto fail;
}
- if (read(bfd, buf, st.st_size) != st.st_size) {
+ if (read(bfd, buf, (size_t)st.st_size) != (ssize_t)st.st_size) {
gpt_warn(gpt, "Error reading from `%s'", bp);
goto fail;
}
@@ -266,7 +266,7 @@ cmd_biosboot(gpt_t gpt, int argc, char *
return usage();
break;
case 'i':
- if (gpt_entry_get(&entry) == -1)
+ if (gpt_uint_get(&entry) == -1)
return usage();
break;
case 'L':
Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.58 src/sbin/gpt/gpt.c:1.59
--- src/sbin/gpt/gpt.c:1.58 Wed Dec 2 15:09:33 2015
+++ src/sbin/gpt/gpt.c Wed Dec 2 21:02:43 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.58 2015/12/02 20:09:33 christos Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.59 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/param.h>
@@ -144,25 +144,25 @@ utf16_to_utf8(const uint16_t *s16, uint8
if (utfchar < 0x80) {
if (s8idx + 1 >= s8len)
break;
- s8[s8idx++] = utfchar;
+ s8[s8idx++] = (uint8_t)utfchar;
} else if (utfchar < 0x800) {
if (s8idx + 2 >= s8len)
break;
- s8[s8idx++] = 0xc0 | (utfchar >> 6);
- s8[s8idx++] = 0x80 | (utfchar & 0x3f);
+ s8[s8idx++] = (uint8_t)(0xc0 | (utfchar >> 6));
+ s8[s8idx++] = (uint8_t)(0x80 | (utfchar & 0x3f));
} else if (utfchar < 0x10000) {
if (s8idx + 3 >= s8len)
break;
- s8[s8idx++] = 0xe0 | (utfchar >> 12);
- s8[s8idx++] = 0x80 | ((utfchar >> 6) & 0x3f);
- s8[s8idx++] = 0x80 | (utfchar & 0x3f);
+ s8[s8idx++] = (uint8_t)(0xe0 | (utfchar >> 12));
+ s8[s8idx++] = (uint8_t)(0x80 | ((utfchar >> 6) & 0x3f));
+ s8[s8idx++] = (uint8_t)(0x80 | (utfchar & 0x3f));
} else if (utfchar < 0x200000) {
if (s8idx + 4 >= s8len)
break;
- s8[s8idx++] = 0xf0 | (utfchar >> 18);
- s8[s8idx++] = 0x80 | ((utfchar >> 12) & 0x3f);
- s8[s8idx++] = 0x80 | ((utfchar >> 6) & 0x3f);
- s8[s8idx++] = 0x80 | (utfchar & 0x3f);
+ s8[s8idx++] = (uint8_t)(0xf0 | (utfchar >> 18));
+ s8[s8idx++] = (uint8_t)(0x80 | ((utfchar >> 12) & 0x3f));
+ s8[s8idx++] = (uint8_t)(0x80 | ((utfchar >> 6) & 0x3f));
+ s8[s8idx++] = (uint8_t)(0x80 | (utfchar & 0x3f));
}
}
s8[s8idx] = 0;
@@ -211,18 +211,18 @@ utf8_to_utf16(const uint8_t *s8, uint16_
utfchar = (utfchar << 6) + (c & 0x3f);
utfbytes--;
} else if (utfbytes == 0)
- utfbytes = -1;
+ utfbytes = (u_int)~0;
}
if (utfbytes == 0) {
if (utfchar >= 0x10000 && s16idx + 2 >= s16len)
utfchar = 0xfffd;
if (utfchar >= 0x10000) {
- s16[s16idx++] =
- htole16(0xd800 | ((utfchar>>10)-0x40));
- s16[s16idx++] =
- htole16(0xdc00 | (utfchar & 0x3ff));
+ s16[s16idx++] = htole16((uint16_t)
+ (0xd800 | ((utfchar>>10) - 0x40)));
+ s16[s16idx++] = htole16((uint16_t)
+ (0xdc00 | (utfchar & 0x3ff)));
} else
- s16[s16idx++] = htole16(utfchar);
+ s16[s16idx++] = htole16((uint16_t)utfchar);
if (s16idx == s16len) {
s16[--s16idx] = 0;
return;
@@ -257,7 +257,7 @@ gpt_write(gpt_t gpt, map_t map)
off_t ofs;
size_t count;
- count = map->map_size * gpt->secsz;
+ count = (size_t)(map->map_size * gpt->secsz);
ofs = map->map_start * gpt->secsz;
if (lseek(gpt->fd, ofs, SEEK_SET) != ofs ||
write(gpt->fd, map->map_data, count) != (ssize_t)count)
@@ -391,7 +391,7 @@ gpt_gpt(gpt_t gpt, off_t lba, int found)
blocks = tblsz / gpt->secsz + ((tblsz % gpt->secsz) ? 1 : 0);
/* Use generic pointer to deal with hdr->hdr_entsz != sizeof(*ent). */
- p = gpt_read(gpt, le64toh(hdr->hdr_lba_table), blocks);
+ p = gpt_read(gpt, (off_t)le64toh((uint64_t)hdr->hdr_lba_table), blocks);
if (p == NULL) {
if (found) {
if (gpt->verbose)
@@ -419,8 +419,9 @@ gpt_gpt(gpt_t gpt, off_t lba, int found)
if (m == NULL)
return (-1);
- m = map_add(gpt, le64toh(hdr->hdr_lba_table), blocks, (lba == 1)
- ? MAP_TYPE_PRI_GPT_TBL : MAP_TYPE_SEC_GPT_TBL, p);
+ m = map_add(gpt, (off_t)le64toh((uint64_t)hdr->hdr_lba_table),
+ (off_t)blocks,
+ lba == 1 ? MAP_TYPE_PRI_GPT_TBL : MAP_TYPE_SEC_GPT_TBL, p);
if (m == NULL)
return (-1);
@@ -432,8 +433,8 @@ gpt_gpt(gpt_t gpt, off_t lba, int found)
if (gpt_uuid_is_nil(ent->ent_type))
continue;
- size = le64toh(ent->ent_lba_end) - le64toh(ent->ent_lba_start) +
- 1LL;
+ size = (off_t)(le64toh((uint64_t)ent->ent_lba_end) -
+ le64toh((uint64_t)ent->ent_lba_start) + 1LL);
if (gpt->verbose > 2) {
char buf[128];
gpt_uuid_snprintf(buf, sizeof(buf), "%s",
@@ -444,8 +445,8 @@ gpt_gpt(gpt_t gpt, off_t lba, int found)
(uintmax_t)size);
}
// XXX: map add with not allocated memory.
- m = map_add(gpt, le64toh(ent->ent_lba_start), size,
- MAP_TYPE_GPT_PART, ent);
+ m = map_add(gpt, (off_t)le64toh((uint64_t)ent->ent_lba_start),
+ size, MAP_TYPE_GPT_PART, ent);
if (m == NULL)
return (-1);
m->map_index = i + 1;
@@ -711,8 +712,8 @@ gpt_create_pmbr_part(struct mbr_part *pa
part->part_size_lo = htole16(0xffff);
part->part_size_hi = htole16(0xffff);
} else {
- part->part_size_lo = htole16(last);
- part->part_size_hi = htole16(last >> 16);
+ part->part_size_lo = htole16((uint16_t)last);
+ part->part_size_hi = htole16((uint16_t)(last >> 16));
}
}
@@ -774,7 +775,7 @@ gpt_last(gpt_t gpt)
return gpt->mediasz / gpt->secsz - 1LL;
}
-int
+off_t
gpt_create(gpt_t gpt, off_t last, u_int parts, int primary_only)
{
off_t blocks;
@@ -800,7 +801,7 @@ gpt_create(gpt_t gpt, off_t last, u_int
/* Don't create more than parts entries. */
if ((uint64_t)(blocks - 1) * gpt->secsz >
parts * sizeof(struct gpt_ent)) {
- blocks = (parts * sizeof(struct gpt_ent)) / gpt->secsz;
+ blocks = (off_t)((parts * sizeof(struct gpt_ent)) / gpt->secsz);
if ((parts * sizeof(struct gpt_ent)) % gpt->secsz)
blocks++;
blocks++; /* Don't forget the header itself */
@@ -840,7 +841,7 @@ gpt_create(gpt_t gpt, off_t last, u_int
return -1;
}
- if ((p = calloc(blocks, gpt->secsz)) == NULL) {
+ if ((p = calloc((size_t)blocks, gpt->secsz)) == NULL) {
gpt_warnx(gpt, "Can't allocate the primary GPT table");
return -1;
}
@@ -860,15 +861,15 @@ gpt_create(gpt_t gpt, off_t last, u_int
*/
hdr->hdr_revision = htole32(GPT_HDR_REVISION);
hdr->hdr_size = htole32(GPT_HDR_SIZE);
- hdr->hdr_lba_self = htole64(gpt->gpt->map_start);
- hdr->hdr_lba_alt = htole64(last);
- hdr->hdr_lba_start = htole64(gpt->tbl->map_start + blocks);
- hdr->hdr_lba_end = htole64(last - blocks - 1LL);
+ hdr->hdr_lba_self = htole64((uint64_t)gpt->gpt->map_start);
+ hdr->hdr_lba_alt = htole64((uint64_t)last);
+ hdr->hdr_lba_start = htole64((uint64_t)(gpt->tbl->map_start + blocks));
+ hdr->hdr_lba_end = htole64((uint64_t)(last - blocks - 1LL));
if (gpt_uuid_generate(gpt, hdr->hdr_guid) == -1)
return -1;
- hdr->hdr_lba_table = htole64(gpt->tbl->map_start);
- hdr->hdr_entries = htole32((blocks * gpt->secsz) /
- sizeof(struct gpt_ent));
+ hdr->hdr_lba_table = htole64((uint64_t)(gpt->tbl->map_start));
+ hdr->hdr_entries = htole32((uint32_t)(((uint64_t)blocks * gpt->secsz) /
+ sizeof(struct gpt_ent)));
if (le32toh(hdr->hdr_entries) > parts)
hdr->hdr_entries = htole32(parts);
hdr->hdr_entsz = htole32(sizeof(struct gpt_ent));
@@ -905,9 +906,9 @@ gpt_create(gpt_t gpt, off_t last, u_int
memcpy(gpt->tpg->map_data, gpt->gpt->map_data, gpt->secsz);
hdr = gpt->tpg->map_data;
- hdr->hdr_lba_self = htole64(gpt->tpg->map_start);
- hdr->hdr_lba_alt = htole64(gpt->gpt->map_start);
- hdr->hdr_lba_table = htole64(gpt->lbt->map_start);
+ hdr->hdr_lba_self = htole64((uint64_t)gpt->tpg->map_start);
+ hdr->hdr_lba_alt = htole64((uint64_t)gpt->gpt->map_start);
+ hdr->hdr_lba_table = htole64((uint64_t)gpt->lbt->map_start);
return last;
}
@@ -966,7 +967,7 @@ gpt_add_find(gpt_t gpt, struct gpt_find
return -1;
break;
case 'i':
- if (gpt_entry_get(&find->entry) == -1)
+ if (gpt_uint_get(&find->entry) == -1)
return -1;
break;
case 'L':
@@ -1058,7 +1059,7 @@ gpt_add_ais(gpt_t gpt, off_t *alignment,
return -1;
return 0;
case 'i':
- if (gpt_entry_get(entry) == -1)
+ if (gpt_uint_get(entry) == -1)
return -1;
return 0;
case 's':
@@ -1150,12 +1151,12 @@ gpt_attr_update(gpt_t gpt, u_int entry,
}
int
-gpt_entry_get(u_int *entry)
+gpt_uint_get(u_int *entry)
{
char *p;
if (*entry > 0)
return -1;
- *entry = strtoul(optarg, &p, 10);
+ *entry = (u_int)strtoul(optarg, &p, 10);
if (*p != 0 || *entry < 1)
return -1;
return 0;
@@ -1185,3 +1186,20 @@ gpt_name_get(gpt_t gpt, void *v)
}
return 0;
}
+
+void
+gpt_show_num(const char *prompt, uintmax_t num)
+{
+#ifdef HN_AUTOSCALE
+ char human_num[5];
+ if (humanize_number(human_num, 5, (int64_t)num ,
+ "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
+ human_num[0] = '\0';
+#endif
+ printf("%s: %ju", prompt, num);
+#ifdef HN_AUTOSCALE
+ if (human_num[0] != '\0')
+ printf("(%s)", human_num);
+#endif
+ printf("\n");
+}
Index: src/sbin/gpt/gpt.h
diff -u src/sbin/gpt/gpt.h:1.27 src/sbin/gpt/gpt.h:1.28
--- src/sbin/gpt/gpt.h:1.27 Tue Dec 1 23:07:11 2015
+++ src/sbin/gpt/gpt.h Wed Dec 2 21:02:43 2015
@@ -82,7 +82,7 @@ gpt_t gpt_open(const char *, int, int, o
void* gpt_read(gpt_t, off_t, size_t);
off_t gpt_last(gpt_t);
-int gpt_create(gpt_t, off_t, u_int, int);
+off_t gpt_create(gpt_t, off_t, u_int, int);
int gpt_write(gpt_t, map_t);
int gpt_write_crc(gpt_t, map_t, map_t);
int gpt_write_primary(gpt_t);
@@ -120,9 +120,10 @@ off_t gpt_check_ais(gpt_t, off_t, u_int,
int gpt_attr_get(uint64_t *);
int gpt_attr_update(gpt_t, u_int, uint64_t, uint64_t);
-int gpt_entry_get(u_int *);
+int gpt_uint_get(u_int *);
int gpt_human_get(off_t *);
int gpt_uuid_get(gpt_t, gpt_uuid_t *);
int gpt_name_get(gpt_t, void *);
+void gpt_show_num(const char *, uintmax_t);
#endif /* _GPT_H_ */
Index: src/sbin/gpt/gpt_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.11 src/sbin/gpt/gpt_uuid.c:1.12
--- src/sbin/gpt/gpt_uuid.c:1.11 Tue Dec 1 18:29:07 2015
+++ src/sbin/gpt/gpt_uuid.c Wed Dec 2 21:02:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: gpt_uuid.c,v 1.11 2015/12/01 23:29:07 christos Exp $ */
+/* $NetBSD: gpt_uuid.c,v 1.12 2015/12/03 02:02:43 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
-__RCSID("$NetBSD: gpt_uuid.c,v 1.11 2015/12/01 23:29:07 christos Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.12 2015/12/03 02:02:43 christos Exp $");
#endif
#include <err.h>
@@ -136,7 +136,7 @@ gpt_uuid_symbolic(char *buf, size_t bufs
for (i = 0; i < __arraycount(gpt_nv); i++)
if (memcmp(&gpt_nv[i].u, u, sizeof(*u)) == 0)
- return strlcpy(buf, gpt_nv[i].n, bufsiz);
+ return (int)strlcpy(buf, gpt_nv[i].n, bufsiz);
return -1;
}
@@ -147,7 +147,7 @@ gpt_uuid_descriptive(char *buf, size_t b
for (i = 0; i < __arraycount(gpt_nv); i++)
if (memcmp(&gpt_nv[i].u, u, sizeof(*u)) == 0)
- return strlcpy(buf, gpt_nv[i].d, bufsiz);
+ return (int)strlcpy(buf, gpt_nv[i].d, bufsiz);
return -1;
}
@@ -253,7 +253,7 @@ gpt_uuid_generate(gpt_t gpt, gpt_uuid_t
gpt_warn(gpt, "Can't open `/dev/urandom'");
return -1;
}
- for (p = (void *)&u, n = sizeof u; 0 < n; p += nread, n -= nread) {
+ for (p = (void *)&u, n = sizeof u; n > 0; p += nread, n -= (size_t)nread) {
nread = read(fd, p, n);
if (nread < 0) {
gpt_warn(gpt, "Can't read `/dev/urandom'");
@@ -271,11 +271,11 @@ gpt_uuid_generate(gpt_t gpt, gpt_uuid_t
(void)close(fd);
/* Set the version number to 4. */
- u.time_hi_and_version &= ~(uint32_t)0xf000;
+ u.time_hi_and_version &= (uint16_t)~0xf000;
u.time_hi_and_version |= 0x4000;
/* Fix the reserved bits. */
- u.clock_seq_hi_and_reserved &= ~(uint8_t)0x40;
+ u.clock_seq_hi_and_reserved &= (uint8_t)~0x40;
u.clock_seq_hi_and_reserved |= 0x80;
gpt_dce_to_uuid(&u, t);
Index: src/sbin/gpt/header.c
diff -u src/sbin/gpt/header.c:1.6 src/sbin/gpt/header.c:1.7
--- src/sbin/gpt/header.c:1.6 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/header.c Wed Dec 2 21:02:43 2015
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
-__RCSID("$NetBSD: header.c,v 1.6 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: header.c,v 1.7 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -71,34 +71,12 @@ header(gpt_t gpt)
map_t map;
struct gpt_hdr *hdr;
char buf[128];
-#ifdef HN_AUTOSCALE
- char human_num[5];
-#endif
-
-#ifdef HN_AUTOSCALE
- if (humanize_number(human_num, 5, gpt->mediasz,
- "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
- human_num[0] = '\0';
- if (human_num[0] != '\0')
- printf("Media Size: %ju (%s)\n", (uintmax_t)gpt->mediasz,
- human_num);
- else
-#endif
- printf("Media Size: %ju\n", (uintmax_t)gpt->mediasz);
+ gpt_show_num("Media Size", (uintmax_t)gpt->mediasz);
printf("Sector Size: %u\n", gpt->secsz);
-#ifdef HN_AUTOSCALE
- if (humanize_number(human_num, 5, gpt->mediasz / gpt->secsz,
- "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
- human_num[0] = '\0';
- if (human_num[0] != '\0')
- printf("Number of Sectors: %ju (%s)\n",
- (uintmax_t)(gpt->mediasz / gpt->secsz), human_num);
- else
-#endif
- printf("Number of Sectors: %ju\n",
- (uintmax_t)(gpt->mediasz / gpt->secsz));
+ gpt_show_num("Number of Sectors",
+ (uintmax_t)(gpt->mediasz / gpt->secsz));
printf("\nHeader Information:\n");
@@ -112,19 +90,8 @@ header(gpt_t gpt)
revision = le32toh(hdr->hdr_revision);
printf("- GPT Header Revision: %u.%u\n", revision >> 16,
revision & 0xffff);
- printf("- First Data Sector: %ju\n",
- (uintmax_t)hdr->hdr_lba_start);
-#ifdef HN_AUTOSCALE
- if (humanize_number(human_num, 5, hdr->hdr_lba_end,
- "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
- human_num[0] = '\0';
- if (human_num[0] != '\0')
- printf("- Last Data Sector: %ju (%s)\n",
- (uintmax_t)hdr->hdr_lba_end, human_num);
- else
-#endif
- printf("- Last Data Sector: %ju\n",
- (uintmax_t)hdr->hdr_lba_end);
+ gpt_show_num("- First Data Sector", hdr->hdr_lba_start);
+ gpt_show_num("- Last Data Sector", hdr->hdr_lba_end);
gpt_uuid_snprintf(buf, sizeof(buf), "%d", hdr->hdr_guid);
printf("- Media GUID: %s\n", buf);
printf("- Number of GPT Entries: %u\n", hdr->hdr_entries);
Index: src/sbin/gpt/main.c
diff -u src/sbin/gpt/main.c:1.5 src/sbin/gpt/main.c:1.6
--- src/sbin/gpt/main.c:1.5 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/main.c Wed Dec 2 21:02:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.5 2015/12/03 01:07:28 christos Exp $ */
+/* $NetBSD: main.c,v 1.6 2015/12/03 02:02:43 christos Exp $ */
/*-
* Copyright (c) 2002 Marcel Moolenaar
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
-__RCSID("$NetBSD: main.c,v 1.5 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.6 2015/12/03 02:02:43 christos Exp $");
#endif
#include <stdio.h>
@@ -151,7 +151,7 @@ main(int argc, char *argv[])
case 'm':
if (mediasz > 0)
usage();
- mediasz = strtoul(optarg, &p, 10);
+ mediasz = strtol(optarg, &p, 10);
if (*p != 0 || mediasz < 1)
usage();
break;
@@ -165,10 +165,7 @@ main(int argc, char *argv[])
flags |= GPT_QUIET;
break;
case 's':
- if (secsz > 0)
- usage();
- secsz = strtoul(optarg, &p, 10);
- if (*p != 0 || secsz < 1)
+ if (gpt_uint_get(&secsz) == -1)
usage();
break;
case 'v':
Index: src/sbin/gpt/migrate.c
diff -u src/sbin/gpt/migrate.c:1.26 src/sbin/gpt/migrate.c:1.27
--- src/sbin/gpt/migrate.c:1.26 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/migrate.c Wed Dec 2 21:02:43 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.26 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: migrate.c,v 1.27 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -158,9 +158,10 @@ migrate_disklabel(gpt_t gpt, off_t start
ofs = (le32toh(dl->d_partitions[i].p_offset) *
le32toh(dl->d_secsize)) / gpt->secsz;
ofs = (ofs > 0) ? ofs - rawofs : 0;
- ent->ent_lba_start = htole64(start + ofs);
- ent->ent_lba_end = htole64(start + ofs +
- le32toh(dl->d_partitions[i].p_size) - 1LL);
+ ent->ent_lba_start = htole64((uint64_t)(start + ofs));
+ ent->ent_lba_end = htole64((uint64_t)(start + ofs +
+ (off_t)le32toh((uint64_t)dl->d_partitions[i].p_size)
+ - 1LL));
ent++;
}
@@ -245,9 +246,10 @@ migrate_netbsd_disklabel(gpt_t gpt, off_
ofs = (le32toh(dl->d_partitions[i].p_offset) *
le32toh(dl->d_secsize)) / gpt->secsz;
ofs = (ofs > 0) ? ofs - rawofs : 0;
- ent->ent_lba_start = htole64(ofs);
- ent->ent_lba_end = htole64(ofs +
- le32toh(dl->d_partitions[i].p_size) - 1LL);
+ ent->ent_lba_start = htole64((uint64_t)ofs);
+ ent->ent_lba_end = htole64((uint64_t)(ofs +
+ (off_t)le32toh((uint64_t)dl->d_partitions[i].p_size)
+ - 1LL));
ent++;
}
@@ -294,7 +296,8 @@ migrate(gpt_t gpt, u_int parts, int forc
ent->ent_type, ent->ent_name,
sizeof(ent->ent_name));
ent->ent_lba_start = htole64((uint64_t)start);
- ent->ent_lba_end = htole64(start + size - 1LL);
+ ent->ent_lba_end = htole64(
+ (uint64_t)(start + size - 1LL));
ent++;
} else
ent = migrate_disklabel(gpt, start, ent);
@@ -308,7 +311,8 @@ migrate(gpt_t gpt, u_int parts, int forc
ent->ent_type, ent->ent_name,
sizeof(ent->ent_name));
ent->ent_lba_start = htole64((uint64_t)start);
- ent->ent_lba_end = htole64(start + size - 1LL);
+ ent->ent_lba_end = htole64(
+ (uint64_t)(start + size - 1LL));
ent++;
break;
}
@@ -355,7 +359,8 @@ cmd_migrate(gpt_t gpt, int argc, char *a
force = 1;
break;
case 'p':
- parts = atoi(optarg);
+ if (gpt_uint_get(&parts) == -1)
+ return usage();
break;
case 's':
slice = 1;
Index: src/sbin/gpt/recover.c
diff -u src/sbin/gpt/recover.c:1.12 src/sbin/gpt/recover.c:1.13
--- src/sbin/gpt/recover.c:1.12 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/recover.c Wed Dec 2 21:02:43 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.12 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: recover.c,v 1.13 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -104,9 +104,9 @@ recover_gpt_hdr(gpt_t gpt, int type, off
}
memcpy((*dgpt)->map_data, sgpt->map_data, gpt->secsz);
hdr = (*dgpt)->map_data;
- hdr->hdr_lba_self = htole64((*dgpt)->map_start);
- hdr->hdr_lba_alt = htole64(stbl->map_start);
- hdr->hdr_lba_table = htole64(dtbl->map_start);
+ hdr->hdr_lba_self = htole64((uint64_t)(*dgpt)->map_start);
+ hdr->hdr_lba_alt = htole64((uint64_t)stbl->map_start);
+ hdr->hdr_lba_table = htole64((uint64_t)dtbl->map_start);
hdr->hdr_crc_self = 0;
hdr->hdr_crc_self = htole32(crc32(hdr, le32toh(hdr->hdr_size)));
if (gpt_write(gpt, *dgpt) == -1) {
@@ -181,7 +181,7 @@ recover(gpt_t gpt, int recoverable)
return -1;
}
- last = gpt->mediasz / gpt->secsz - 1LL;
+ last = (uint64_t)(gpt->mediasz / gpt->secsz - 1LL);
if (gpt->gpt != NULL &&
((struct gpt_hdr *)(gpt->gpt->map_data))->hdr_lba_alt != last) {
@@ -192,7 +192,7 @@ recover(gpt_t gpt, int recoverable)
if (gpt->tbl != NULL && gpt->lbt == NULL) {
if (recover_gpt_tbl(gpt, MAP_TYPE_SEC_GPT_TBL,
- last - gpt->tbl->map_size) == -1)
+ (off_t)last - gpt->tbl->map_size) == -1)
return -1;
} else if (gpt->tbl == NULL && gpt->lbt != NULL) {
if (recover_gpt_tbl(gpt, MAP_TYPE_PRI_GPT_TBL, 2LL) == -1)
@@ -200,7 +200,8 @@ recover(gpt_t gpt, int recoverable)
}
if (gpt->gpt != NULL && gpt->tpg == NULL) {
- if (recover_gpt_hdr(gpt, MAP_TYPE_SEC_GPT_HDR, last) == -1)
+ if (recover_gpt_hdr(gpt, MAP_TYPE_SEC_GPT_HDR,
+ (off_t)last) == -1)
return -1;
} else if (gpt->gpt == NULL && gpt->tpg != NULL) {
if (recover_gpt_hdr(gpt, MAP_TYPE_PRI_GPT_HDR, 1LL) == -1)
Index: src/sbin/gpt/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.12 src/sbin/gpt/resizedisk.c:1.13
--- src/sbin/gpt/resizedisk.c:1.12 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/resizedisk.c Wed Dec 2 21:02:43 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.12 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.13 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/bootblock.h>
@@ -111,7 +111,7 @@ resizedisk(gpt_t gpt, off_t sector, off_
return -1;
}
hdr = gpt->gpt->map_data;
- oldloc = le64toh(hdr->hdr_lba_alt);
+ oldloc = (off_t)le64toh((uint64_t)hdr->hdr_lba_alt);
gpt->tpg = map_find(gpt, MAP_TYPE_SEC_GPT_HDR);
if (gpt->tpg == NULL)
@@ -139,7 +139,7 @@ resizedisk(gpt_t gpt, off_t sector, off_
le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz)); ent++) {
if (!gpt_uuid_is_nil(ent->ent_type) &&
((off_t)le64toh(ent->ent_lba_end) > lastdata)) {
- lastdata = le64toh(ent->ent_lba_end);
+ lastdata = (off_t)le64toh((uint64_t)ent->ent_lba_end);
}
}
if (sector - gpt_size <= lastdata) {
@@ -198,18 +198,18 @@ resizedisk(gpt_t gpt, off_t sector, off_
}
hdr = gpt->gpt->map_data;
- hdr->hdr_lba_alt = gpt->tpg->map_start;
+ hdr->hdr_lba_alt = (uint64_t)gpt->tpg->map_start;
hdr->hdr_crc_self = 0;
- hdr->hdr_lba_end = htole64(gpt->lbt->map_start - 1);
+ hdr->hdr_lba_end = htole64((uint64_t)(gpt->lbt->map_start - 1));
hdr->hdr_crc_self =
htole32(crc32(gpt->gpt->map_data, GPT_HDR_SIZE));
gpt_write(gpt, gpt->gpt);
hdr = gpt->tpg->map_data;
- hdr->hdr_lba_self = htole64(gpt->tpg->map_start);
- hdr->hdr_lba_alt = htole64(gpt->gpt->map_start);
- hdr->hdr_lba_end = htole64(gpt->lbt->map_start - 1);
- hdr->hdr_lba_table = htole64(gpt->lbt->map_start);
+ hdr->hdr_lba_self = htole64((uint64_t)gpt->tpg->map_start);
+ hdr->hdr_lba_alt = htole64((uint64_t)gpt->gpt->map_start);
+ hdr->hdr_lba_end = htole64((uint64_t)(gpt->lbt->map_start - 1));
+ hdr->hdr_lba_table = htole64((uint64_t)gpt->lbt->map_start);
if (gpt_write_backup(gpt) == -1)
return -1;
@@ -225,8 +225,8 @@ resizedisk(gpt_t gpt, off_t sector, off_
mbr->mbr_part[0].part_size_lo = htole16(0xffff);
mbr->mbr_part[0].part_size_hi = htole16(0xffff);
} else {
- mbr->mbr_part[0].part_size_lo = htole16(last);
- mbr->mbr_part[0].part_size_hi = htole16(last >> 16);
+ mbr->mbr_part[0].part_size_lo = htole16((uint16_t)last);
+ mbr->mbr_part[0].part_size_hi = htole16((uint16_t)(last >> 16));
}
if (gpt_write(gpt, mbrmap) == -1) {
gpt_warnx(gpt, "Error writing PMBR");
@@ -256,7 +256,7 @@ cmd_resizedisk(gpt_t gpt, int argc, char
if (argc != optind)
return usage();
- if ((sector = gpt_check_ais(gpt, 0, ~0, size)) == -1)
+ if ((sector = gpt_check_ais(gpt, 0, (u_int)~0, size)) == -1)
return -1;
return resizedisk(gpt, sector, size);
Index: src/sbin/gpt/resize.c
diff -u src/sbin/gpt/resize.c:1.20 src/sbin/gpt/resize.c:1.21
--- src/sbin/gpt/resize.c:1.20 Wed Dec 2 20:16:21 2015
+++ src/sbin/gpt/resize.c Wed Dec 2 21:02:43 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.20 2015/12/03 01:16:21 christos Exp $");
+__RCSID("$NetBSD: resize.c,v 1.21 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -72,6 +72,7 @@ resize(gpt_t gpt, u_int entry, off_t ali
struct gpt_ent *ent;
unsigned int i;
off_t alignsecs, newsize;
+ uint64_t end;
if ((hdr = gpt_hdr(gpt)) == NULL)
@@ -108,13 +109,14 @@ resize(gpt_t gpt, u_int entry, off_t ali
if (newsize == -1)
return -1;
- ent->ent_lba_end = htole64(map->map_start + newsize - 1LL);
+ end = htole64((uint64_t)(map->map_start + newsize - 1LL));
+ ent->ent_lba_end = end;
if (gpt_write_primary(gpt) == -1)
return -1;
ent = gpt_ent(gpt->gpt, gpt->lbt, i);
- ent->ent_lba_end = htole64(map->map_start + newsize - 1LL);
+ ent->ent_lba_end = end;
if (gpt_write_backup(gpt) == -1)
return -1;
Index: src/sbin/gpt/restore.c
diff -u src/sbin/gpt/restore.c:1.15 src/sbin/gpt/restore.c:1.16
--- src/sbin/gpt/restore.c:1.15 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/restore.c Wed Dec 2 21:02:43 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.15 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: restore.c,v 1.16 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -72,7 +72,9 @@ struct gpt_cmd c_restore = {
return -1; \
}
-#define prop_uint(a) prop_number_unsigned_integer_value(a)
+#define prop_uint(a) (u_int)prop_number_unsigned_integer_value(a)
+#define prop_uint16_t(a) (uint16_t)prop_number_unsigned_integer_value(a)
+#define prop_uint8_t(a) (uint8_t)prop_number_unsigned_integer_value(a)
static int
restore_mbr(gpt_t gpt, struct mbr *mbr, prop_dictionary_t mbr_dict, off_t last)
@@ -84,55 +86,56 @@ restore_mbr(gpt_t gpt, struct mbr *mbr,
propnum = prop_dictionary_get(mbr_dict, "index");
PROP_ERR(propnum);
- i = prop_number_integer_value(propnum);
+ i = prop_uint(propnum);
propnum = prop_dictionary_get(mbr_dict, "flag");
PROP_ERR(propnum);
part = &mbr->mbr_part[i];
- part->part_flag = prop_uint(propnum);
+ part->part_flag = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "start_head");
PROP_ERR(propnum);
- part->part_shd = prop_uint(propnum);
+ part->part_shd = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "start_sector");
PROP_ERR(propnum);
- part->part_ssect = prop_uint(propnum);
+ part->part_ssect = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "start_cylinder");
PROP_ERR(propnum);
- part->part_scyl = prop_uint(propnum);
+ part->part_scyl = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "type");
PROP_ERR(propnum);
- part->part_typ = prop_uint(propnum);
+ part->part_typ = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "end_head");
PROP_ERR(propnum);
- part->part_ehd = prop_uint(propnum);
+ part->part_ehd = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "end_sector");
PROP_ERR(propnum);
- part->part_esect = prop_uint(propnum);
+ part->part_esect = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "end_cylinder");
PROP_ERR(propnum);
- part->part_ecyl = prop_uint(propnum);
+ part->part_ecyl = prop_uint8_t(propnum);
propnum = prop_dictionary_get(mbr_dict, "lba_start_low");
PROP_ERR(propnum);
- part->part_start_lo = htole16(prop_uint(propnum));
+ part->part_start_lo = htole16(prop_uint16_t(propnum));
propnum = prop_dictionary_get(mbr_dict, "lba_start_high");
PROP_ERR(propnum);
- part->part_start_hi = htole16(prop_uint(propnum));
+ part->part_start_hi = htole16(prop_uint16_t(propnum));
/* adjust PMBR size to size of device */
if (part->part_typ == MBR_PTYPE_PMBR) {
if (last > 0xffffffff) {
mbr->mbr_part[0].part_size_lo = htole16(0xffff);
mbr->mbr_part[0].part_size_hi = htole16(0xffff);
} else {
- mbr->mbr_part[0].part_size_lo = htole16(last);
- mbr->mbr_part[0].part_size_hi = htole16(last >> 16);
+ mbr->mbr_part[0].part_size_lo = htole16((uint16_t)last);
+ mbr->mbr_part[0].part_size_hi = htole16(
+ (uint16_t)(last >> 16));
}
} else {
propnum = prop_dictionary_get(mbr_dict, "lba_size_low");
PROP_ERR(propnum);
- part->part_size_lo = htole16(prop_uint(propnum));
+ part->part_size_lo = htole16(prop_uint16_t(propnum));
propnum = prop_dictionary_get(mbr_dict, "lba_size_high");
PROP_ERR(propnum);
- part->part_size_hi = htole16(prop_uint(propnum));
+ part->part_size_hi = htole16(prop_uint16_t(propnum));
}
return 0;
}
@@ -179,7 +182,7 @@ restore_ent(gpt_t gpt, prop_dictionary_t
}
propnum = prop_dictionary_get(gpt_dict, "index");
PROP_ERR(propnum);
- i = prop_number_integer_value(propnum);
+ i = prop_uint(propnum);
if (i > entries) {
gpt_warnx(gpt, "Entity index out of bounds %u > %u\n",
i, entries);
@@ -259,7 +262,7 @@ restore(gpt_t gpt, const char *infile, i
propnum = prop_dictionary_get(gpt_dict, "entries");
PROP_ERR(propnum);
entries = prop_uint(propnum);
- gpt_size = entries * sizeof(struct gpt_ent) / gpt->secsz;
+ gpt_size = (u_int)(entries * sizeof(struct gpt_ent) / gpt->secsz);
if (gpt_size * sizeof(struct gpt_ent) % gpt->secsz)
gpt_size++;
@@ -322,7 +325,7 @@ restore(gpt_t gpt, const char *infile, i
gpt_warn(gpt, "Can't seek to end");
goto out;
}
- for (i = lastdata + 1; i <= last; i++) {
+ for (i = (u_int)(lastdata + 1); i <= (u_int)last; i++) {
if (write(gpt->fd, secbuf, gpt->secsz) != (ssize_t)gpt->secsz) {
gpt_warn(gpt, "Error writing");
goto out;
@@ -381,9 +384,9 @@ restore(gpt_t gpt, const char *infile, i
hdr->hdr_revision = htole32(GPT_HDR_REVISION);
hdr->hdr_size = htole32(GPT_HDR_SIZE);
hdr->hdr_lba_self = htole64(GPT_HDR_BLKNO);
- hdr->hdr_lba_alt = htole64(last);
- hdr->hdr_lba_start = htole64(firstdata);
- hdr->hdr_lba_end = htole64(lastdata);
+ hdr->hdr_lba_alt = htole64((uint64_t)last);
+ hdr->hdr_lba_start = htole64((uint64_t)firstdata);
+ hdr->hdr_lba_end = htole64((uint64_t)lastdata);
gpt_uuid_copy(hdr->hdr_guid, gpt_guid);
hdr->hdr_lba_table = htole64(2);
hdr->hdr_entries = htole32(entries);
@@ -396,9 +399,9 @@ restore(gpt_t gpt, const char *infile, i
goto out;
}
- hdr->hdr_lba_self = htole64(last);
+ hdr->hdr_lba_self = htole64((uint64_t)last);
hdr->hdr_lba_alt = htole64(GPT_HDR_BLKNO);
- hdr->hdr_lba_table = htole64(lastdata + 1);
+ hdr->hdr_lba_table = htole64((uint64_t)(lastdata + 1));
hdr->hdr_crc_self = 0;
hdr->hdr_crc_self = htole32(crc32(hdr, GPT_HDR_SIZE));
if (lseek(gpt->fd, last * gpt->secsz, SEEK_SET) == -1 ||
Index: src/sbin/gpt/set.c
diff -u src/sbin/gpt/set.c:1.10 src/sbin/gpt/set.c:1.11
--- src/sbin/gpt/set.c:1.10 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/set.c Wed Dec 2 21:02:43 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.10 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: set.c,v 1.11 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -78,7 +78,7 @@ cmd_set(gpt_t gpt, int argc, char *argv[
return usage();
break;
case 'i':
- if (gpt_entry_get(&entry) == -1)
+ if (gpt_uint_get(&entry) == -1)
return usage();
break;
default:
Index: src/sbin/gpt/unset.c
diff -u src/sbin/gpt/unset.c:1.10 src/sbin/gpt/unset.c:1.11
--- src/sbin/gpt/unset.c:1.10 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/unset.c Wed Dec 2 21:02:43 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.10 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: unset.c,v 1.11 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -78,7 +78,7 @@ cmd_unset(gpt_t gpt, int argc, char *arg
return usage();
break;
case 'i':
- if (gpt_entry_get(&entry) == -1)
+ if (gpt_uint_get(&entry) == -1)
return usage();
break;
default:
Index: src/sbin/gpt/show.c
diff -u src/sbin/gpt/show.c:1.28 src/sbin/gpt/show.c:1.29
--- src/sbin/gpt/show.c:1.28 Wed Dec 2 20:07:28 2015
+++ src/sbin/gpt/show.c Wed Dec 2 21:02:43 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.28 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: show.c,v 1.29 2015/12/03 02:02:43 christos Exp $");
#endif
#include <sys/types.h>
@@ -163,24 +163,6 @@ show(gpt_t gpt, int show)
return 0;
}
-static void
-show_num(gpt_t gpt, const char *prompt, uintmax_t num)
-{
-#ifdef HN_AUTOSCALE
- char human_num[5];
- if (humanize_number(human_num, 5, (int64_t)(num * gpt->secsz),
- "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
- human_num[0] = '\0';
-#endif
- printf("%s: %ju", prompt, num);
-#ifdef HN_AUTOSCALE
- if (human_num[0] != '\0')
- printf("(%s)", human_num);
-#endif
-
- printf("\n");
-}
-
static int
show_one(gpt_t gpt, unsigned int entry)
{
@@ -199,8 +181,8 @@ show_one(gpt_t gpt, unsigned int entry)
ent = m->map_data;
printf("Details for index %d:\n", entry);
- show_num(gpt, "Start", m->map_start);
- show_num(gpt, "Size", m->map_size);
+ gpt_show_num("Start", (uintmax_t)(m->map_start * gpt->secsz));
+ gpt_show_num("Size", (uintmax_t)(m->map_size * gpt->secsz));
gpt_uuid_snprintf(s1, sizeof(s1), "%s", ent->ent_type);
gpt_uuid_snprintf(s2, sizeof(s2), "%d", ent->ent_type);
@@ -247,7 +229,7 @@ cmd_show(gpt_t gpt, int argc, char *argv
xshow |= SHOW_GUID;
break;
case 'i':
- if (gpt_entry_get(&entry) == -1)
+ if (gpt_uint_get(&entry) == -1)
return usage();
break;
case 'l':