aboutsummaryrefslogtreecommitdiff
path: root/util-linux/umount.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 17:54:45 +0000
committerRob Landley <rob@landley.net>2006-08-03 17:54:45 +0000
commit7478804b783619762a52a740037126ef8711acc2 (patch)
treeb89cfcb288e5ff6deb78c7bbf21a08459850cba2 /util-linux/umount.c
parent280a264fb893670f00e333dc75c58b6c77970048 (diff)
downloadbusybox-w32-7478804b783619762a52a740037126ef8711acc2.tar.gz
busybox-w32-7478804b783619762a52a740037126ef8711acc2.tar.bz2
busybox-w32-7478804b783619762a52a740037126ef8711acc2.zip
Fix umount so loop device disassociation hopefully doesn't screw up errno on
a failed mount. And while I'm at it, legacy mdev removal was only being done in the _failure_ case? That can't be right. Plus minor header cleanups and an option parsing tweak.
Diffstat (limited to 'util-linux/umount.c')
-rw-r--r--util-linux/umount.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c
index b74b11027..24c1d03a9 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -13,18 +13,15 @@
13 13
14#include "busybox.h" 14#include "busybox.h"
15#include <mntent.h> 15#include <mntent.h>
16#include <errno.h>
17#include <string.h>
18#include <getopt.h> 16#include <getopt.h>
19 17
20#define OPTION_STRING "flDnrvad" 18#define OPTION_STRING "flDnravd"
21#define OPT_FORCE 1 19#define OPT_FORCE 1
22#define OPT_LAZY 2 20#define OPT_LAZY 2
23#define OPT_DONTFREELOOP 4 21#define OPT_DONTFREELOOP 4
24#define OPT_NO_MTAB 8 22#define OPT_NO_MTAB 8
25#define OPT_REMOUNT 16 23#define OPT_REMOUNT 16
26#define OPT_IGNORED 32 // -v is ignored 24#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? 32 : 0)
27#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? 64 : 0)
28 25
29int umount_main(int argc, char **argv) 26int umount_main(int argc, char **argv)
30{ 27{
@@ -77,8 +74,6 @@ int umount_main(int argc, char **argv)
77 m = 0; 74 m = 0;
78 if (!argc) bb_show_usage(); 75 if (!argc) bb_show_usage();
79 } 76 }
80
81
82 77
83 // Loop through everything we're supposed to umount, and do so. 78 // Loop through everything we're supposed to umount, and do so.
84 for (;;) { 79 for (;;) {
@@ -114,19 +109,20 @@ int umount_main(int argc, char **argv)
114 "%s busy - remounted read-only", m->device); 109 "%s busy - remounted read-only", m->device);
115 } 110 }
116 111
117 /* De-allocate the loop device. This ioctl should be ignored on any
118 * non-loop block devices. */
119 if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONTFREELOOP) && m)
120 del_loop(m->device);
121
122 if (curstat) { 112 if (curstat) {
123 /* Yes, the ENABLE is redundant here, but the optimizer for ARM
124 * can't do simple constant propagation in local variables... */
125 if(ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
126 erase_mtab(m->dir);
127 status = EXIT_FAILURE; 113 status = EXIT_FAILURE;
128 bb_perror_msg("Couldn't umount %s", path); 114 bb_perror_msg("Couldn't umount %s", path);
115 } else {
116 /* De-allocate the loop device. This ioctl should be ignored on
117 * any non-loop block devices. */
118 if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONTFREELOOP) && m)
119 del_loop(m->device);
120 if (ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
121 erase_mtab(m->dir);
129 } 122 }
123
124
125
130 // Find next matching mtab entry for -a or umount /dev 126 // Find next matching mtab entry for -a or umount /dev
131 while (m && (m = m->next)) 127 while (m && (m = m->next))
132 if ((opt & OPT_ALL) || !strcmp(path,m->device)) 128 if ((opt & OPT_ALL) || !strcmp(path,m->device))