mkfs.minix rev 1.7 completely broke the option parser. This fixes it.
authorEric Andersen <andersen@codepoet.org>
Tue, 6 Jun 2000 22:12:35 +0000 (22:12 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 6 Jun 2000 22:12:35 +0000 (22:12 -0000)
 -Erik

TODO
mkfs_minix.c
util-linux/mkfs_minix.c

diff --git a/TODO b/TODO
index 63fae0b5d20baa21b7bf3473f4b559fc18819876..e6c9cfd8f3dd542ae25e9dcea71de65aef695a15 100644 (file)
--- a/TODO
+++ b/TODO
@@ -22,8 +22,10 @@ Bugs that need fixing before the 0.44 release goes out the door:
  - 'grep foo$ file' doesn't work
  - 'grep *foo file' segfaults
  - ps dirent race bug (need to stat the file before attempting chdir)
- - I believe that swaponoff may also be also broken (check it).
- - It used to be that BusyBox tar would happily overwrite existing files on
+ - The following commands segfault or are broken:
+       date -u
+  - I believe that swaponoff may also be also broken (check it).
+  - It used to be that BusyBox tar would happily overwrite existing files on
       an extraction.  However, as of 0.42, BusyBox tar simply dies as soon as an 
       existing file is found.
  - Make 'mount -a' work even when /proc isn't mounted (ugly bug).
index ef37c385d5ad5e20984b664f094dd68747ce45f2..43f5a087efbd346543d7d1a0a14cb51c38277483 100644 (file)
@@ -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,43 +660,57 @@ extern int mkfs_minix_main(int argc, char **argv)
 #endif
        
        /* Parse options */
-       //printf("argc='%d'  argv='%s'\n", argc, *argv);
+printf("erik: 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);
+printf("erik: 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();
+printf("erik: nr_inodes=%ld\n", req_nr_inodes);
+                                                       stopIt=TRUE;
+                                                       break;
                                                }
-                                               req_nr_inodes = (unsigned long) atol(*(++argv));
-                                               break;
                                        case 'l':
                                                if (--argc == 0) {
                                                        goto goodbye;
                                                }
                                                listfile = *(++argv);
+printf("erik: listfile='%s'\n", listfile);
                                                break;
                                        case 'n':
                                                {
                                                        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);
+printf("erik: namelen=%d\n", i);
                                                        if (*tmp)
                                                                show_usage();
                                                        if (i == 14)
@@ -727,7 +741,7 @@ goodbye:
                                }
                        }
                } else {
-                       //printf("else:  argc='%d'  argv='%s'\n", argc, *argv);
+printf("else:  argc='%d'  argv='%s'\n", argc, *argv);
                        if (device_name == NULL)
                                device_name = *argv;
                        else if (BLOCKS == 0)
index ef37c385d5ad5e20984b664f094dd68747ce45f2..43f5a087efbd346543d7d1a0a14cb51c38277483 100644 (file)
@@ -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,43 +660,57 @@ extern int mkfs_minix_main(int argc, char **argv)
 #endif
        
        /* Parse options */
-       //printf("argc='%d'  argv='%s'\n", argc, *argv);
+printf("erik: 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);
+printf("erik: 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();
+printf("erik: nr_inodes=%ld\n", req_nr_inodes);
+                                                       stopIt=TRUE;
+                                                       break;
                                                }
-                                               req_nr_inodes = (unsigned long) atol(*(++argv));
-                                               break;
                                        case 'l':
                                                if (--argc == 0) {
                                                        goto goodbye;
                                                }
                                                listfile = *(++argv);
+printf("erik: listfile='%s'\n", listfile);
                                                break;
                                        case 'n':
                                                {
                                                        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);
+printf("erik: namelen=%d\n", i);
                                                        if (*tmp)
                                                                show_usage();
                                                        if (i == 14)
@@ -727,7 +741,7 @@ goodbye:
                                }
                        }
                } else {
-                       //printf("else:  argc='%d'  argv='%s'\n", argc, *argv);
+printf("else:  argc='%d'  argv='%s'\n", argc, *argv);
                        if (device_name == NULL)
                                device_name = *argv;
                        else if (BLOCKS == 0)