Bug fix: umount wasn't detaching loop devices unless mtab support was enabled.

Made some whitespace cleanups while I was there.
This commit is contained in:
Rob Landley 2006-03-17 03:30:05 +00:00
parent 2824ded677
commit 5a57821565

View File

@ -21,7 +21,7 @@
#include <getopt.h>
#include "busybox.h"
#define OPTION_STRING "flDnrva"
#define OPTION_STRING "flDnrvad"
#define OPT_FORCE 1
#define OPT_LAZY 2
#define OPT_DONTFREELOOP 4
@ -60,14 +60,14 @@ int umount_main(int argc, char **argv)
* umounts the most recent entries first. */
m = mtl = 0;
if(opt & OPT_ALL) {
/* 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). */
if(!(fp = setmntent(bb_path_mtab_file, "r")))
if (!(fp = setmntent(bb_path_mtab_file, "r"))) {
if (opt & OPT_ALL)
bb_error_msg_and_die("Cannot open %s", bb_path_mtab_file);
while (getmntent_r(fp,&me,path,sizeof(path))) {
} else while (getmntent_r(fp,&me,path,sizeof(path))) {
m = xmalloc(sizeof(struct mtab_list));
m->next = mtl;
m->device = bb_xstrdup(me.mnt_fsname);
@ -77,7 +77,12 @@ int umount_main(int argc, char **argv)
endmntent(fp);
/* If we're not mounting all, we need at least one argument. */
} else if(argc <= 0) bb_show_usage();
if (!(opt & OPT_ALL)) {
m = 0;
if (!argc) bb_show_usage();
}
// Loop through everything we're supposed to umount, and do so.
for (;;) {
@ -90,9 +95,7 @@ int umount_main(int argc, char **argv)
// Get next command line argument (and look it up in mtab list)
else if (!argc--) break;
else {
// Get next command line argument (and look it up in mtab list)
realpath(*argv++, path);
if (ENABLE_FEATURE_MTAB_SUPPORT)
for (m = mtl; m; m = m->next)
if (!strcmp(path, m->dir) || !strcmp(path, m->device))
break;