mount: getopt_ulflag'ification
This commit is contained in:
parent
13b4924ce0
commit
9c99b62b9e
@ -1378,11 +1378,8 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
|
|
||||||
for (fl = fslist; fl; fl = fl->link) {
|
for (fl = fslist; fl; fl = fl->link) {
|
||||||
mp->mnt_type = fl->data;
|
mp->mnt_type = fl->data;
|
||||||
|
|
||||||
rc = mount_it_now(mp, vfsflags, filteropts);
|
rc = mount_it_now(mp, vfsflags, filteropts);
|
||||||
if (!rc) break;
|
if (!rc) break;
|
||||||
|
|
||||||
mp->mnt_type = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,52 +1409,41 @@ report_error:
|
|||||||
|
|
||||||
int mount_main(int argc, char **argv)
|
int mount_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *cmdopts = xstrdup(""), *fstabname, *fstype=0, *storage_path=0;
|
enum { OPT_ALL = 0x8 };
|
||||||
|
|
||||||
|
char *cmdopts = xstrdup(""), *fstype=0, *storage_path=0;
|
||||||
|
char *opt_o, *fstabname;
|
||||||
FILE *fstab;
|
FILE *fstab;
|
||||||
int i, opt, all = FALSE, rc = 0;
|
int i, j, rc = 0;
|
||||||
|
unsigned long opt;
|
||||||
struct mntent mtpair[2], *mtcur = mtpair;
|
struct mntent mtpair[2], *mtcur = mtpair;
|
||||||
|
|
||||||
/* parse long options, like --bind and --move. Note that -o option
|
/* parse long options, like --bind and --move. Note that -o option
|
||||||
* and --option are synonymous. Yes, this means --remount,rw works. */
|
* and --option are synonymous. Yes, this means --remount,rw works. */
|
||||||
|
|
||||||
for (i = opt = 0; i < argc; i++) {
|
for (i = j = 0; i < argc; i++) {
|
||||||
if (argv[i][0] == '-' && argv[i][1] == '-') {
|
if (argv[i][0] == '-' && argv[i][1] == '-') {
|
||||||
append_mount_options(&cmdopts,argv[i]+2);
|
append_mount_options(&cmdopts,argv[i]+2);
|
||||||
} else argv[opt++] = argv[i];
|
} else argv[j++] = argv[i];
|
||||||
}
|
}
|
||||||
argc = opt;
|
argc = j;
|
||||||
|
|
||||||
// Parse remaining options
|
// Parse remaining options
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "o:t:rwavnf")) > 0) {
|
opt = bb_getopt_ulflags(argc, argv, "o:t:rwavnf", &opt_o, &fstype);
|
||||||
switch (opt) {
|
if (opt & 1) // -o
|
||||||
case 'o':
|
append_mount_options(&cmdopts, opt_o);
|
||||||
append_mount_options(&cmdopts, optarg);
|
//if (opt & 1) // -t
|
||||||
break;
|
if (opt & 2) // -r
|
||||||
case 't':
|
append_mount_options(&cmdopts, "ro");
|
||||||
fstype = optarg;
|
if (opt & 4) // -w
|
||||||
break;
|
append_mount_options(&cmdopts, "rw");
|
||||||
case 'r':
|
//if (opt & 8) // -a
|
||||||
append_mount_options(&cmdopts, "ro");
|
if (opt & 0x10) // -n
|
||||||
break;
|
USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE);
|
||||||
case 'w':
|
if (opt & 0x20) // -f
|
||||||
append_mount_options(&cmdopts, "rw");
|
USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE);
|
||||||
break;
|
//if (opt & 0x40) // ignore -v
|
||||||
case 'a':
|
|
||||||
all = TRUE;
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
break; // ignore -v
|
|
||||||
default:
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
|
|
||||||
@ -1468,7 +1454,7 @@ int mount_main(int argc, char **argv)
|
|||||||
// If we have no arguments, show currently mounted filesystems
|
// If we have no arguments, show currently mounted filesystems
|
||||||
|
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
if (!all) {
|
if (!(opt & OPT_ALL)) {
|
||||||
FILE *mountTable = setmntent(bb_path_mtab_file, "r");
|
FILE *mountTable = setmntent(bb_path_mtab_file, "r");
|
||||||
|
|
||||||
if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
|
if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
|
||||||
|
Loading…
Reference in New Issue
Block a user