summaryrefslogtreecommitdiff
path: root/util-linux/mount.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-17 15:05:31 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-17 15:05:31 +0000
commit9c99b62b9eec826065496f895ae9eaece08ecc88 (patch)
treed777c3d45d5e4f83269d1f9d20c9dbd1e0e90590 /util-linux/mount.c
parent13b4924ce0ab3f78d2105b9f55b73a4f66c7028b (diff)
downloadbusybox-w32-9c99b62b9eec826065496f895ae9eaece08ecc88.tar.gz
busybox-w32-9c99b62b9eec826065496f895ae9eaece08ecc88.tar.bz2
busybox-w32-9c99b62b9eec826065496f895ae9eaece08ecc88.zip
mount: getopt_ulflag'ification
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r--util-linux/mount.c62
1 files changed, 24 insertions, 38 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index f4dcbad0b..5539f1e02 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -1378,11 +1378,8 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1378 1378
1379 for (fl = fslist; fl; fl = fl->link) { 1379 for (fl = fslist; fl; fl = fl->link) {
1380 mp->mnt_type = fl->data; 1380 mp->mnt_type = fl->data;
1381
1382 rc = mount_it_now(mp, vfsflags, filteropts); 1381 rc = mount_it_now(mp, vfsflags, filteropts);
1383 if (!rc) break; 1382 if (!rc) break;
1384
1385 mp->mnt_type = 0;
1386 } 1383 }
1387 } 1384 }
1388 1385
@@ -1412,52 +1409,41 @@ report_error:
1412 1409
1413int mount_main(int argc, char **argv) 1410int mount_main(int argc, char **argv)
1414{ 1411{
1415 char *cmdopts = xstrdup(""), *fstabname, *fstype=0, *storage_path=0; 1412 enum { OPT_ALL = 0x8 };
1413
1414 char *cmdopts = xstrdup(""), *fstype=0, *storage_path=0;
1415 char *opt_o, *fstabname;
1416 FILE *fstab; 1416 FILE *fstab;
1417 int i, opt, all = FALSE, rc = 0; 1417 int i, j, rc = 0;
1418 unsigned long opt;
1418 struct mntent mtpair[2], *mtcur = mtpair; 1419 struct mntent mtpair[2], *mtcur = mtpair;
1419 1420
1420 /* parse long options, like --bind and --move. Note that -o option 1421 /* parse long options, like --bind and --move. Note that -o option
1421 * and --option are synonymous. Yes, this means --remount,rw works. */ 1422 * and --option are synonymous. Yes, this means --remount,rw works. */
1422 1423
1423 for (i = opt = 0; i < argc; i++) { 1424 for (i = j = 0; i < argc; i++) {
1424 if (argv[i][0] == '-' && argv[i][1] == '-') { 1425 if (argv[i][0] == '-' && argv[i][1] == '-') {
1425 append_mount_options(&cmdopts,argv[i]+2); 1426 append_mount_options(&cmdopts,argv[i]+2);
1426 } else argv[opt++] = argv[i]; 1427 } else argv[j++] = argv[i];
1427 } 1428 }
1428 argc = opt; 1429 argc = j;
1429 1430
1430 // Parse remaining options 1431 // Parse remaining options
1431 1432
1432 while ((opt = getopt(argc, argv, "o:t:rwavnf")) > 0) { 1433 opt = bb_getopt_ulflags(argc, argv, "o:t:rwavnf", &opt_o, &fstype);
1433 switch (opt) { 1434 if (opt & 1) // -o
1434 case 'o': 1435 append_mount_options(&cmdopts, opt_o);
1435 append_mount_options(&cmdopts, optarg); 1436 //if (opt & 1) // -t
1436 break; 1437 if (opt & 2) // -r
1437 case 't': 1438 append_mount_options(&cmdopts, "ro");
1438 fstype = optarg; 1439 if (opt & 4) // -w
1439 break; 1440 append_mount_options(&cmdopts, "rw");
1440 case 'r': 1441 //if (opt & 8) // -a
1441 append_mount_options(&cmdopts, "ro"); 1442 if (opt & 0x10) // -n
1442 break; 1443 USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE);
1443 case 'w': 1444 if (opt & 0x20) // -f
1444 append_mount_options(&cmdopts, "rw"); 1445 USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE);
1445 break; 1446 //if (opt & 0x40) // ignore -v
1446 case 'a':
1447 all = TRUE;
1448 break;
1449 case 'n':
1450 USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
1451 break;
1452 case 'f':
1453 USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
1454 break;
1455 case 'v':
1456 break; // ignore -v
1457 default:
1458 bb_show_usage();
1459 }
1460 }
1461 argv += optind; 1447 argv += optind;
1462 argc -= optind; 1448 argc -= optind;
1463 1449
@@ -1468,7 +1454,7 @@ int mount_main(int argc, char **argv)
1468 // If we have no arguments, show currently mounted filesystems 1454 // If we have no arguments, show currently mounted filesystems
1469 1455
1470 if (!argc) { 1456 if (!argc) {
1471 if (!all) { 1457 if (!(opt & OPT_ALL)) {
1472 FILE *mountTable = setmntent(bb_path_mtab_file, "r"); 1458 FILE *mountTable = setmntent(bb_path_mtab_file, "r");
1473 1459
1474 if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file); 1460 if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);