Date: Fri, 15 Nov 2002 15:59:25 -0800 (PST) From: Julian Elischer <julian@elischer.org> To: re@freebsd.org, FreeBSD current users <current@FreeBSD.ORG> Subject: Sign fixes for disklabel(8) Message-ID: <Pine.BSF.4.21.0211151555190.46162-200000@InterJet.elischer.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Here are the diffs to allow disklabel to correctly create partitions >
1TB (up to 2TB is useful with UFS2) pending a different partitionning
scheme. It also allows you to correctly make smaller partitions beyond
1TB which is nice if you don't want to waste 800GB on an array :-)
permission to commit please?
(pending comments by others)
(also the sysinstall changes posted before)
(also the bluetooth code)
[-- Attachment #2 --]
Index: disklabel.c
===================================================================
RCS file: /usr/cvs/src/sbin/disklabel/disklabel.c,v
retrieving revision 1.62
diff -u -r1.62 disklabel.c
--- disklabel.c 8 Oct 2002 12:13:19 -0000 1.62
+++ disklabel.c 15 Nov 2002 23:53:04 -0000
@@ -943,7 +943,8 @@
const char **cpp;
unsigned int part;
char *tp, line[BUFSIZ];
- int v, lineno = 0, errors = 0;
+ unsigned int v;
+ int lineno = 0, errors = 0;
int i;
lp->d_bbsize = BBSIZE; /* XXX */
@@ -973,7 +974,7 @@
}
if (cpp < &dktypenames[DKMAXTYPES])
continue;
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if ((unsigned)v >= DKMAXTYPES)
fprintf(stderr, "line %d:%s %d\n", lineno,
"Warning, unknown disk type", v);
@@ -1006,8 +1007,8 @@
}
continue;
}
- if (sscanf(cp, "%d partitions", &v) == 1) {
- if (v == 0 || (unsigned)v > MAXPARTITIONS) {
+ if (sscanf(cp, "%u partitions", &v) == 1) {
+ if (v == 0 || v > MAXPARTITIONS) {
fprintf(stderr,
"line %d: bad # of partitions\n", lineno);
lp->d_npartitions = MAXPARTITIONS;
@@ -1027,7 +1028,7 @@
continue;
}
if (streq(cp, "bytes/sector")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0 || (v % DEV_BSIZE) != 0) {
fprintf(stderr,
"line %d: %s: bad sector size\n",
@@ -1038,7 +1039,7 @@
continue;
}
if (streq(cp, "sectors/track")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1048,7 +1049,7 @@
continue;
}
if (streq(cp, "sectors/cylinder")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1058,7 +1059,7 @@
continue;
}
if (streq(cp, "tracks/cylinder")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1068,7 +1069,7 @@
continue;
}
if (streq(cp, "cylinders")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1078,7 +1079,7 @@
continue;
}
if (streq(cp, "sectors/unit")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1088,7 +1089,7 @@
continue;
}
if (streq(cp, "rpm")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1098,7 +1099,7 @@
continue;
}
if (streq(cp, "interleave")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v <= 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1108,7 +1109,7 @@
continue;
}
if (streq(cp, "trackskew")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v < 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1118,7 +1119,7 @@
continue;
}
if (streq(cp, "cylinderskew")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v < 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1128,7 +1129,7 @@
continue;
}
if (streq(cp, "headswitch")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v < 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1138,7 +1139,7 @@
continue;
}
if (streq(cp, "track-to-track seek")) {
- v = atoi(tp);
+ v = strtoul(tp, NULL, 0);
if (v < 0) {
fprintf(stderr, "line %d: %s: bad %s\n",
lineno, tp, cp);
@@ -1182,7 +1183,7 @@
return (1); \
} else { \
cp = tp, tp = word(cp); \
- (n) = atoi(cp); \
+ (n) = strtoul(cp, NULL, 0); \
} \
} while (0)
@@ -1194,7 +1195,7 @@
} else { \
char *tmp; \
cp = tp, tp = word(cp); \
- (n) = strtol(cp,&tmp,10); \
+ (n) = strtoul(cp, &tmp, 10); \
if (tmp) (w) = *tmp; \
} \
} while (0)
@@ -1209,7 +1210,7 @@
struct partition *pp;
char *cp;
const char **cpp;
- int v;
+ unsigned int v;
pp = &lp->d_partitions[part];
cp = NULL;
@@ -1370,7 +1371,7 @@
hog_part = i;
}
} else {
- off_t size;
+ u_int64_t size;
size = pp->p_size;
switch (part_size_type[i]) {
@@ -1517,7 +1518,7 @@
"partition %c: offset past end of unit\n", part);
errors++;
}
- if (pp->p_offset + pp->p_size > lp->d_secperunit) {
+ if ((pp->p_offset + pp->p_size) > lp->d_secperunit) {
fprintf(stderr,
"partition %c: partition extends past end of unit\n",
part);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0211151555190.46162-200000>
