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:
parent
2824ded677
commit
5a57821565
@ -21,7 +21,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
#define OPTION_STRING "flDnrva"
|
#define OPTION_STRING "flDnrvad"
|
||||||
#define OPT_FORCE 1
|
#define OPT_FORCE 1
|
||||||
#define OPT_LAZY 2
|
#define OPT_LAZY 2
|
||||||
#define OPT_DONTFREELOOP 4
|
#define OPT_DONTFREELOOP 4
|
||||||
@ -60,14 +60,14 @@ int umount_main(int argc, char **argv)
|
|||||||
* umounts the most recent entries first. */
|
* umounts the most recent entries first. */
|
||||||
|
|
||||||
m = mtl = 0;
|
m = mtl = 0;
|
||||||
if(opt & OPT_ALL) {
|
|
||||||
|
|
||||||
/* 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(!(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);
|
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 = xmalloc(sizeof(struct mtab_list));
|
||||||
m->next = mtl;
|
m->next = mtl;
|
||||||
m->device = bb_xstrdup(me.mnt_fsname);
|
m->device = bb_xstrdup(me.mnt_fsname);
|
||||||
@ -77,7 +77,12 @@ int umount_main(int argc, char **argv)
|
|||||||
endmntent(fp);
|
endmntent(fp);
|
||||||
|
|
||||||
/* If we're not mounting all, we need at least one argument. */
|
/* 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.
|
// Loop through everything we're supposed to umount, and do so.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -90,9 +95,7 @@ int umount_main(int argc, char **argv)
|
|||||||
// Get next command line argument (and look it up in mtab list)
|
// Get next command line argument (and look it up in mtab list)
|
||||||
else if (!argc--) break;
|
else if (!argc--) break;
|
||||||
else {
|
else {
|
||||||
// Get next command line argument (and look it up in mtab list)
|
|
||||||
realpath(*argv++, path);
|
realpath(*argv++, path);
|
||||||
if (ENABLE_FEATURE_MTAB_SUPPORT)
|
|
||||||
for (m = mtl; m; m = m->next)
|
for (m = mtl; m; m = m->next)
|
||||||
if (!strcmp(path, m->dir) || !strcmp(path, m->device))
|
if (!strcmp(path, m->dir) || !strcmp(path, m->device))
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user