Made mkfs a little smarter about how to report empty devices.
Also a little smarter about manually specified number of blocks that is larger than the device capacity.
This commit is contained in:
parent
9aae3002ed
commit
34a9677a5b
1 changed files with 19 additions and 2 deletions
|
@ -141,7 +141,7 @@ int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
int nread, mode, usrid, grpid, ch;
|
int nread, mode, usrid, grpid, ch;
|
||||||
block_t blocks;
|
block_t blocks, maxblocks;
|
||||||
block_t i;
|
block_t i;
|
||||||
ino_t root_inum;
|
ino_t root_inum;
|
||||||
ino_t inodes;
|
ino_t inodes;
|
||||||
|
@ -225,13 +225,30 @@ char *argv[];
|
||||||
bzero(zero, block_size);
|
bzero(zero, block_size);
|
||||||
|
|
||||||
/* Determine the size of the device if not specified as -b or proto. */
|
/* Determine the size of the device if not specified as -b or proto. */
|
||||||
if (argc - optind == 1 && blocks == 0) blocks = sizeup(argv[optind]);
|
maxblocks = sizeup(argv[optind]);
|
||||||
|
if (argc - optind == 1 && blocks == 0) {
|
||||||
|
blocks = maxblocks;
|
||||||
|
/* blocks == 0 is checked later, but leads to a funny way of
|
||||||
|
* reporting a 0-sized device (displays usage).
|
||||||
|
*/
|
||||||
|
if(blocks < 1) {
|
||||||
|
fprintf(stderr, "%s: this device can't hold a filesystem.\n",
|
||||||
|
progname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The remaining args must be 'special proto', or just 'special' if the
|
/* The remaining args must be 'special proto', or just 'special' if the
|
||||||
* no. of blocks has already been specified.
|
* no. of blocks has already been specified.
|
||||||
*/
|
*/
|
||||||
if (argc - optind != 2 && (argc - optind != 1 || blocks == 0)) usage();
|
if (argc - optind != 2 && (argc - optind != 1 || blocks == 0)) usage();
|
||||||
|
|
||||||
|
if (blocks > maxblocks) {
|
||||||
|
fprintf(stderr, "%s: number of blocks too large for device.\n",
|
||||||
|
progname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check special. */
|
/* Check special. */
|
||||||
check_mtab(argv[optind]);
|
check_mtab(argv[optind]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue