diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-05-19 05:35:19 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-05-19 05:35:19 +0000 |
commit | 330fd2b5767110f29544131d4c72c77e0506b6df (patch) | |
tree | aa360774a903d3ebb0b2b5f3031c2e359f9c3afb /util-linux/mkfs_minix.c | |
parent | d356c6e9d1bc091c64200ecc401aa9b6ffb53151 (diff) | |
download | busybox-w32-330fd2b5767110f29544131d4c72c77e0506b6df.tar.gz busybox-w32-330fd2b5767110f29544131d4c72c77e0506b6df.tar.bz2 busybox-w32-330fd2b5767110f29544131d4c72c77e0506b6df.zip |
More libc portability updates, add in the website (which has not been
archived previously). Wrote 'which' during the meeting today.
-Erik
Diffstat (limited to 'util-linux/mkfs_minix.c')
-rw-r--r-- | util-linux/mkfs_minix.c | 128 |
1 files changed, 81 insertions, 47 deletions
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index bf4bda9fd..f4f1d0997 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -57,6 +57,9 @@ | |||
57 | * | 57 | * |
58 | * The device may be a block device or a image of one, but this isn't | 58 | * The device may be a block device or a image of one, but this isn't |
59 | * enforced (but it's not much fun on a character device :-). | 59 | * enforced (but it's not much fun on a character device :-). |
60 | * | ||
61 | * Modified for BusyBox by Erik Andersen <andersen@debian.org> -- | ||
62 | * removed getopt based parser and added a hand rolled one. | ||
60 | */ | 63 | */ |
61 | 64 | ||
62 | #include "internal.h" | 65 | #include "internal.h" |
@@ -72,7 +75,6 @@ | |||
72 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
73 | #include <sys/ioctl.h> | 76 | #include <sys/ioctl.h> |
74 | #include <mntent.h> | 77 | #include <mntent.h> |
75 | #include <getopt.h> | ||
76 | 78 | ||
77 | #include <linux/fs.h> | 79 | #include <linux/fs.h> |
78 | #include <linux/minix_fs.h> | 80 | #include <linux/minix_fs.h> |
@@ -174,6 +176,7 @@ static volatile void die(char *str) | |||
174 | exit(8); | 176 | exit(8); |
175 | } | 177 | } |
176 | 178 | ||
179 | static volatile void show_usage() __attribute__ ((noreturn)); | ||
177 | static volatile void show_usage() | 180 | static volatile void show_usage() |
178 | { | 181 | { |
179 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", | 182 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", |
@@ -648,6 +651,7 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
648 | char *tmp; | 651 | char *tmp; |
649 | struct stat statbuf; | 652 | struct stat statbuf; |
650 | char *listfile = NULL; | 653 | char *listfile = NULL; |
654 | int stopIt=FALSE; | ||
651 | 655 | ||
652 | if (argc && *argv) | 656 | if (argc && *argv) |
653 | program_name = *argv; | 657 | program_name = *argv; |
@@ -657,57 +661,86 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
657 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 661 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
658 | die("bad inode size"); | 662 | die("bad inode size"); |
659 | #endif | 663 | #endif |
660 | opterr = 0; | 664 | |
661 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) | 665 | /* Parse options */ |
662 | switch (i) { | 666 | //printf("argc='%d' argv='%s'\n", argc, *argv); |
663 | case 'c': | 667 | argv++; |
664 | check = 1; | 668 | while (--argc >= 0 && *argv && **argv) { |
665 | break; | 669 | if (**argv == '-') { |
666 | case 'i': | 670 | stopIt=FALSE; |
667 | req_nr_inodes = (unsigned long) atol(optarg); | 671 | while (i > 0 && *++(*argv) && stopIt==FALSE) { |
668 | break; | 672 | //printf("argc='%d' argv='%s'\n", argc, *argv); |
669 | case 'l': | 673 | switch (**argv) { |
670 | listfile = optarg; | 674 | case 'c': |
671 | break; | 675 | check = 1; |
672 | case 'n': | 676 | break; |
673 | i = strtoul(optarg, &tmp, 0); | 677 | case 'i': |
674 | if (*tmp) | 678 | if (--argc == 0) { |
675 | show_usage(); | 679 | goto goodbye; |
676 | if (i == 14) | 680 | } |
677 | magic = MINIX_SUPER_MAGIC; | 681 | req_nr_inodes = (unsigned long) atol(*(++argv)); |
678 | else if (i == 30) | 682 | break; |
679 | magic = MINIX_SUPER_MAGIC2; | 683 | case 'l': |
680 | else | 684 | if (--argc == 0) { |
681 | show_usage(); | 685 | goto goodbye; |
682 | namelen = i; | 686 | } |
683 | dirsize = i + 2; | 687 | listfile = *(++argv); |
684 | break; | 688 | break; |
685 | case 'v': | 689 | case 'n': |
690 | { | ||
691 | char *cp=NULL; | ||
692 | |||
693 | if (--argc == 0) { | ||
694 | goto goodbye; | ||
695 | } | ||
696 | if (*(*argv+1) != 0) { | ||
697 | cp = ++(*argv); | ||
698 | } else { | ||
699 | cp = *(++argv); | ||
700 | } | ||
701 | i = strtoul(cp, &tmp, 0); | ||
702 | //printf("cp='%s' i='%d'\n", cp, i); | ||
703 | if (*tmp) | ||
704 | show_usage(); | ||
705 | if (i == 14) | ||
706 | magic = MINIX_SUPER_MAGIC; | ||
707 | else if (i == 30) | ||
708 | magic = MINIX_SUPER_MAGIC2; | ||
709 | else | ||
710 | show_usage(); | ||
711 | namelen = i; | ||
712 | dirsize = i + 2; | ||
713 | stopIt=TRUE; | ||
714 | break; | ||
715 | } | ||
716 | case 'v': | ||
686 | #ifdef HAVE_MINIX2 | 717 | #ifdef HAVE_MINIX2 |
687 | version2 = 1; | 718 | version2 = 1; |
688 | #else | 719 | #else |
689 | fprintf(stderr, "%s: not compiled with minix v2 support\n", | 720 | fprintf(stderr, "%s: not compiled with minix v2 support\n", |
690 | program_name, device_name); | 721 | program_name, device_name); |
691 | exit(-1); | 722 | exit(-1); |
692 | #endif | 723 | #endif |
693 | break; | 724 | break; |
694 | default: | 725 | case '-': |
695 | show_usage(); | 726 | case 'h': |
727 | default: | ||
728 | goodbye: | ||
729 | show_usage(); | ||
730 | } | ||
731 | } | ||
732 | } else { | ||
733 | //printf("else: argc='%d' argv='%s'\n", argc, *argv); | ||
734 | if (device_name == NULL) | ||
735 | device_name = *argv; | ||
736 | else if (BLOCKS == 0) | ||
737 | BLOCKS = strtol(*argv, &tmp, 0); | ||
738 | else { | ||
739 | goto goodbye; | ||
740 | } | ||
696 | } | 741 | } |
697 | argc -= optind; | ||
698 | argv += optind; | ||
699 | if (argc > 0 && !device_name) { | ||
700 | device_name = argv[0]; | ||
701 | argc--; | ||
702 | argv++; | 742 | argv++; |
703 | } | 743 | } |
704 | if (argc > 0) { | ||
705 | BLOCKS = strtol(argv[0], &tmp, 0); | ||
706 | if (*tmp) { | ||
707 | printf("strtol error: number of blocks not specified"); | ||
708 | show_usage(); | ||
709 | } | ||
710 | } | ||
711 | 744 | ||
712 | if (device_name && !BLOCKS) | 745 | if (device_name && !BLOCKS) |
713 | BLOCKS = get_size(device_name) / 1024; | 746 | BLOCKS = get_size(device_name) / 1024; |
@@ -760,5 +793,6 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
760 | } | 793 | } |
761 | mark_good_blocks(); | 794 | mark_good_blocks(); |
762 | write_tables(); | 795 | write_tables(); |
763 | return 0; | 796 | exit( 0); |
797 | |||
764 | } | 798 | } |