aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-04-17 04:48:51 +0000
committerMatt Kraai <kraai@debian.org>2001-04-17 04:48:51 +0000
commita3045dfd258b1db2e23eeaaeb6735b297a96941e (patch)
treeadddf3c44e8766c3ef903b058116f40384eedf1e
parent1240082e37d5e89c618de0d28d8466e611c41f4a (diff)
downloadbusybox-w32-a3045dfd258b1db2e23eeaaeb6735b297a96941e.tar.gz
busybox-w32-a3045dfd258b1db2e23eeaaeb6735b297a96941e.tar.bz2
busybox-w32-a3045dfd258b1db2e23eeaaeb6735b297a96941e.zip
Convert mount to use getopt.
-rw-r--r--mount.c86
-rw-r--r--util-linux/mount.c86
2 files changed, 62 insertions, 110 deletions
diff --git a/mount.c b/mount.c
index 6a4c8eb2f..90c1cc723 100644
--- a/mount.c
+++ b/mount.c
@@ -343,65 +343,44 @@ extern int mount_main(int argc, char **argv)
343 int all = FALSE; 343 int all = FALSE;
344 int fakeIt = FALSE; 344 int fakeIt = FALSE;
345 int useMtab = TRUE; 345 int useMtab = TRUE;
346 int i;
347 int rc = EXIT_FAILURE; 346 int rc = EXIT_FAILURE;
348 int fstabmount = FALSE; 347 int fstabmount = FALSE;
348 int opt;
349 349
350 /* Parse options */ 350 /* Parse options */
351 i = --argc; 351 while ((opt = getopt(argc, argv, "o:rt:wafnv")) > 0) {
352 argv++; 352 switch (opt) {
353 while (i > 0 && **argv) { 353 case 'o':
354 if (**argv == '-') { 354 parse_mount_options(optarg, &flags, string_flags);
355 char *opt = *argv; 355 break;
356 356 case 'r':
357 while (i > 0 && *++opt) 357 flags |= MS_RDONLY;
358 switch (*opt) { 358 break;
359 case 'o': 359 case 't':
360 if (--i == 0) { 360 filesystemType = optarg;
361 goto goodbye; 361 break;
362 } 362 case 'w':
363 parse_mount_options(*(++argv), &flags, string_flags); 363 flags &= ~MS_RDONLY;
364 break; 364 break;
365 case 'r': 365 case 'a':
366 flags |= MS_RDONLY; 366 all = TRUE;
367 break; 367 break;
368 case 't': 368 case 'f':
369 if (--i == 0) { 369 fakeIt = TRUE;
370 goto goodbye; 370 break;
371 }
372 filesystemType = *(++argv);
373 break;
374 case 'w':
375 flags &= ~MS_RDONLY;
376 break;
377 case 'a':
378 all = TRUE;
379 break;
380 case 'f':
381 fakeIt = TRUE;
382 break;
383#ifdef BB_FEATURE_MTAB_SUPPORT 371#ifdef BB_FEATURE_MTAB_SUPPORT
384 case 'n': 372 case 'n':
385 useMtab = FALSE; 373 useMtab = FALSE;
386 break; 374 break;
387#endif 375#endif
388 case 'v': 376 case 'v':
389 break; /* ignore -v */ 377 break; /* ignore -v */
390 case 'h':
391 case '-':
392 goto goodbye;
393 }
394 } else {
395 if (device == NULL)
396 device = *argv;
397 else if (directory == NULL)
398 directory = *argv;
399 else {
400 goto goodbye;
401 }
402 } 378 }
403 i--; 379 }
404 argv++; 380
381 if (argv[optind] != NULL) {
382 device = argv[optind];
383 directory = argv[optind + 1];
405 } 384 }
406 385
407 if (device == NULL && !all) 386 if (device == NULL && !all)
@@ -469,7 +448,4 @@ singlemount:
469 } 448 }
470 449
471 goto singlemount; 450 goto singlemount;
472
473goodbye:
474 show_usage();
475} 451}
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 6a4c8eb2f..90c1cc723 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -343,65 +343,44 @@ extern int mount_main(int argc, char **argv)
343 int all = FALSE; 343 int all = FALSE;
344 int fakeIt = FALSE; 344 int fakeIt = FALSE;
345 int useMtab = TRUE; 345 int useMtab = TRUE;
346 int i;
347 int rc = EXIT_FAILURE; 346 int rc = EXIT_FAILURE;
348 int fstabmount = FALSE; 347 int fstabmount = FALSE;
348 int opt;
349 349
350 /* Parse options */ 350 /* Parse options */
351 i = --argc; 351 while ((opt = getopt(argc, argv, "o:rt:wafnv")) > 0) {
352 argv++; 352 switch (opt) {
353 while (i > 0 && **argv) { 353 case 'o':
354 if (**argv == '-') { 354 parse_mount_options(optarg, &flags, string_flags);
355 char *opt = *argv; 355 break;
356 356 case 'r':
357 while (i > 0 && *++opt) 357 flags |= MS_RDONLY;
358 switch (*opt) { 358 break;
359 case 'o': 359 case 't':
360 if (--i == 0) { 360 filesystemType = optarg;
361 goto goodbye; 361 break;
362 } 362 case 'w':
363 parse_mount_options(*(++argv), &flags, string_flags); 363 flags &= ~MS_RDONLY;
364 break; 364 break;
365 case 'r': 365 case 'a':
366 flags |= MS_RDONLY; 366 all = TRUE;
367 break; 367 break;
368 case 't': 368 case 'f':
369 if (--i == 0) { 369 fakeIt = TRUE;
370 goto goodbye; 370 break;
371 }
372 filesystemType = *(++argv);
373 break;
374 case 'w':
375 flags &= ~MS_RDONLY;
376 break;
377 case 'a':
378 all = TRUE;
379 break;
380 case 'f':
381 fakeIt = TRUE;
382 break;
383#ifdef BB_FEATURE_MTAB_SUPPORT 371#ifdef BB_FEATURE_MTAB_SUPPORT
384 case 'n': 372 case 'n':
385 useMtab = FALSE; 373 useMtab = FALSE;
386 break; 374 break;
387#endif 375#endif
388 case 'v': 376 case 'v':
389 break; /* ignore -v */ 377 break; /* ignore -v */
390 case 'h':
391 case '-':
392 goto goodbye;
393 }
394 } else {
395 if (device == NULL)
396 device = *argv;
397 else if (directory == NULL)
398 directory = *argv;
399 else {
400 goto goodbye;
401 }
402 } 378 }
403 i--; 379 }
404 argv++; 380
381 if (argv[optind] != NULL) {
382 device = argv[optind];
383 directory = argv[optind + 1];
405 } 384 }
406 385
407 if (device == NULL && !all) 386 if (device == NULL && !all)
@@ -469,7 +448,4 @@ singlemount:
469 } 448 }
470 449
471 goto singlemount; 450 goto singlemount;
472
473goodbye:
474 show_usage();
475} 451}