aboutsummaryrefslogtreecommitdiff
path: root/mkfs_minix.c
diff options
context:
space:
mode:
Diffstat (limited to 'mkfs_minix.c')
-rw-r--r--mkfs_minix.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/mkfs_minix.c b/mkfs_minix.c
index 21965d3b1..a2b6d8a6e 100644
--- a/mkfs_minix.c
+++ b/mkfs_minix.c
@@ -279,7 +279,7 @@ static void check_mount(void)
279 if (!mnt) 279 if (!mnt)
280 return; 280 return;
281 281
282 error_msg_and_die("%s is mounted; will not make a filesystem here!\n", device_name); 282 error_msg_and_die("%s is mounted; will not make a filesystem here!", device_name);
283} 283}
284 284
285static long valid_offset(int fd, int offset) 285static long valid_offset(int fd, int offset)
@@ -336,28 +336,28 @@ static void write_tables(void)
336 Super.s_state &= ~MINIX_ERROR_FS; 336 Super.s_state &= ~MINIX_ERROR_FS;
337 337
338 if (lseek(DEV, 0, SEEK_SET)) 338 if (lseek(DEV, 0, SEEK_SET))
339 error_msg_and_die("seek to boot block failed in write_tables\n"); 339 error_msg_and_die("seek to boot block failed in write_tables");
340 if (512 != write(DEV, boot_block_buffer, 512)) 340 if (512 != write(DEV, boot_block_buffer, 512))
341 error_msg_and_die("unable to clear boot sector\n"); 341 error_msg_and_die("unable to clear boot sector");
342 if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) 342 if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET))
343 error_msg_and_die("seek failed in write_tables\n"); 343 error_msg_and_die("seek failed in write_tables");
344 if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) 344 if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE))
345 error_msg_and_die("unable to write super-block\n"); 345 error_msg_and_die("unable to write super-block");
346 if (IMAPS * BLOCK_SIZE != write(DEV, inode_map, IMAPS * BLOCK_SIZE)) 346 if (IMAPS * BLOCK_SIZE != write(DEV, inode_map, IMAPS * BLOCK_SIZE))
347 error_msg_and_die("unable to write inode map\n"); 347 error_msg_and_die("unable to write inode map");
348 if (ZMAPS * BLOCK_SIZE != write(DEV, zone_map, ZMAPS * BLOCK_SIZE)) 348 if (ZMAPS * BLOCK_SIZE != write(DEV, zone_map, ZMAPS * BLOCK_SIZE))
349 error_msg_and_die("unable to write zone map\n"); 349 error_msg_and_die("unable to write zone map");
350 if (INODE_BUFFER_SIZE != write(DEV, inode_buffer, INODE_BUFFER_SIZE)) 350 if (INODE_BUFFER_SIZE != write(DEV, inode_buffer, INODE_BUFFER_SIZE))
351 error_msg_and_die("unable to write inodes\n"); 351 error_msg_and_die("unable to write inodes");
352 352
353} 353}
354 354
355static void write_block(int blk, char *buffer) 355static void write_block(int blk, char *buffer)
356{ 356{
357 if (blk * BLOCK_SIZE != lseek(DEV, blk * BLOCK_SIZE, SEEK_SET)) 357 if (blk * BLOCK_SIZE != lseek(DEV, blk * BLOCK_SIZE, SEEK_SET))
358 error_msg_and_die("seek failed in write_block\n"); 358 error_msg_and_die("seek failed in write_block");
359 if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) 359 if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE))
360 error_msg_and_die("write failed in write_block\n"); 360 error_msg_and_die("write failed in write_block");
361} 361}
362 362
363static int get_free_block(void) 363static int get_free_block(void)
@@ -365,7 +365,7 @@ static int get_free_block(void)
365 int blk; 365 int blk;
366 366
367 if (used_good_blocks + 1 >= MAX_GOOD_BLOCKS) 367 if (used_good_blocks + 1 >= MAX_GOOD_BLOCKS)
368 error_msg_and_die("too many bad blocks\n"); 368 error_msg_and_die("too many bad blocks");
369 if (used_good_blocks) 369 if (used_good_blocks)
370 blk = good_blocks_table[used_good_blocks - 1] + 1; 370 blk = good_blocks_table[used_good_blocks - 1] + 1;
371 else 371 else
@@ -373,7 +373,7 @@ static int get_free_block(void)
373 while (blk < ZONES && zone_in_use(blk)) 373 while (blk < ZONES && zone_in_use(blk))
374 blk++; 374 blk++;
375 if (blk >= ZONES) 375 if (blk >= ZONES)
376 error_msg_and_die("not enough good blocks\n"); 376 error_msg_and_die("not enough good blocks");
377 good_blocks_table[used_good_blocks] = blk; 377 good_blocks_table[used_good_blocks] = blk;
378 used_good_blocks++; 378 used_good_blocks++;
379 return blk; 379 return blk;
@@ -439,7 +439,7 @@ static void make_bad_inode(void)
439 goto end_bad; 439 goto end_bad;
440 } 440 }
441 } 441 }
442 error_msg_and_die("too many bad blocks\n"); 442 error_msg_and_die("too many bad blocks");
443 end_bad: 443 end_bad:
444 if (ind) 444 if (ind)
445 write_block(ind, (char *) ind_block); 445 write_block(ind, (char *) ind_block);
@@ -489,7 +489,7 @@ static void make_bad_inode2(void)
489 } 489 }
490 } 490 }
491 /* Could make triple indirect block here */ 491 /* Could make triple indirect block here */
492 error_msg_and_die("too many bad blocks\n"); 492 error_msg_and_die("too many bad blocks");
493 end_bad: 493 end_bad:
494 if (ind) 494 if (ind)
495 write_block(ind, (char *) ind_block); 495 write_block(ind, (char *) ind_block);
@@ -590,7 +590,7 @@ static void setup_tables(void)
590 * /sbin/mkfs.minix -i 200 test.fs 590 * /sbin/mkfs.minix -i 200 test.fs
591 * */ 591 * */
592 if (i >= 999) { 592 if (i >= 999) {
593 error_msg_and_die("unable to allocate buffers for maps\n"); 593 error_msg_and_die("unable to allocate buffers for maps");
594 } 594 }
595 FIRSTZONE = NORM_FIRSTZONE; 595 FIRSTZONE = NORM_FIRSTZONE;
596 inode_map = xmalloc(IMAPS * BLOCK_SIZE); 596 inode_map = xmalloc(IMAPS * BLOCK_SIZE);
@@ -621,7 +621,7 @@ long do_check(char *buffer, int try, unsigned int current_block)
621 /* Seek to the correct loc. */ 621 /* Seek to the correct loc. */
622 if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != 622 if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) !=
623 current_block * BLOCK_SIZE) { 623 current_block * BLOCK_SIZE) {
624 error_msg_and_die("seek failed during testing of blocks\n"); 624 error_msg_and_die("seek failed during testing of blocks");
625 } 625 }
626 626
627 627
@@ -661,7 +661,7 @@ static void check_blocks(void)
661 while (currently_testing < ZONES) { 661 while (currently_testing < ZONES) {
662 if (lseek(DEV, currently_testing * BLOCK_SIZE, SEEK_SET) != 662 if (lseek(DEV, currently_testing * BLOCK_SIZE, SEEK_SET) !=
663 currently_testing * BLOCK_SIZE) 663 currently_testing * BLOCK_SIZE)
664 error_msg_and_die("seek failed in check_blocks\n"); 664 error_msg_and_die("seek failed in check_blocks");
665 try = TEST_BUFFER_BLOCKS; 665 try = TEST_BUFFER_BLOCKS;
666 if (currently_testing + try > ZONES) 666 if (currently_testing + try > ZONES)
667 try = ZONES - currently_testing; 667 try = ZONES - currently_testing;
@@ -670,7 +670,7 @@ static void check_blocks(void)
670 if (got == try) 670 if (got == try)
671 continue; 671 continue;
672 if (currently_testing < FIRSTZONE) 672 if (currently_testing < FIRSTZONE)
673 error_msg_and_die("bad blocks before data-area: cannot make fs\n"); 673 error_msg_and_die("bad blocks before data-area: cannot make fs");
674 mark_zone(currently_testing); 674 mark_zone(currently_testing);
675 badblocks++; 675 badblocks++;
676 currently_testing++; 676 currently_testing++;
@@ -690,7 +690,7 @@ char *filename;
690 690
691 listfile = fopen(filename, "r"); 691 listfile = fopen(filename, "r");
692 if (listfile == (FILE *) NULL) { 692 if (listfile == (FILE *) NULL) {
693 error_msg_and_die("can't open file of bad blocks\n"); 693 error_msg_and_die("can't open file of bad blocks");
694 } 694 }
695 while (!feof(listfile)) { 695 while (!feof(listfile)) {
696 fscanf(listfile, "%ld\n", &blockno); 696 fscanf(listfile, "%ld\n", &blockno);
@@ -712,10 +712,10 @@ extern int mkfs_minix_main(int argc, char **argv)
712 int stopIt=FALSE; 712 int stopIt=FALSE;
713 713
714 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 714 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
715 error_msg_and_die("bad inode size\n"); 715 error_msg_and_die("bad inode size");
716#ifdef BB_FEATURE_MINIX2 716#ifdef BB_FEATURE_MINIX2
717 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 717 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
718 error_msg_and_die("bad inode size\n"); 718 error_msg_and_die("bad inode size");
719#endif 719#endif
720 720
721 /* Parse options */ 721 /* Parse options */
@@ -781,7 +781,7 @@ extern int mkfs_minix_main(int argc, char **argv)
781#ifdef BB_FEATURE_MINIX2 781#ifdef BB_FEATURE_MINIX2
782 version2 = 1; 782 version2 = 1;
783#else 783#else
784 error_msg("%s: not compiled with minix v2 support\n", 784 error_msg("%s: not compiled with minix v2 support",
785 device_name); 785 device_name);
786 exit(-1); 786 exit(-1);
787#endif 787#endif
@@ -832,13 +832,13 @@ goodbye:
832 strcpy(tmp + 2, ".badblocks"); 832 strcpy(tmp + 2, ".badblocks");
833 DEV = open(device_name, O_RDWR); 833 DEV = open(device_name, O_RDWR);
834 if (DEV < 0) 834 if (DEV < 0)
835 error_msg_and_die("unable to open %s\n", device_name); 835 error_msg_and_die("unable to open %s", device_name);
836 if (fstat(DEV, &statbuf) < 0) 836 if (fstat(DEV, &statbuf) < 0)
837 error_msg_and_die("unable to stat %s\n", device_name); 837 error_msg_and_die("unable to stat %s", device_name);
838 if (!S_ISBLK(statbuf.st_mode)) 838 if (!S_ISBLK(statbuf.st_mode))
839 check = 0; 839 check = 0;
840 else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) 840 else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
841 error_msg_and_die("will not try to make filesystem on '%s'\n", device_name); 841 error_msg_and_die("will not try to make filesystem on '%s'", device_name);
842 setup_tables(); 842 setup_tables();
843 if (check) 843 if (check)
844 check_blocks(); 844 check_blocks();