argv += optind;
// MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
- // OPT_FORCE and OPT_LAZY, otherwise this trick won't work:
- doForce = MAX((opt & OPT_FORCE), (opt & OPT_LAZY));
+ // OPT_FORCE and OPT_LAZY.
+ {
+ typedef char bug[
+ (OPT_FORCE != MNT_FORCE || OPT_LAZY != MNT_DETACH) ? -1 : 1
+ ];
+ }
+ doForce = opt & (OPT_FORCE|OPT_LAZY);
/* Get a list of mount points from mtab. We read them all in now mostly
* for umount -a (so we don't have to worry about the list changing while
// umount the directory even if we were given the block device.
if (m) zapit = m->dir;
+// umount from util-linux 2.22.2 does not do this:
+// umount -f uses umount2(MNT_FORCE) immediately,
+// not trying umount() first.
+// (Strangely, umount -fl ignores -f: it is equivalent to umount -l.
+// We do pass both flags in this case)
+#if 0
// Let's ask the thing nicely to unmount.
curstat = umount(zapit);
- // Force the unmount, if necessary.
+ // Unmount with force and/or lazy flags, if necessary.
if (curstat && doForce)
+#endif
curstat = umount2(zapit, doForce);
// If still can't umount, maybe remount read-only?
bb_error_msg(msg, m->device);
} else {
status = EXIT_FAILURE;
- bb_perror_msg("can't %sumount %s", (doForce ? "forcibly " : ""), zapit);
+ bb_perror_msg("can't unmount %s", zapit);
}
} else {
// De-allocate the loop device. This ioctl should be ignored on