mkfs.minix rev 1.7 completely broke the option parser. This fixes it.

-Erik
This commit is contained in:
Eric Andersen 2000-06-06 22:12:35 +00:00
parent d05e3ce5c2
commit 3232203226
3 changed files with 54 additions and 24 deletions

6
TODO
View File

@ -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' doesn't work
- 'grep *foo file' segfaults - 'grep *foo file' segfaults
- ps dirent race bug (need to stat the file before attempting chdir) - ps dirent race bug (need to stat the file before attempting chdir)
- I believe that swaponoff may also be also broken (check it). - The following commands segfault or are broken:
- It used to be that BusyBox tar would happily overwrite existing files on 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 an extraction. However, as of 0.42, BusyBox tar simply dies as soon as an
existing file is found. existing file is found.
- Make 'mount -a' work even when /proc isn't mounted (ugly bug). - Make 'mount -a' work even when /proc isn't mounted (ugly bug).

View File

@ -644,7 +644,7 @@ char *filename;
extern int mkfs_minix_main(int argc, char **argv) extern int mkfs_minix_main(int argc, char **argv)
{ {
int i; int i=1;
char *tmp; char *tmp;
struct stat statbuf; struct stat statbuf;
char *listfile = NULL; char *listfile = NULL;
@ -660,43 +660,57 @@ extern int mkfs_minix_main(int argc, char **argv)
#endif #endif
/* Parse options */ /* Parse options */
//printf("argc='%d' argv='%s'\n", argc, *argv); printf("erik: argc='%d' argv='%s'\n", argc, *argv);
argv++; argv++;
while (--argc >= 0 && *argv && **argv) { while (--argc >= 0 && *argv && **argv) {
if (**argv == '-') { if (**argv == '-') {
stopIt=FALSE; stopIt=FALSE;
while (i > 0 && *++(*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) { switch (**argv) {
case 'c': case 'c':
check = 1; check = 1;
break; break;
case 'i': 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': case 'l':
if (--argc == 0) { if (--argc == 0) {
goto goodbye; goto goodbye;
} }
listfile = *(++argv); listfile = *(++argv);
printf("erik: listfile='%s'\n", listfile);
break; break;
case 'n': case 'n':
{ {
char *cp=NULL; char *cp=NULL;
if (--argc == 0) {
goto goodbye;
}
if (*(*argv+1) != 0) { if (*(*argv+1) != 0) {
cp = ++(*argv); cp = ++(*argv);
} else { } else {
if (--argc == 0) {
goto goodbye;
}
cp = *(++argv); cp = *(++argv);
} }
i = strtoul(cp, &tmp, 0); i = strtoul(cp, &tmp, 0);
//printf("cp='%s' i='%d'\n", cp, i); //printf("cp='%s' i='%d'\n", cp, i);
printf("erik: namelen=%d\n", i);
if (*tmp) if (*tmp)
show_usage(); show_usage();
if (i == 14) if (i == 14)
@ -727,7 +741,7 @@ goodbye:
} }
} }
} else { } else {
//printf("else: argc='%d' argv='%s'\n", argc, *argv); printf("else: argc='%d' argv='%s'\n", argc, *argv);
if (device_name == NULL) if (device_name == NULL)
device_name = *argv; device_name = *argv;
else if (BLOCKS == 0) else if (BLOCKS == 0)

View File

@ -644,7 +644,7 @@ char *filename;
extern int mkfs_minix_main(int argc, char **argv) extern int mkfs_minix_main(int argc, char **argv)
{ {
int i; int i=1;
char *tmp; char *tmp;
struct stat statbuf; struct stat statbuf;
char *listfile = NULL; char *listfile = NULL;
@ -660,43 +660,57 @@ extern int mkfs_minix_main(int argc, char **argv)
#endif #endif
/* Parse options */ /* Parse options */
//printf("argc='%d' argv='%s'\n", argc, *argv); printf("erik: argc='%d' argv='%s'\n", argc, *argv);
argv++; argv++;
while (--argc >= 0 && *argv && **argv) { while (--argc >= 0 && *argv && **argv) {
if (**argv == '-') { if (**argv == '-') {
stopIt=FALSE; stopIt=FALSE;
while (i > 0 && *++(*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) { switch (**argv) {
case 'c': case 'c':
check = 1; check = 1;
break; break;
case 'i': 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': case 'l':
if (--argc == 0) { if (--argc == 0) {
goto goodbye; goto goodbye;
} }
listfile = *(++argv); listfile = *(++argv);
printf("erik: listfile='%s'\n", listfile);
break; break;
case 'n': case 'n':
{ {
char *cp=NULL; char *cp=NULL;
if (--argc == 0) {
goto goodbye;
}
if (*(*argv+1) != 0) { if (*(*argv+1) != 0) {
cp = ++(*argv); cp = ++(*argv);
} else { } else {
if (--argc == 0) {
goto goodbye;
}
cp = *(++argv); cp = *(++argv);
} }
i = strtoul(cp, &tmp, 0); i = strtoul(cp, &tmp, 0);
//printf("cp='%s' i='%d'\n", cp, i); //printf("cp='%s' i='%d'\n", cp, i);
printf("erik: namelen=%d\n", i);
if (*tmp) if (*tmp)
show_usage(); show_usage();
if (i == 14) if (i == 14)
@ -727,7 +741,7 @@ goodbye:
} }
} }
} else { } else {
//printf("else: argc='%d' argv='%s'\n", argc, *argv); printf("else: argc='%d' argv='%s'\n", argc, *argv);
if (device_name == NULL) if (device_name == NULL)
device_name = *argv; device_name = *argv;
else if (BLOCKS == 0) else if (BLOCKS == 0)