summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2012-04-17 13:07:28 +0200
committerDenys Vlasenko2012-04-17 13:07:28 +0200
commit86a03bee1d3d6990c03bf500836b19ec8a1c1f12 (patch)
treef86a7cc1aed9d415e5cbd4bbbcddbd401eaaf7d3
parentee0d4cd8cb64a4ef7f10a89c7d51145d44cc6d49 (diff)
downloadbusybox-86a03bee1d3d6990c03bf500836b19ec8a1c1f12.zip
busybox-86a03bee1d3d6990c03bf500836b19ec8a1c1f12.tar.gz
umount: make -d always active, add -D to suppress it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/umount.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 5b716c6..4c2e882 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -22,7 +22,7 @@
//usage: "\n -l Lazy umount (detach filesystem)"
//usage: "\n -f Force umount (i.e., unreachable NFS server)"
//usage: IF_FEATURE_MOUNT_LOOP(
-//usage: "\n -d Free loop device if it has been used"
+//usage: "\n -D Don't free loop device even if it has been used"
//usage: )
//usage:
//usage:#define umount_example_usage
@@ -44,14 +44,22 @@ static struct mntent *getmntent_r(FILE* stream, struct mntent* result,
}
#endif
-/* ignored: -v -d -t -i */
-#define OPTION_STRING "fldnra" "vdt:i"
+/* Ignored: -v -t -i
+ * bbox always acts as if -d is present.
+ * -D can be used to suppress it (bbox extension).
+ * Rationale:
+ * (1) util-linux's umount does it if "loop=..." is seen in /etc/mtab:
+ * thus, on many systems, bare umount _does_ drop loop devices.
+ * (2) many users request this feature.
+ */
+#define OPTION_STRING "fldDnra" "vt:i"
#define OPT_FORCE (1 << 0) // Same as MNT_FORCE
#define OPT_LAZY (1 << 1) // Same as MNT_DETACH
-#define OPT_FREELOOP (1 << 2)
-#define OPT_NO_MTAB (1 << 3)
-#define OPT_REMOUNT (1 << 4)
-#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? (1 << 5) : 0)
+//#define OPT_FREE_LOOP (1 << 2) // -d is assumed always present
+#define OPT_DONT_FREE_LOOP (1 << 3)
+#define OPT_NO_MTAB (1 << 4)
+#define OPT_REMOUNT (1 << 5)
+#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? (1 << 6) : 0)
int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int umount_main(int argc UNUSED_PARAM, char **argv)
@@ -165,7 +173,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
} else {
// De-allocate the loop device. This ioctl should be ignored on
// any non-loop block devices.
- if (ENABLE_FEATURE_MOUNT_LOOP && (opt & OPT_FREELOOP) && m)
+ if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONT_FREE_LOOP) && m)
del_loop(m->device);
if (ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
erase_mtab(m->dir);