summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2004-03-16 17:07:06 +0000
committerjhb <jhb@FreeBSD.org>2004-03-16 17:07:06 +0000
commitb7e56e9eea26be625659f4a99d9094c501a0a3bc (patch)
tree5aa997ef67b14b420649f8ea11a120707fde3633 /usr.sbin
parent662b843050ffa69c81e8bd9be635806f6abd5739 (diff)
downloadFreeBSD-src-b7e56e9eea26be625659f4a99d9094c501a0a3bc.zip
FreeBSD-src-b7e56e9eea26be625659f4a99d9094c501a0a3bc.tar.gz
Change libdisk and sysinstall to use d_addr_t rather than u_long for disk
addresses. For arch's with 64-bit longs, this is a nop, but for i386 this allows sysinstall to properly handle disks and filesystems > 1 TB. Changes from the original patch include: - Use d_addr_t rather than inventing a blkcnt type based on int64_t. - Use strtoimax() rather than strtoull() to parse d_addr_t's from config files. - Use intmax_t casts and %jd rather than %llu to printf d_addr_t values. Tested on: i386 Tested by: kuriyama Submitted by: julian MFC after: 1 month
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/sade/disks.c37
-rw-r--r--usr.sbin/sade/label.c69
-rw-r--r--usr.sbin/sysinstall/disks.c37
-rw-r--r--usr.sbin/sysinstall/label.c69
4 files changed, 116 insertions, 96 deletions
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
index 4fba2c7..535fb05 100644
--- a/usr.sbin/sade/disks.c
+++ b/usr.sbin/sade/disks.c
@@ -37,6 +37,7 @@
#include "sysinstall.h"
#include <ctype.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <sys/stat.h>
#include <sys/disklabel.h>
@@ -83,7 +84,7 @@ record_chunks(Disk *d)
{
struct chunk *c1 = NULL;
int i = 0;
- int last_free = 0;
+ daddr_t last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", d->name);
@@ -100,20 +101,21 @@ record_chunks(Disk *d)
current_chunk = i - 1;
}
-static int Total;
+static daddr_t Total;
static void
print_chunks(Disk *d, int u)
{
int row;
int i;
- int sz;
+ daddr_t sz;
char *szstr;
szstr = (u == UNIT_GIG ? "GB" : (u == UNIT_MEG ? "MB" :
(u == UNIT_KILO ? "KB" : "ST")));
- for (i = Total = 0; chunk_info[i]; i++)
+ Total = 0;
+ for (i = 0; chunk_info[i]; i++)
Total += chunk_info[i]->size;
#ifdef PC98
if (d->bios_cyl >= 65536 || d->bios_hd > 16 || d->bios_sect >= 256) {
@@ -139,10 +141,10 @@ print_chunks(Disk *d, int u)
attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL);
attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL);
mvprintw(1, 0,
- "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %lu sectors (%luMB)",
+ "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %jd sectors (%jdMB)",
d->bios_cyl, d->bios_hd, d->bios_sect,
- d->bios_cyl * d->bios_hd * d->bios_sect,
- d->bios_cyl * d->bios_hd * d->bios_sect / (1024/512) / 1024);
+ (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect,
+ (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect / (1024/512) / 1024);
mvprintw(3, 0, "%6s %10s(%s) %10s %8s %6s %10s %8s %8s",
"Offset", "Size", szstr, "End", "Name", "PType", "Desc",
"Subtype", "Flags");
@@ -164,9 +166,9 @@ print_chunks(Disk *d, int u)
}
if (i == current_chunk)
attrset(ATTR_SELECTED);
- mvprintw(row, 0, "%10ld %10lu %10lu %8s %6d %10s %8d\t%-6s",
- chunk_info[i]->offset, sz,
- chunk_info[i]->end, chunk_info[i]->name,
+ mvprintw(row, 0, "%10jd %10jd %10jd %8s %6d %10s %8d\t%-6s",
+ (intmax_t)chunk_info[i]->offset, (intmax_t)sz,
+ (intmax_t)chunk_info[i]->end, chunk_info[i]->name,
chunk_info[i]->type,
slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype),
chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i]));
@@ -423,7 +425,8 @@ diskPartition(Device *dev)
msg = "Slice in use, delete it first or move to an unused one.";
else {
char *val, tmp[20], name[16], *cp;
- int size, subtype;
+ daddr_t size;
+ int subtype;
chunk_e partitiontype;
#ifdef PC98
snprintf(name, sizeof (name), "%s", "FreeBSD");
@@ -434,10 +437,10 @@ diskPartition(Device *dev)
#else
name[0] = '\0';
#endif
- snprintf(tmp, 20, "%lu", chunk_info[current_chunk]->size);
+ snprintf(tmp, 20, "%jd", (intmax_t)chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n"
"or append a trailing `M' for megabytes (e.g. 20M).");
- if (val && (size = strtol(val, &cp, 0)) > 0) {
+ if (val && (size = strtoimax(val, &cp, 0)) > 0) {
if (*cp && toupper(*cp) == 'M')
size *= ONE_MEG;
else if (*cp && toupper(*cp) == 'G')
@@ -886,7 +889,8 @@ static void
diskPartitionNonInteractive(Device *dev)
{
char *cp;
- int i, sz, all_disk = 0;
+ int i, all_disk = 0;
+ daddr_t sz;
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
@@ -939,7 +943,7 @@ diskPartitionNonInteractive(Device *dev)
All_FreeBSD(d, all_disk = TRUE);
}
- else if ((sz = strtol(cp, &cp, 0))) {
+ else if ((sz = strtoimax(cp, &cp, 0))) {
/* Look for sz bytes free */
if (*cp && toupper(*cp) == 'M')
sz *= ONE_MEG;
@@ -956,7 +960,8 @@ diskPartitionNonInteractive(Device *dev)
}
}
if (!chunk_info[i]) {
- msgConfirm("Unable to find %d free blocks on this disk!", sz);
+ msgConfirm("Unable to find %jd free blocks on this disk!",
+ (intmax_t)sz);
return;
}
}
diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c
index 5b4a51c..e75da48 100644
--- a/usr.sbin/sade/label.c
+++ b/usr.sbin/sade/label.c
@@ -36,6 +36,7 @@
#include "sysinstall.h"
#include <ctype.h>
+#include <inttypes.h>
#include <sys/disklabel.h>
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -244,11 +245,11 @@ check_conflict(char *name)
}
/* How much space is in this FreeBSD slice? */
-static int
+static daddr_t
space_free(struct chunk *c)
{
struct chunk *c1;
- int sz = c->size;
+ daddr_t sz = c->size;
for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type != unused)
@@ -551,8 +552,8 @@ getNewfsOptionalArguments(PartInfo *p)
static void
print_label_chunks(void)
{
- int i, j, spaces, srow, prow, pcol;
- int sz;
+ int i, j, srow, prow, pcol;
+ daddr_t sz;
char clrmsg[80];
int ChunkPartStartRow;
WINDOW *ChunkWin;
@@ -650,25 +651,27 @@ print_label_chunks(void)
if (label_chunk_info[i].c->type == whole) {
if (sz >= 100 * ONE_GIG)
mvprintw(srow++, 0,
- "Disk: %s\t\tFree: %d blocks (%dGB)",
- label_chunk_info[i].c->disk->name, sz, (sz / ONE_GIG));
+ "Disk: %s\t\tFree: %jd blocks (%jdGB)",
+ label_chunk_info[i].c->disk->name, (intmax_t)sz,
+ (intmax_t)(sz / ONE_GIG));
else
mvprintw(srow++, 0,
- "Disk: %s\t\tFree: %d blocks (%dMB)",
- label_chunk_info[i].c->disk->name, sz, (sz / ONE_MEG));
+ "Disk: %s\t\tFree: %jd blocks (%jdMB)",
+ label_chunk_info[i].c->disk->name, (intmax_t)sz,
+ (intmax_t)(sz / ONE_MEG));
} else {
if (sz >= 100 * ONE_GIG)
mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %d blocks (%dGB)",
+ "Disk: %s\tPartition name: %s\tFree: %jd blocks (%jdGB)",
label_chunk_info[i].c->disk->name,
label_chunk_info[i].c->name,
- sz, (sz / ONE_GIG));
+ (intmax_t)sz, (intmax_t)(sz / ONE_GIG));
else
mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)",
+ "Disk: %s\tPartition name: %s\tFree: %jd blocks (%jdMB)",
label_chunk_info[i].c->disk->name,
label_chunk_info[i].c->name,
- sz, (sz / ONE_MEG));
+ (intmax_t)sz, (intmax_t)(sz / ONE_MEG));
}
attrset(A_NORMAL);
clrtoeol();
@@ -760,13 +763,13 @@ print_label_chunks(void)
for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
onestr[PART_MOUNT_COL + j] = mountpoint[j];
if (label_chunk_info[i].c->size == 0)
- snprintf(num, 10, "%5ldMB", 0);
+ snprintf(num, 10, "%5dMB", 0);
else if (label_chunk_info[i].c->size < (100 * ONE_GIG))
- snprintf(num, 10, "%5ldMB",
- label_chunk_info[i].c->size / ONE_MEG);
+ snprintf(num, 10, "%5jdMB",
+ (intmax_t)label_chunk_info[i].c->size / ONE_MEG);
else
- snprintf(num, 10, "%5ldGB",
- label_chunk_info[i].c->size / ONE_GIG);
+ snprintf(num, 10, "%5jdGB",
+ (intmax_t)label_chunk_info[i].c->size / ONE_GIG);
memcpy(onestr + PART_SIZE_COL, num, strlen(num));
memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
@@ -834,7 +837,8 @@ clear_wins(void)
static int
diskLabel(Device *dev)
{
- int sz, key = 0;
+ daddr_t sz;
+ int key = 0;
Boolean labeling;
char *msg = NULL;
PartInfo *p, *oldp;
@@ -991,12 +995,12 @@ diskLabel(Device *dev)
}
else {
char *val;
- int size;
+ daddr_t size;
struct chunk *tmp;
char osize[80];
u_long flags = 0;
- sprintf(osize, "%d", sz);
+ sprintf(osize, "%jd", (intmax_t)sz);
val = msgGetInput(osize,
"Please specify the partition size in blocks or append a trailing G for\n"
#ifdef __ia64__
@@ -1004,9 +1008,9 @@ diskLabel(Device *dev)
#else
"gigabytes, M for megabytes, or C for cylinders.\n"
#endif
- "%d blocks (%dMB) are free.",
- sz, sz / ONE_MEG);
- if (!val || (size = strtol(val, &cp, 0)) <= 0) {
+ "%jd blocks (%jdMB) are free.",
+ (intmax_t)sz, (intmax_t)sz / ONE_MEG);
+ if (!val || (size = strtoimax(val, &cp, 0)) <= 0) {
clear_wins();
break;
}
@@ -1353,14 +1357,14 @@ diskLabel(Device *dev)
return DITEM_SUCCESS;
}
-static __inline int
-requested_part_size(char *varName, int nom, int def, int perc)
+static __inline daddr_t
+requested_part_size(char *varName, daddr_t nom, int def, int perc)
{
char *cp;
- int sz;
+ daddr_t sz;
if ((cp = variable_get(varName)) != NULL)
- sz = atoi(cp);
+ sz = strtoimax(cp, NULL, 0);
else
sz = nom + (def - nom) * perc / 100;
return(sz * ONE_MEG);
@@ -1381,7 +1385,7 @@ requested_part_size(char *varName, int nom, int def, int perc)
static char *
try_auto_label(Device **devs, Device *dev, int perc, int *req)
{
- int sz;
+ daddr_t sz;
struct chunk *root_chunk = NULL;
struct chunk *swap_chunk = NULL;
struct chunk *usr_chunk = NULL;
@@ -1420,8 +1424,8 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
if (!swapdev) {
sz = requested_part_size(VAR_SWAP_SIZE, 0, 0, perc);
if (sz == 0) {
- int nom;
- int def;
+ daddr_t nom;
+ daddr_t def;
mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM;
@@ -1595,11 +1599,12 @@ diskLabelNonInteractive(Device *dev)
int entries;
for (entries = 1;; entries++) {
- int sz, soft = 0;
+ intmax_t sz;
+ int soft = 0;
snprintf(name, sizeof name, "%s-%d", c1->name, entries);
if ((cp = variable_get(name)) == NULL)
break;
- if (sscanf(cp, "%s %d %s %d", typ, &sz, mpoint, &soft) < 3) {
+ if (sscanf(cp, "%s %jd %s %d", typ, &sz, mpoint, &soft) < 3) {
msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
status = DITEM_FAILURE;
break;
diff --git a/usr.sbin/sysinstall/disks.c b/usr.sbin/sysinstall/disks.c
index 4fba2c7..535fb05 100644
--- a/usr.sbin/sysinstall/disks.c
+++ b/usr.sbin/sysinstall/disks.c
@@ -37,6 +37,7 @@
#include "sysinstall.h"
#include <ctype.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <sys/stat.h>
#include <sys/disklabel.h>
@@ -83,7 +84,7 @@ record_chunks(Disk *d)
{
struct chunk *c1 = NULL;
int i = 0;
- int last_free = 0;
+ daddr_t last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", d->name);
@@ -100,20 +101,21 @@ record_chunks(Disk *d)
current_chunk = i - 1;
}
-static int Total;
+static daddr_t Total;
static void
print_chunks(Disk *d, int u)
{
int row;
int i;
- int sz;
+ daddr_t sz;
char *szstr;
szstr = (u == UNIT_GIG ? "GB" : (u == UNIT_MEG ? "MB" :
(u == UNIT_KILO ? "KB" : "ST")));
- for (i = Total = 0; chunk_info[i]; i++)
+ Total = 0;
+ for (i = 0; chunk_info[i]; i++)
Total += chunk_info[i]->size;
#ifdef PC98
if (d->bios_cyl >= 65536 || d->bios_hd > 16 || d->bios_sect >= 256) {
@@ -139,10 +141,10 @@ print_chunks(Disk *d, int u)
attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL);
attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL);
mvprintw(1, 0,
- "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %lu sectors (%luMB)",
+ "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %jd sectors (%jdMB)",
d->bios_cyl, d->bios_hd, d->bios_sect,
- d->bios_cyl * d->bios_hd * d->bios_sect,
- d->bios_cyl * d->bios_hd * d->bios_sect / (1024/512) / 1024);
+ (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect,
+ (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect / (1024/512) / 1024);
mvprintw(3, 0, "%6s %10s(%s) %10s %8s %6s %10s %8s %8s",
"Offset", "Size", szstr, "End", "Name", "PType", "Desc",
"Subtype", "Flags");
@@ -164,9 +166,9 @@ print_chunks(Disk *d, int u)
}
if (i == current_chunk)
attrset(ATTR_SELECTED);
- mvprintw(row, 0, "%10ld %10lu %10lu %8s %6d %10s %8d\t%-6s",
- chunk_info[i]->offset, sz,
- chunk_info[i]->end, chunk_info[i]->name,
+ mvprintw(row, 0, "%10jd %10jd %10jd %8s %6d %10s %8d\t%-6s",
+ (intmax_t)chunk_info[i]->offset, (intmax_t)sz,
+ (intmax_t)chunk_info[i]->end, chunk_info[i]->name,
chunk_info[i]->type,
slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype),
chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i]));
@@ -423,7 +425,8 @@ diskPartition(Device *dev)
msg = "Slice in use, delete it first or move to an unused one.";
else {
char *val, tmp[20], name[16], *cp;
- int size, subtype;
+ daddr_t size;
+ int subtype;
chunk_e partitiontype;
#ifdef PC98
snprintf(name, sizeof (name), "%s", "FreeBSD");
@@ -434,10 +437,10 @@ diskPartition(Device *dev)
#else
name[0] = '\0';
#endif
- snprintf(tmp, 20, "%lu", chunk_info[current_chunk]->size);
+ snprintf(tmp, 20, "%jd", (intmax_t)chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n"
"or append a trailing `M' for megabytes (e.g. 20M).");
- if (val && (size = strtol(val, &cp, 0)) > 0) {
+ if (val && (size = strtoimax(val, &cp, 0)) > 0) {
if (*cp && toupper(*cp) == 'M')
size *= ONE_MEG;
else if (*cp && toupper(*cp) == 'G')
@@ -886,7 +889,8 @@ static void
diskPartitionNonInteractive(Device *dev)
{
char *cp;
- int i, sz, all_disk = 0;
+ int i, all_disk = 0;
+ daddr_t sz;
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
@@ -939,7 +943,7 @@ diskPartitionNonInteractive(Device *dev)
All_FreeBSD(d, all_disk = TRUE);
}
- else if ((sz = strtol(cp, &cp, 0))) {
+ else if ((sz = strtoimax(cp, &cp, 0))) {
/* Look for sz bytes free */
if (*cp && toupper(*cp) == 'M')
sz *= ONE_MEG;
@@ -956,7 +960,8 @@ diskPartitionNonInteractive(Device *dev)
}
}
if (!chunk_info[i]) {
- msgConfirm("Unable to find %d free blocks on this disk!", sz);
+ msgConfirm("Unable to find %jd free blocks on this disk!",
+ (intmax_t)sz);
return;
}
}
diff --git a/usr.sbin/sysinstall/label.c b/usr.sbin/sysinstall/label.c
index 5b4a51c..e75da48 100644
--- a/usr.sbin/sysinstall/label.c
+++ b/usr.sbin/sysinstall/label.c
@@ -36,6 +36,7 @@
#include "sysinstall.h"
#include <ctype.h>
+#include <inttypes.h>
#include <sys/disklabel.h>
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -244,11 +245,11 @@ check_conflict(char *name)
}
/* How much space is in this FreeBSD slice? */
-static int
+static daddr_t
space_free(struct chunk *c)
{
struct chunk *c1;
- int sz = c->size;
+ daddr_t sz = c->size;
for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type != unused)
@@ -551,8 +552,8 @@ getNewfsOptionalArguments(PartInfo *p)
static void
print_label_chunks(void)
{
- int i, j, spaces, srow, prow, pcol;
- int sz;
+ int i, j, srow, prow, pcol;
+ daddr_t sz;
char clrmsg[80];
int ChunkPartStartRow;
WINDOW *ChunkWin;
@@ -650,25 +651,27 @@ print_label_chunks(void)
if (label_chunk_info[i].c->type == whole) {
if (sz >= 100 * ONE_GIG)
mvprintw(srow++, 0,
- "Disk: %s\t\tFree: %d blocks (%dGB)",
- label_chunk_info[i].c->disk->name, sz, (sz / ONE_GIG));
+ "Disk: %s\t\tFree: %jd blocks (%jdGB)",
+ label_chunk_info[i].c->disk->name, (intmax_t)sz,
+ (intmax_t)(sz / ONE_GIG));
else
mvprintw(srow++, 0,
- "Disk: %s\t\tFree: %d blocks (%dMB)",
- label_chunk_info[i].c->disk->name, sz, (sz / ONE_MEG));
+ "Disk: %s\t\tFree: %jd blocks (%jdMB)",
+ label_chunk_info[i].c->disk->name, (intmax_t)sz,
+ (intmax_t)(sz / ONE_MEG));
} else {
if (sz >= 100 * ONE_GIG)
mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %d blocks (%dGB)",
+ "Disk: %s\tPartition name: %s\tFree: %jd blocks (%jdGB)",
label_chunk_info[i].c->disk->name,
label_chunk_info[i].c->name,
- sz, (sz / ONE_GIG));
+ (intmax_t)sz, (intmax_t)(sz / ONE_GIG));
else
mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)",
+ "Disk: %s\tPartition name: %s\tFree: %jd blocks (%jdMB)",
label_chunk_info[i].c->disk->name,
label_chunk_info[i].c->name,
- sz, (sz / ONE_MEG));
+ (intmax_t)sz, (intmax_t)(sz / ONE_MEG));
}
attrset(A_NORMAL);
clrtoeol();
@@ -760,13 +763,13 @@ print_label_chunks(void)
for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
onestr[PART_MOUNT_COL + j] = mountpoint[j];
if (label_chunk_info[i].c->size == 0)
- snprintf(num, 10, "%5ldMB", 0);
+ snprintf(num, 10, "%5dMB", 0);
else if (label_chunk_info[i].c->size < (100 * ONE_GIG))
- snprintf(num, 10, "%5ldMB",
- label_chunk_info[i].c->size / ONE_MEG);
+ snprintf(num, 10, "%5jdMB",
+ (intmax_t)label_chunk_info[i].c->size / ONE_MEG);
else
- snprintf(num, 10, "%5ldGB",
- label_chunk_info[i].c->size / ONE_GIG);
+ snprintf(num, 10, "%5jdGB",
+ (intmax_t)label_chunk_info[i].c->size / ONE_GIG);
memcpy(onestr + PART_SIZE_COL, num, strlen(num));
memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
@@ -834,7 +837,8 @@ clear_wins(void)
static int
diskLabel(Device *dev)
{
- int sz, key = 0;
+ daddr_t sz;
+ int key = 0;
Boolean labeling;
char *msg = NULL;
PartInfo *p, *oldp;
@@ -991,12 +995,12 @@ diskLabel(Device *dev)
}
else {
char *val;
- int size;
+ daddr_t size;
struct chunk *tmp;
char osize[80];
u_long flags = 0;
- sprintf(osize, "%d", sz);
+ sprintf(osize, "%jd", (intmax_t)sz);
val = msgGetInput(osize,
"Please specify the partition size in blocks or append a trailing G for\n"
#ifdef __ia64__
@@ -1004,9 +1008,9 @@ diskLabel(Device *dev)
#else
"gigabytes, M for megabytes, or C for cylinders.\n"
#endif
- "%d blocks (%dMB) are free.",
- sz, sz / ONE_MEG);
- if (!val || (size = strtol(val, &cp, 0)) <= 0) {
+ "%jd blocks (%jdMB) are free.",
+ (intmax_t)sz, (intmax_t)sz / ONE_MEG);
+ if (!val || (size = strtoimax(val, &cp, 0)) <= 0) {
clear_wins();
break;
}
@@ -1353,14 +1357,14 @@ diskLabel(Device *dev)
return DITEM_SUCCESS;
}
-static __inline int
-requested_part_size(char *varName, int nom, int def, int perc)
+static __inline daddr_t
+requested_part_size(char *varName, daddr_t nom, int def, int perc)
{
char *cp;
- int sz;
+ daddr_t sz;
if ((cp = variable_get(varName)) != NULL)
- sz = atoi(cp);
+ sz = strtoimax(cp, NULL, 0);
else
sz = nom + (def - nom) * perc / 100;
return(sz * ONE_MEG);
@@ -1381,7 +1385,7 @@ requested_part_size(char *varName, int nom, int def, int perc)
static char *
try_auto_label(Device **devs, Device *dev, int perc, int *req)
{
- int sz;
+ daddr_t sz;
struct chunk *root_chunk = NULL;
struct chunk *swap_chunk = NULL;
struct chunk *usr_chunk = NULL;
@@ -1420,8 +1424,8 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req)
if (!swapdev) {
sz = requested_part_size(VAR_SWAP_SIZE, 0, 0, perc);
if (sz == 0) {
- int nom;
- int def;
+ daddr_t nom;
+ daddr_t def;
mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM;
@@ -1595,11 +1599,12 @@ diskLabelNonInteractive(Device *dev)
int entries;
for (entries = 1;; entries++) {
- int sz, soft = 0;
+ intmax_t sz;
+ int soft = 0;
snprintf(name, sizeof name, "%s-%d", c1->name, entries);
if ((cp = variable_get(name)) == NULL)
break;
- if (sscanf(cp, "%s %d %s %d", typ, &sz, mpoint, &soft) < 3) {
+ if (sscanf(cp, "%s %jd %s %d", typ, &sz, mpoint, &soft) < 3) {
msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
status = DITEM_FAILURE;
break;
OpenPOWER on IntegriCloud