better check usage with options, correct show problem error message, indent
This commit is contained in:
parent
083d3f49c2
commit
54cb5c6af3
@ -25,7 +25,7 @@
|
|||||||
#define OPT_FORCE 1
|
#define OPT_FORCE 1
|
||||||
#define OPT_LAZY 2
|
#define OPT_LAZY 2
|
||||||
#define OPT_ALL 4
|
#define OPT_ALL 4
|
||||||
#define OPT_DONTFREELOOP 8
|
#define OPT_DONTFREELOOP 8
|
||||||
#define OPT_NO_MTAB 16
|
#define OPT_NO_MTAB 16
|
||||||
#define OPT_REMOUNT 32
|
#define OPT_REMOUNT 32
|
||||||
/* -v is ignored */
|
/* -v is ignored */
|
||||||
@ -42,14 +42,12 @@ extern int umount_main(int argc, char **argv)
|
|||||||
struct mtab_list {
|
struct mtab_list {
|
||||||
char *dir;
|
char *dir;
|
||||||
char *device;
|
char *device;
|
||||||
struct mtab_list *next;
|
struct mtab_list *next;
|
||||||
} *mtl, *m;
|
} *mtl, *m;
|
||||||
|
|
||||||
if(argc < 2) bb_show_usage();
|
|
||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
|
|
||||||
opt = bb_getopt_ulflags (argc, argv, "flaDnrv");
|
opt = bb_getopt_ulflags (argc, argv, OPTION_STRING);
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
@ -76,7 +74,10 @@ extern int umount_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* If we're umounting all, then m points to the start of the list and
|
/* If we're umounting all, then m points to the start of the list and
|
||||||
* the argument list should be empty (which will match all). */
|
* the argument list should be empty (which will match all). */
|
||||||
if(!(opt & OPT_ALL)) m=0;
|
if(!(opt & OPT_ALL)) {
|
||||||
|
m=0;
|
||||||
|
if(argc <= 0) bb_show_usage();
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through everything we're supposed to umount, and do so.
|
// Loop through everything we're supposed to umount, and do so.
|
||||||
for(;;) {
|
for(;;) {
|
||||||
@ -124,12 +125,12 @@ extern int umount_main(int argc, char **argv)
|
|||||||
if(ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
|
if(ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
|
||||||
erase_mtab(m->dir);
|
erase_mtab(m->dir);
|
||||||
status = EXIT_FAILURE;
|
status = EXIT_FAILURE;
|
||||||
bb_perror_msg("Couldn't umount %s\n", path);
|
bb_perror_msg("Couldn't umount %s", path);
|
||||||
}
|
}
|
||||||
// Find next matching mtab entry for -a or umount /dev
|
// Find next matching mtab entry for -a or umount /dev
|
||||||
while(m && (m = m->next))
|
while(m && (m = m->next))
|
||||||
if((opt & OPT_ALL) || !strcmp(path,m->device))
|
if((opt & OPT_ALL) || !strcmp(path,m->device))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free mtab list if necessary
|
// Free mtab list if necessary
|
||||||
|
Loading…
x
Reference in New Issue
Block a user