If user writes a value using b or s suffix without explicitly stating the size
of blocks or sectors, mkfs ends with a not helpful error about the value being
too small. It happens because we read the physical geometry after all options
are parsed.
So, tell the user exactly what is wrong with the input.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
if (sp[1] != '\0')
return -1LL;
- if (*sp == 'b')
- return i * blksize;
- if (*sp == 's')
- return i * sectsize;
+ if (*sp == 'b') {
+ if (!blksize) {
+ fprintf(stderr,
+_("Blocksize must be provided prior to using 'b' suffix.\n"));
+ usage();
+ } else {
+ return i * blksize;
+ }
+ }
+ if (*sp == 's') {
+ if (!sectsize) {
+ fprintf(stderr,
+_("Sectorsize must be specified prior to using 's' suffix.\n"));
+ usage();
+ } else {
+ return i * sectsize;
+ }
+ }
c = tolower(*sp);
switch (c) {