aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mkfs_minix.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/mkfs_minix.c')
-rw-r--r--util-linux/mkfs_minix.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 94f29e55d..75a909e6b 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -268,7 +268,7 @@ extern inline void check_mount(void)
268 if (!mnt) 268 if (!mnt)
269 return; 269 return;
270 270
271 error_msg_and_die("%s is mounted; will not make a filesystem here!", device_name); 271 bb_error_msg_and_die("%s is mounted; will not make a filesystem here!", device_name);
272} 272}
273 273
274static long valid_offset(int fd, int offset) 274static long valid_offset(int fd, int offset)
@@ -307,7 +307,7 @@ extern inline int get_size(const char *file)
307 long size; 307 long size;
308 308
309 if ((fd = open(file, O_RDWR)) < 0) 309 if ((fd = open(file, O_RDWR)) < 0)
310 perror_msg_and_die("%s", file); 310 bb_perror_msg_and_die("%s", file);
311 if (ioctl(fd, BLKGETSIZE, &size) >= 0) { 311 if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
312 close(fd); 312 close(fd);
313 return (size * 512); 313 return (size * 512);
@@ -325,28 +325,28 @@ extern inline void write_tables(void)
325 Super.s_state &= ~MINIX_ERROR_FS; 325 Super.s_state &= ~MINIX_ERROR_FS;
326 326
327 if (lseek(DEV, 0, SEEK_SET)) 327 if (lseek(DEV, 0, SEEK_SET))
328 error_msg_and_die("seek to boot block failed in write_tables"); 328 bb_error_msg_and_die("seek to boot block failed in write_tables");
329 if (512 != write(DEV, boot_block_buffer, 512)) 329 if (512 != write(DEV, boot_block_buffer, 512))
330 error_msg_and_die("unable to clear boot sector"); 330 bb_error_msg_and_die("unable to clear boot sector");
331 if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) 331 if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET))
332 error_msg_and_die("seek failed in write_tables"); 332 bb_error_msg_and_die("seek failed in write_tables");
333 if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) 333 if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE))
334 error_msg_and_die("unable to write super-block"); 334 bb_error_msg_and_die("unable to write super-block");
335 if (IMAPS * BLOCK_SIZE != write(DEV, inode_map, IMAPS * BLOCK_SIZE)) 335 if (IMAPS * BLOCK_SIZE != write(DEV, inode_map, IMAPS * BLOCK_SIZE))
336 error_msg_and_die("unable to write inode map"); 336 bb_error_msg_and_die("unable to write inode map");
337 if (ZMAPS * BLOCK_SIZE != write(DEV, zone_map, ZMAPS * BLOCK_SIZE)) 337 if (ZMAPS * BLOCK_SIZE != write(DEV, zone_map, ZMAPS * BLOCK_SIZE))
338 error_msg_and_die("unable to write zone map"); 338 bb_error_msg_and_die("unable to write zone map");
339 if (INODE_BUFFER_SIZE != write(DEV, inode_buffer, INODE_BUFFER_SIZE)) 339 if (INODE_BUFFER_SIZE != write(DEV, inode_buffer, INODE_BUFFER_SIZE))
340 error_msg_and_die("unable to write inodes"); 340 bb_error_msg_and_die("unable to write inodes");
341 341
342} 342}
343 343
344static void write_block(int blk, char *buffer) 344static void write_block(int blk, char *buffer)
345{ 345{
346 if (blk * BLOCK_SIZE != lseek(DEV, blk * BLOCK_SIZE, SEEK_SET)) 346 if (blk * BLOCK_SIZE != lseek(DEV, blk * BLOCK_SIZE, SEEK_SET))
347 error_msg_and_die("seek failed in write_block"); 347 bb_error_msg_and_die("seek failed in write_block");
348 if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) 348 if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE))
349 error_msg_and_die("write failed in write_block"); 349 bb_error_msg_and_die("write failed in write_block");
350} 350}
351 351
352static int get_free_block(void) 352static int get_free_block(void)
@@ -354,7 +354,7 @@ static int get_free_block(void)
354 int blk; 354 int blk;
355 355
356 if (used_good_blocks + 1 >= MAX_GOOD_BLOCKS) 356 if (used_good_blocks + 1 >= MAX_GOOD_BLOCKS)
357 error_msg_and_die("too many bad blocks"); 357 bb_error_msg_and_die("too many bad blocks");
358 if (used_good_blocks) 358 if (used_good_blocks)
359 blk = good_blocks_table[used_good_blocks - 1] + 1; 359 blk = good_blocks_table[used_good_blocks - 1] + 1;
360 else 360 else
@@ -362,7 +362,7 @@ static int get_free_block(void)
362 while (blk < ZONES && zone_in_use(blk)) 362 while (blk < ZONES && zone_in_use(blk))
363 blk++; 363 blk++;
364 if (blk >= ZONES) 364 if (blk >= ZONES)
365 error_msg_and_die("not enough good blocks"); 365 bb_error_msg_and_die("not enough good blocks");
366 good_blocks_table[used_good_blocks] = blk; 366 good_blocks_table[used_good_blocks] = blk;
367 used_good_blocks++; 367 used_good_blocks++;
368 return blk; 368 return blk;
@@ -428,7 +428,7 @@ extern inline void make_bad_inode(void)
428 goto end_bad; 428 goto end_bad;
429 } 429 }
430 } 430 }
431 error_msg_and_die("too many bad blocks"); 431 bb_error_msg_and_die("too many bad blocks");
432 end_bad: 432 end_bad:
433 if (ind) 433 if (ind)
434 write_block(ind, (char *) ind_block); 434 write_block(ind, (char *) ind_block);
@@ -478,7 +478,7 @@ extern inline void make_bad_inode2(void)
478 } 478 }
479 } 479 }
480 /* Could make triple indirect block here */ 480 /* Could make triple indirect block here */
481 error_msg_and_die("too many bad blocks"); 481 bb_error_msg_and_die("too many bad blocks");
482 end_bad: 482 end_bad:
483 if (ind) 483 if (ind)
484 write_block(ind, (char *) ind_block); 484 write_block(ind, (char *) ind_block);
@@ -579,7 +579,7 @@ extern inline void setup_tables(void)
579 * /sbin/mkfs.minix -i 200 test.fs 579 * /sbin/mkfs.minix -i 200 test.fs
580 * */ 580 * */
581 if (i >= 999) { 581 if (i >= 999) {
582 error_msg_and_die("unable to allocate buffers for maps"); 582 bb_error_msg_and_die("unable to allocate buffers for maps");
583 } 583 }
584 FIRSTZONE = NORM_FIRSTZONE; 584 FIRSTZONE = NORM_FIRSTZONE;
585 inode_map = xmalloc(IMAPS * BLOCK_SIZE); 585 inode_map = xmalloc(IMAPS * BLOCK_SIZE);
@@ -610,7 +610,7 @@ extern inline long do_check(char *buffer, int try, unsigned int current_block)
610 /* Seek to the correct loc. */ 610 /* Seek to the correct loc. */
611 if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != 611 if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) !=
612 current_block * BLOCK_SIZE) { 612 current_block * BLOCK_SIZE) {
613 error_msg_and_die("seek failed during testing of blocks"); 613 bb_error_msg_and_die("seek failed during testing of blocks");
614 } 614 }
615 615
616 616
@@ -650,7 +650,7 @@ static void check_blocks(void)
650 while (currently_testing < ZONES) { 650 while (currently_testing < ZONES) {
651 if (lseek(DEV, currently_testing * BLOCK_SIZE, SEEK_SET) != 651 if (lseek(DEV, currently_testing * BLOCK_SIZE, SEEK_SET) !=
652 currently_testing * BLOCK_SIZE) 652 currently_testing * BLOCK_SIZE)
653 error_msg_and_die("seek failed in check_blocks"); 653 bb_error_msg_and_die("seek failed in check_blocks");
654 try = TEST_BUFFER_BLOCKS; 654 try = TEST_BUFFER_BLOCKS;
655 if (currently_testing + try > ZONES) 655 if (currently_testing + try > ZONES)
656 try = ZONES - currently_testing; 656 try = ZONES - currently_testing;
@@ -659,7 +659,7 @@ static void check_blocks(void)
659 if (got == try) 659 if (got == try)
660 continue; 660 continue;
661 if (currently_testing < FIRSTZONE) 661 if (currently_testing < FIRSTZONE)
662 error_msg_and_die("bad blocks before data-area: cannot make fs"); 662 bb_error_msg_and_die("bad blocks before data-area: cannot make fs");
663 mark_zone(currently_testing); 663 mark_zone(currently_testing);
664 badblocks++; 664 badblocks++;
665 currently_testing++; 665 currently_testing++;
@@ -675,7 +675,7 @@ static void get_list_blocks(char *filename)
675 FILE *listfile; 675 FILE *listfile;
676 unsigned long blockno; 676 unsigned long blockno;
677 677
678 listfile = xfopen(filename, "r"); 678 listfile = bb_xfopen(filename, "r");
679 while (!feof(listfile)) { 679 while (!feof(listfile)) {
680 fscanf(listfile, "%ld\n", &blockno); 680 fscanf(listfile, "%ld\n", &blockno);
681 mark_zone(blockno); 681 mark_zone(blockno);
@@ -696,10 +696,10 @@ extern int mkfs_minix_main(int argc, char **argv)
696 int stopIt=FALSE; 696 int stopIt=FALSE;
697 697
698 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 698 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
699 error_msg_and_die("bad inode size"); 699 bb_error_msg_and_die("bad inode size");
700#ifdef CONFIG_FEATURE_MINIX2 700#ifdef CONFIG_FEATURE_MINIX2
701 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 701 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
702 error_msg_and_die("bad inode size"); 702 bb_error_msg_and_die("bad inode size");
703#endif 703#endif
704 704
705 /* Parse options */ 705 /* Parse options */
@@ -725,7 +725,7 @@ extern int mkfs_minix_main(int argc, char **argv)
725 } 725 }
726 req_nr_inodes = strtoul(cp, &tmp, 0); 726 req_nr_inodes = strtoul(cp, &tmp, 0);
727 if (*tmp) 727 if (*tmp)
728 show_usage(); 728 bb_show_usage();
729 stopIt=TRUE; 729 stopIt=TRUE;
730 break; 730 break;
731 } 731 }
@@ -749,13 +749,13 @@ extern int mkfs_minix_main(int argc, char **argv)
749 } 749 }
750 i = strtoul(cp, &tmp, 0); 750 i = strtoul(cp, &tmp, 0);
751 if (*tmp) 751 if (*tmp)
752 show_usage(); 752 bb_show_usage();
753 if (i == 14) 753 if (i == 14)
754 magic = MINIX_SUPER_MAGIC; 754 magic = MINIX_SUPER_MAGIC;
755 else if (i == 30) 755 else if (i == 30)
756 magic = MINIX_SUPER_MAGIC2; 756 magic = MINIX_SUPER_MAGIC2;
757 else 757 else
758 show_usage(); 758 bb_show_usage();
759 namelen = i; 759 namelen = i;
760 dirsize = i + 2; 760 dirsize = i + 2;
761 stopIt=TRUE; 761 stopIt=TRUE;
@@ -765,7 +765,7 @@ extern int mkfs_minix_main(int argc, char **argv)
765#ifdef CONFIG_FEATURE_MINIX2 765#ifdef CONFIG_FEATURE_MINIX2
766 version2 = 1; 766 version2 = 1;
767#else 767#else
768 error_msg("%s: not compiled with minix v2 support", 768 bb_error_msg("%s: not compiled with minix v2 support",
769 device_name); 769 device_name);
770 exit(-1); 770 exit(-1);
771#endif 771#endif
@@ -774,7 +774,7 @@ extern int mkfs_minix_main(int argc, char **argv)
774 case 'h': 774 case 'h':
775 default: 775 default:
776goodbye: 776goodbye:
777 show_usage(); 777 bb_show_usage();
778 } 778 }
779 } 779 }
780 } else { 780 } else {
@@ -792,7 +792,7 @@ goodbye:
792 if (device_name && !BLOCKS) 792 if (device_name && !BLOCKS)
793 BLOCKS = get_size(device_name) / 1024; 793 BLOCKS = get_size(device_name) / 1024;
794 if (!device_name || BLOCKS < 10) { 794 if (!device_name || BLOCKS < 10) {
795 show_usage(); 795 bb_show_usage();
796 } 796 }
797#ifdef CONFIG_FEATURE_MINIX2 797#ifdef CONFIG_FEATURE_MINIX2
798 if (version2) { 798 if (version2) {
@@ -816,13 +816,13 @@ goodbye:
816 strcpy(tmp + 2, ".badblocks"); 816 strcpy(tmp + 2, ".badblocks");
817 DEV = open(device_name, O_RDWR); 817 DEV = open(device_name, O_RDWR);
818 if (DEV < 0) 818 if (DEV < 0)
819 error_msg_and_die("unable to open %s", device_name); 819 bb_error_msg_and_die("unable to open %s", device_name);
820 if (fstat(DEV, &statbuf) < 0) 820 if (fstat(DEV, &statbuf) < 0)
821 error_msg_and_die("unable to stat %s", device_name); 821 bb_error_msg_and_die("unable to stat %s", device_name);
822 if (!S_ISBLK(statbuf.st_mode)) 822 if (!S_ISBLK(statbuf.st_mode))
823 check = 0; 823 check = 0;
824 else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) 824 else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
825 error_msg_and_die("will not try to make filesystem on '%s'", device_name); 825 bb_error_msg_and_die("will not try to make filesystem on '%s'", device_name);
826 setup_tables(); 826 setup_tables();
827 if (check) 827 if (check)
828 check_blocks(); 828 check_blocks();