Everything in the disklabel is unsigned so make all the input routines
take unsigned values. his allows one to label disk with the number of blocks > 31 bits (though less then 32 bits) e.g. # size offset fstype [fsize bsize bps/cpg] c: 3125755904 0 unused 0 0 # (Cyl. 0 - 194569*) d: 3125755840 64 unused 0 0 # (Cyl. 0*- 194569*) which is needd to test UFS2
This commit is contained in:
parent
a12cc0e489
commit
484c780433
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=107041
@ -732,7 +732,7 @@ display(FILE *f, const struct disklabel *lp)
|
|||||||
const struct partition *pp;
|
const struct partition *pp;
|
||||||
|
|
||||||
fprintf(f, "# %s:\n", specname);
|
fprintf(f, "# %s:\n", specname);
|
||||||
if ((unsigned) lp->d_type < DKMAXTYPES)
|
if (lp->d_type < DKMAXTYPES)
|
||||||
fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
|
fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
|
||||||
else
|
else
|
||||||
fprintf(f, "type: %u\n", lp->d_type);
|
fprintf(f, "type: %u\n", lp->d_type);
|
||||||
@ -778,7 +778,7 @@ display(FILE *f, const struct disklabel *lp)
|
|||||||
if (pp->p_size) {
|
if (pp->p_size) {
|
||||||
fprintf(f, " %c: %8lu %8lu ", 'a' + i,
|
fprintf(f, " %c: %8lu %8lu ", 'a' + i,
|
||||||
(u_long)pp->p_size, (u_long)pp->p_offset);
|
(u_long)pp->p_size, (u_long)pp->p_offset);
|
||||||
if ((unsigned) pp->p_fstype < FSMAXTYPES)
|
if (pp->p_fstype < FSMAXTYPES)
|
||||||
fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
|
fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
|
||||||
else
|
else
|
||||||
fprintf(f, "%8d", pp->p_fstype);
|
fprintf(f, "%8d", pp->p_fstype);
|
||||||
@ -941,9 +941,10 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
const char **cpp;
|
const char **cpp;
|
||||||
unsigned int part;
|
u_int part;
|
||||||
char *tp, line[BUFSIZ];
|
char *tp, line[BUFSIZ];
|
||||||
int v, lineno = 0, errors = 0;
|
u_long v;
|
||||||
|
int lineno = 0, errors = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lp->d_bbsize = BBSIZE; /* XXX */
|
lp->d_bbsize = BBSIZE; /* XXX */
|
||||||
@ -973,9 +974,9 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
}
|
}
|
||||||
if (cpp < &dktypenames[DKMAXTYPES])
|
if (cpp < &dktypenames[DKMAXTYPES])
|
||||||
continue;
|
continue;
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if ((unsigned)v >= DKMAXTYPES)
|
if (v >= DKMAXTYPES)
|
||||||
fprintf(stderr, "line %d:%s %d\n", lineno,
|
fprintf(stderr, "line %d:%s %lu\n", lineno,
|
||||||
"Warning, unknown disk type", v);
|
"Warning, unknown disk type", v);
|
||||||
lp->d_type = v;
|
lp->d_type = v;
|
||||||
continue;
|
continue;
|
||||||
@ -1001,13 +1002,13 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
}
|
}
|
||||||
if (streq(cp, "drivedata")) {
|
if (streq(cp, "drivedata")) {
|
||||||
for (i = 0; (cp = tp) && *cp != '\0' && i < NDDATA;) {
|
for (i = 0; (cp = tp) && *cp != '\0' && i < NDDATA;) {
|
||||||
lp->d_drivedata[i++] = atoi(cp);
|
lp->d_drivedata[i++] = strtoul(cp, NULL, 10);
|
||||||
tp = word(cp);
|
tp = word(cp);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sscanf(cp, "%d partitions", &v) == 1) {
|
if (sscanf(cp, "%lu partitions", &v) == 1) {
|
||||||
if (v == 0 || (unsigned)v > MAXPARTITIONS) {
|
if (v == 0 || v > MAXPARTITIONS) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"line %d: bad # of partitions\n", lineno);
|
"line %d: bad # of partitions\n", lineno);
|
||||||
lp->d_npartitions = MAXPARTITIONS;
|
lp->d_npartitions = MAXPARTITIONS;
|
||||||
@ -1027,8 +1028,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "bytes/sector")) {
|
if (streq(cp, "bytes/sector")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0 || (v % DEV_BSIZE) != 0) {
|
if (v == 0 || (v % DEV_BSIZE) != 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"line %d: %s: bad sector size\n",
|
"line %d: %s: bad sector size\n",
|
||||||
lineno, tp);
|
lineno, tp);
|
||||||
@ -1038,8 +1039,12 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "sectors/track")) {
|
if (streq(cp, "sectors/track")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
#if (ULONG_MAX != 0xffffffffUL)
|
||||||
|
if (v == 0 || v > 0xffffffff) {
|
||||||
|
#else
|
||||||
|
if (v == 0) {
|
||||||
|
#endif
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1048,8 +1053,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "sectors/cylinder")) {
|
if (streq(cp, "sectors/cylinder")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1058,8 +1063,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "tracks/cylinder")) {
|
if (streq(cp, "tracks/cylinder")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1068,8 +1073,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "cylinders")) {
|
if (streq(cp, "cylinders")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1078,8 +1083,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "sectors/unit")) {
|
if (streq(cp, "sectors/unit")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1088,8 +1093,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "rpm")) {
|
if (streq(cp, "rpm")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0 || v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1098,8 +1103,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "interleave")) {
|
if (streq(cp, "interleave")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0 || v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1108,8 +1113,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "trackskew")) {
|
if (streq(cp, "trackskew")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
if (v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1118,8 +1123,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "cylinderskew")) {
|
if (streq(cp, "cylinderskew")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
if (v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1128,23 +1133,13 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "headswitch")) {
|
if (streq(cp, "headswitch")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
lp->d_headswitch = v;
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
|
||||||
lineno, tp, cp);
|
|
||||||
errors++;
|
|
||||||
} else
|
|
||||||
lp->d_headswitch = v;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "track-to-track seek")) {
|
if (streq(cp, "track-to-track seek")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
lp->d_trkseek = v;
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
|
||||||
lineno, tp, cp);
|
|
||||||
errors++;
|
|
||||||
} else
|
|
||||||
lp->d_trkseek = v;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* the ':' was removed above */
|
/* the ':' was removed above */
|
||||||
@ -1182,7 +1177,7 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
return (1); \
|
return (1); \
|
||||||
} else { \
|
} else { \
|
||||||
cp = tp, tp = word(cp); \
|
cp = tp, tp = word(cp); \
|
||||||
(n) = atoi(cp); \
|
(n) = strtoul(cp, NULL, 10); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -1194,7 +1189,7 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
} else { \
|
} else { \
|
||||||
char *tmp; \
|
char *tmp; \
|
||||||
cp = tp, tp = word(cp); \
|
cp = tp, tp = word(cp); \
|
||||||
(n) = strtol(cp,&tmp,10); \
|
(n) = strtoul(cp, &tmp, 10); \
|
||||||
if (tmp) (w) = *tmp; \
|
if (tmp) (w) = *tmp; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -1209,26 +1204,26 @@ getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno)
|
|||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
char *cp;
|
char *cp;
|
||||||
const char **cpp;
|
const char **cpp;
|
||||||
int v;
|
u_long v;
|
||||||
|
|
||||||
pp = &lp->d_partitions[part];
|
pp = &lp->d_partitions[part];
|
||||||
cp = NULL;
|
cp = NULL;
|
||||||
|
|
||||||
v = 0;
|
v = 0;
|
||||||
NXTWORD(part_size_type[part],v);
|
NXTWORD(part_size_type[part],v);
|
||||||
if (v < 0 || (v == 0 && part_size_type[part] != '*')) {
|
if (v == 0 && part_size_type[part] != '*') {
|
||||||
fprintf(stderr, "line %d: %s: bad partition size\n", lineno,
|
fprintf(stderr,
|
||||||
cp);
|
"line %d: %s: bad partition size\n", lineno, cp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
pp->p_size = v;
|
pp->p_size = v;
|
||||||
|
|
||||||
v = 0;
|
v = 0;
|
||||||
NXTWORD(part_offset_type[part],v);
|
NXTWORD(part_offset_type[part],v);
|
||||||
if (v < 0 || (v == 0 && part_offset_type[part] != '*' &&
|
if (v == 0 && part_offset_type[part] != '*' &&
|
||||||
part_offset_type[part] != '\0')) {
|
part_offset_type[part] != '\0') {
|
||||||
fprintf(stderr, "line %d: %s: bad partition offset\n", lineno,
|
fprintf(stderr,
|
||||||
cp);
|
"line %d: %s: bad partition offset\n", lineno, cp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
pp->p_offset = v;
|
pp->p_offset = v;
|
||||||
@ -1240,10 +1235,10 @@ getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno)
|
|||||||
pp->p_fstype = cpp - fstypenames;
|
pp->p_fstype = cpp - fstypenames;
|
||||||
} else {
|
} else {
|
||||||
if (isdigit(*cp))
|
if (isdigit(*cp))
|
||||||
v = atoi(cp);
|
v = strtoul(cp, NULL, 10);
|
||||||
else
|
else
|
||||||
v = FSMAXTYPES;
|
v = FSMAXTYPES;
|
||||||
if ((unsigned)v >= FSMAXTYPES) {
|
if (v >= FSMAXTYPES) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"line %d: Warning, unknown file system type %s\n",
|
"line %d: Warning, unknown file system type %s\n",
|
||||||
lineno, cp);
|
lineno, cp);
|
||||||
@ -1314,7 +1309,7 @@ checklabel(struct disklabel *lp)
|
|||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
int i, errors = 0;
|
int i, errors = 0;
|
||||||
char part;
|
char part;
|
||||||
unsigned long total_size, total_percent, current_offset;
|
u_long total_size, total_percent, current_offset;
|
||||||
int seen_default_offset;
|
int seen_default_offset;
|
||||||
int hog_part;
|
int hog_part;
|
||||||
int j;
|
int j;
|
||||||
|
@ -732,7 +732,7 @@ display(FILE *f, const struct disklabel *lp)
|
|||||||
const struct partition *pp;
|
const struct partition *pp;
|
||||||
|
|
||||||
fprintf(f, "# %s:\n", specname);
|
fprintf(f, "# %s:\n", specname);
|
||||||
if ((unsigned) lp->d_type < DKMAXTYPES)
|
if (lp->d_type < DKMAXTYPES)
|
||||||
fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
|
fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
|
||||||
else
|
else
|
||||||
fprintf(f, "type: %u\n", lp->d_type);
|
fprintf(f, "type: %u\n", lp->d_type);
|
||||||
@ -778,7 +778,7 @@ display(FILE *f, const struct disklabel *lp)
|
|||||||
if (pp->p_size) {
|
if (pp->p_size) {
|
||||||
fprintf(f, " %c: %8lu %8lu ", 'a' + i,
|
fprintf(f, " %c: %8lu %8lu ", 'a' + i,
|
||||||
(u_long)pp->p_size, (u_long)pp->p_offset);
|
(u_long)pp->p_size, (u_long)pp->p_offset);
|
||||||
if ((unsigned) pp->p_fstype < FSMAXTYPES)
|
if (pp->p_fstype < FSMAXTYPES)
|
||||||
fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
|
fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
|
||||||
else
|
else
|
||||||
fprintf(f, "%8d", pp->p_fstype);
|
fprintf(f, "%8d", pp->p_fstype);
|
||||||
@ -941,9 +941,10 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
const char **cpp;
|
const char **cpp;
|
||||||
unsigned int part;
|
u_int part;
|
||||||
char *tp, line[BUFSIZ];
|
char *tp, line[BUFSIZ];
|
||||||
int v, lineno = 0, errors = 0;
|
u_long v;
|
||||||
|
int lineno = 0, errors = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lp->d_bbsize = BBSIZE; /* XXX */
|
lp->d_bbsize = BBSIZE; /* XXX */
|
||||||
@ -973,9 +974,9 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
}
|
}
|
||||||
if (cpp < &dktypenames[DKMAXTYPES])
|
if (cpp < &dktypenames[DKMAXTYPES])
|
||||||
continue;
|
continue;
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if ((unsigned)v >= DKMAXTYPES)
|
if (v >= DKMAXTYPES)
|
||||||
fprintf(stderr, "line %d:%s %d\n", lineno,
|
fprintf(stderr, "line %d:%s %lu\n", lineno,
|
||||||
"Warning, unknown disk type", v);
|
"Warning, unknown disk type", v);
|
||||||
lp->d_type = v;
|
lp->d_type = v;
|
||||||
continue;
|
continue;
|
||||||
@ -1001,13 +1002,13 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
}
|
}
|
||||||
if (streq(cp, "drivedata")) {
|
if (streq(cp, "drivedata")) {
|
||||||
for (i = 0; (cp = tp) && *cp != '\0' && i < NDDATA;) {
|
for (i = 0; (cp = tp) && *cp != '\0' && i < NDDATA;) {
|
||||||
lp->d_drivedata[i++] = atoi(cp);
|
lp->d_drivedata[i++] = strtoul(cp, NULL, 10);
|
||||||
tp = word(cp);
|
tp = word(cp);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sscanf(cp, "%d partitions", &v) == 1) {
|
if (sscanf(cp, "%lu partitions", &v) == 1) {
|
||||||
if (v == 0 || (unsigned)v > MAXPARTITIONS) {
|
if (v == 0 || v > MAXPARTITIONS) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"line %d: bad # of partitions\n", lineno);
|
"line %d: bad # of partitions\n", lineno);
|
||||||
lp->d_npartitions = MAXPARTITIONS;
|
lp->d_npartitions = MAXPARTITIONS;
|
||||||
@ -1027,8 +1028,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "bytes/sector")) {
|
if (streq(cp, "bytes/sector")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0 || (v % DEV_BSIZE) != 0) {
|
if (v == 0 || (v % DEV_BSIZE) != 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"line %d: %s: bad sector size\n",
|
"line %d: %s: bad sector size\n",
|
||||||
lineno, tp);
|
lineno, tp);
|
||||||
@ -1038,8 +1039,12 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "sectors/track")) {
|
if (streq(cp, "sectors/track")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
#if (ULONG_MAX != 0xffffffffUL)
|
||||||
|
if (v == 0 || v > 0xffffffff) {
|
||||||
|
#else
|
||||||
|
if (v == 0) {
|
||||||
|
#endif
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1048,8 +1053,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "sectors/cylinder")) {
|
if (streq(cp, "sectors/cylinder")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1058,8 +1063,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "tracks/cylinder")) {
|
if (streq(cp, "tracks/cylinder")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1068,8 +1073,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "cylinders")) {
|
if (streq(cp, "cylinders")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1078,8 +1083,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "sectors/unit")) {
|
if (streq(cp, "sectors/unit")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1088,8 +1093,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "rpm")) {
|
if (streq(cp, "rpm")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0 || v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1098,8 +1103,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "interleave")) {
|
if (streq(cp, "interleave")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v <= 0) {
|
if (v == 0 || v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1108,8 +1113,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "trackskew")) {
|
if (streq(cp, "trackskew")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
if (v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1118,8 +1123,8 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "cylinderskew")) {
|
if (streq(cp, "cylinderskew")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
if (v > USHRT_MAX) {
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
fprintf(stderr, "line %d: %s: bad %s\n",
|
||||||
lineno, tp, cp);
|
lineno, tp, cp);
|
||||||
errors++;
|
errors++;
|
||||||
@ -1128,23 +1133,13 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "headswitch")) {
|
if (streq(cp, "headswitch")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
lp->d_headswitch = v;
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
|
||||||
lineno, tp, cp);
|
|
||||||
errors++;
|
|
||||||
} else
|
|
||||||
lp->d_headswitch = v;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (streq(cp, "track-to-track seek")) {
|
if (streq(cp, "track-to-track seek")) {
|
||||||
v = atoi(tp);
|
v = strtoul(tp, NULL, 10);
|
||||||
if (v < 0) {
|
lp->d_trkseek = v;
|
||||||
fprintf(stderr, "line %d: %s: bad %s\n",
|
|
||||||
lineno, tp, cp);
|
|
||||||
errors++;
|
|
||||||
} else
|
|
||||||
lp->d_trkseek = v;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* the ':' was removed above */
|
/* the ':' was removed above */
|
||||||
@ -1182,7 +1177,7 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
return (1); \
|
return (1); \
|
||||||
} else { \
|
} else { \
|
||||||
cp = tp, tp = word(cp); \
|
cp = tp, tp = word(cp); \
|
||||||
(n) = atoi(cp); \
|
(n) = strtoul(cp, NULL, 10); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -1194,7 +1189,7 @@ getasciilabel(FILE *f, struct disklabel *lp)
|
|||||||
} else { \
|
} else { \
|
||||||
char *tmp; \
|
char *tmp; \
|
||||||
cp = tp, tp = word(cp); \
|
cp = tp, tp = word(cp); \
|
||||||
(n) = strtol(cp,&tmp,10); \
|
(n) = strtoul(cp, &tmp, 10); \
|
||||||
if (tmp) (w) = *tmp; \
|
if (tmp) (w) = *tmp; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -1209,26 +1204,26 @@ getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno)
|
|||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
char *cp;
|
char *cp;
|
||||||
const char **cpp;
|
const char **cpp;
|
||||||
int v;
|
u_long v;
|
||||||
|
|
||||||
pp = &lp->d_partitions[part];
|
pp = &lp->d_partitions[part];
|
||||||
cp = NULL;
|
cp = NULL;
|
||||||
|
|
||||||
v = 0;
|
v = 0;
|
||||||
NXTWORD(part_size_type[part],v);
|
NXTWORD(part_size_type[part],v);
|
||||||
if (v < 0 || (v == 0 && part_size_type[part] != '*')) {
|
if (v == 0 && part_size_type[part] != '*') {
|
||||||
fprintf(stderr, "line %d: %s: bad partition size\n", lineno,
|
fprintf(stderr,
|
||||||
cp);
|
"line %d: %s: bad partition size\n", lineno, cp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
pp->p_size = v;
|
pp->p_size = v;
|
||||||
|
|
||||||
v = 0;
|
v = 0;
|
||||||
NXTWORD(part_offset_type[part],v);
|
NXTWORD(part_offset_type[part],v);
|
||||||
if (v < 0 || (v == 0 && part_offset_type[part] != '*' &&
|
if (v == 0 && part_offset_type[part] != '*' &&
|
||||||
part_offset_type[part] != '\0')) {
|
part_offset_type[part] != '\0') {
|
||||||
fprintf(stderr, "line %d: %s: bad partition offset\n", lineno,
|
fprintf(stderr,
|
||||||
cp);
|
"line %d: %s: bad partition offset\n", lineno, cp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
pp->p_offset = v;
|
pp->p_offset = v;
|
||||||
@ -1240,10 +1235,10 @@ getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno)
|
|||||||
pp->p_fstype = cpp - fstypenames;
|
pp->p_fstype = cpp - fstypenames;
|
||||||
} else {
|
} else {
|
||||||
if (isdigit(*cp))
|
if (isdigit(*cp))
|
||||||
v = atoi(cp);
|
v = strtoul(cp, NULL, 10);
|
||||||
else
|
else
|
||||||
v = FSMAXTYPES;
|
v = FSMAXTYPES;
|
||||||
if ((unsigned)v >= FSMAXTYPES) {
|
if (v >= FSMAXTYPES) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"line %d: Warning, unknown file system type %s\n",
|
"line %d: Warning, unknown file system type %s\n",
|
||||||
lineno, cp);
|
lineno, cp);
|
||||||
@ -1314,7 +1309,7 @@ checklabel(struct disklabel *lp)
|
|||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
int i, errors = 0;
|
int i, errors = 0;
|
||||||
char part;
|
char part;
|
||||||
unsigned long total_size, total_percent, current_offset;
|
u_long total_size, total_percent, current_offset;
|
||||||
int seen_default_offset;
|
int seen_default_offset;
|
||||||
int hog_part;
|
int hog_part;
|
||||||
int j;
|
int j;
|
||||||
|
Loading…
Reference in New Issue
Block a user