Update internal.h to conditionally include asm/string.h
[oweals/busybox.git] / mkfs_minix.c
index c6f057a0787ef6bc9fc48e2b22ea6ec0bafd4c14..c6ca754cabdebf895306075bb14d7517d2c00178 100644 (file)
@@ -188,7 +188,7 @@ static volatile void show_usage()
        fprintf(stderr,
                        "\t-n [14|30]\tSpecify the maximum length of filenames\n");
        fprintf(stderr,
-                       "\t-i\t\tSpecify the number of inodes for the filesystem\n");
+                       "\t-i INODES\tSpecify the number of inodes for the filesystem\n");
        fprintf(stderr,
                        "\t-l FILENAME\tRead the bad blocks list from FILENAME\n");
        fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n");
@@ -644,7 +644,7 @@ char *filename;
 
 extern int mkfs_minix_main(int argc, char **argv)
 {
-       int i;
+       int i=1;
        char *tmp;
        struct stat statbuf;
        char *listfile = NULL;
@@ -660,23 +660,32 @@ extern int mkfs_minix_main(int argc, char **argv)
 #endif
        
        /* Parse options */
-       //printf("argc='%d'  argv='%s'\n", argc, *argv);
        argv++;
        while (--argc >= 0 && *argv && **argv) {
                if (**argv == '-') {
                        stopIt=FALSE;
                        while (i > 0 && *++(*argv) && stopIt==FALSE) {
-                               //printf("argc='%d'  argv='%s'\n", argc, *argv);
                                switch (**argv) {
                                        case 'c':
                                                check = 1;
                                                break;
                                        case 'i':
-                                               if (--argc == 0) {
-                                                       goto goodbye;
+                                               {
+                                                       char *cp=NULL;
+                                                       if (*(*argv+1) != 0) {
+                                                               cp = ++(*argv);
+                                                       } else {
+                                                               if (--argc == 0) {
+                                                                       goto goodbye;
+                                                               }
+                                                               cp = *(++argv);
+                                                       }
+                                                       req_nr_inodes = strtoul(cp, &tmp, 0);
+                                                       if (*tmp)
+                                                               show_usage();
+                                                       stopIt=TRUE;
+                                                       break;
                                                }
-                                               req_nr_inodes = (unsigned long) atol(*(++argv));
-                                               break;
                                        case 'l':
                                                if (--argc == 0) {
                                                        goto goodbye;
@@ -687,16 +696,15 @@ extern int mkfs_minix_main(int argc, char **argv)
                                                {
                                                        char *cp=NULL;
 
-                                                       if (--argc == 0) {
-                                                               goto goodbye;
-                                                       }
                                                        if (*(*argv+1) != 0) {
                                                                cp = ++(*argv);
                                                        } else {
+                                                               if (--argc == 0) {
+                                                                       goto goodbye;
+                                                               }
                                                                cp = *(++argv);
                                                        }
                                                        i = strtoul(cp, &tmp, 0);
-                                                       //printf("cp='%s'   i='%d'\n", cp, i);
                                                        if (*tmp)
                                                                show_usage();
                                                        if (i == 14)
@@ -727,7 +735,6 @@ goodbye:
                                }
                        }
                } else {
-                       //printf("else:  argc='%d'  argv='%s'\n", argc, *argv);
                        if (device_name == NULL)
                                device_name = *argv;
                        else if (BLOCKS == 0)