aboutsummaryrefslogtreecommitdiff
path: root/util-linux/umount.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/umount.c')
-rw-r--r--util-linux/umount.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 4c2e8821e..00910977d 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -81,8 +81,9 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
81 argv += optind; 81 argv += optind;
82 82
83 // MNT_FORCE and MNT_DETACH (from linux/fs.h) must match 83 // MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
84 // OPT_FORCE and OPT_LAZY, otherwise this trick won't work: 84 // OPT_FORCE and OPT_LAZY.
85 doForce = MAX((opt & OPT_FORCE), (opt & OPT_LAZY)); 85 BUILD_BUG_ON(OPT_FORCE != MNT_FORCE || OPT_LAZY != MNT_DETACH);
86 doForce = opt & (OPT_FORCE|OPT_LAZY);
86 87
87 /* Get a list of mount points from mtab. We read them all in now mostly 88 /* Get a list of mount points from mtab. We read them all in now mostly
88 * for umount -a (so we don't have to worry about the list changing while 89 * for umount -a (so we don't have to worry about the list changing while
@@ -147,11 +148,18 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
147 // umount the directory even if we were given the block device. 148 // umount the directory even if we were given the block device.
148 if (m) zapit = m->dir; 149 if (m) zapit = m->dir;
149 150
151// umount from util-linux 2.22.2 does not do this:
152// umount -f uses umount2(MNT_FORCE) immediately,
153// not trying umount() first.
154// (Strangely, umount -fl ignores -f: it is equivalent to umount -l.
155// We do pass both flags in this case)
156#if 0
150 // Let's ask the thing nicely to unmount. 157 // Let's ask the thing nicely to unmount.
151 curstat = umount(zapit); 158 curstat = umount(zapit);
152 159
153 // Force the unmount, if necessary. 160 // Unmount with force and/or lazy flags, if necessary.
154 if (curstat && doForce) 161 if (curstat && doForce)
162#endif
155 curstat = umount2(zapit, doForce); 163 curstat = umount2(zapit, doForce);
156 164
157 // If still can't umount, maybe remount read-only? 165 // If still can't umount, maybe remount read-only?
@@ -168,7 +176,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
168 bb_error_msg(msg, m->device); 176 bb_error_msg(msg, m->device);
169 } else { 177 } else {
170 status = EXIT_FAILURE; 178 status = EXIT_FAILURE;
171 bb_perror_msg("can't %sumount %s", (doForce ? "forcibly " : ""), zapit); 179 bb_perror_msg("can't unmount %s", zapit);
172 } 180 }
173 } else { 181 } else {
174 // De-allocate the loop device. This ioctl should be ignored on 182 // De-allocate the loop device. This ioctl should be ignored on