summaryrefslogtreecommitdiff
path: root/util-linux/umount.c
diff options
context:
space:
mode:
authorRob Landley2006-02-08 20:06:57 +0000
committerRob Landley2006-02-08 20:06:57 +0000
commitcc6d8d30ec156f6f247d63253e4a3f12cd8d7edc (patch)
tree3bfe74e8ffb015f23513c2860c8ac7ad019db3b3 /util-linux/umount.c
parent1ab4c3dc25217ea3a21fe5febf4e7af6d0c04427 (diff)
downloadbusybox-cc6d8d30ec156f6f247d63253e4a3f12cd8d7edc.zip
busybox-cc6d8d30ec156f6f247d63253e4a3f12cd8d7edc.tar.gz
Fix umount so it works if there's no /etc/mtab or /proc/mounts, make
umount -a into a CONFIG_FEATURE (why not?), and zap the now obsolete defconfig file (which was supposed to be part of the previous checkin).
Diffstat (limited to 'util-linux/umount.c')
-rw-r--r--util-linux/umount.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 14ff415..8c05584 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -21,15 +21,14 @@
#include <getopt.h>
#include "busybox.h"
-#define OPTION_STRING "flaDnrv"
+#define OPTION_STRING "flDnrva"
#define OPT_FORCE 1
#define OPT_LAZY 2
-#define OPT_ALL 4
-#define OPT_DONTFREELOOP 8
-#define OPT_NO_MTAB 16
-#define OPT_REMOUNT 32
-/* -v is ignored */
-
+#define OPT_DONTFREELOOP 4
+#define OPT_NO_MTAB 8
+#define OPT_REMOUNT 16
+#define OPT_IGNORED 32 // -v is ignored
+#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? 64 : 0)
extern int umount_main(int argc, char **argv)
{
@@ -61,24 +60,25 @@ extern int umount_main(int argc, char **argv)
* umounts the most recent entries first. */
m=mtl=0;
- if(!(fp = setmntent(bb_path_mtab_file, "r")))
- bb_error_msg_and_die("Cannot open %s", bb_path_mtab_file);
- while (getmntent_r(fp,&me,path,sizeof(path))) {
- m=xmalloc(sizeof(struct mtab_list));
- m->next=mtl;
- m->device=bb_xstrdup(me.mnt_fsname);
- m->dir=bb_xstrdup(me.mnt_dir);
- mtl=m;
- }
- endmntent(fp);
-
- /* 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(!(opt & OPT_ALL)) {
- m=0;
- if(argc <= 0) bb_show_usage();
- }
+ 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")))
+ bb_error_msg_and_die("Cannot open %s", bb_path_mtab_file);
+ while (getmntent_r(fp,&me,path,sizeof(path))) {
+ m=xmalloc(sizeof(struct mtab_list));
+ m->next=mtl;
+ m->device=bb_xstrdup(me.mnt_fsname);
+ m->dir=bb_xstrdup(me.mnt_dir);
+ mtl=m;
+ }
+ endmntent(fp);
+ /* If we're not mounting all, we need at least one argument. */
+ } else if(argc <= 0) bb_show_usage();
+
// Loop through everything we're supposed to umount, and do so.
for(;;) {
int curstat;
@@ -92,9 +92,10 @@ extern int umount_main(int argc, char **argv)
else {
// Get next command line argument (and look it up in mtab list)
realpath(*argv++, path);
- for(m = mtl; m; m = m->next)
- if(!strcmp(path, m->dir) || !strcmp(path, m->device))
- break;
+ if (ENABLE_FEATURE_MTAB_SUPPORT)
+ for(m = mtl; m; m = m->next)
+ if(!strcmp(path, m->dir) || !strcmp(path, m->device))
+ break;
}
// Let's ask the thing nicely to unmount.