Created attachment 7456 [details] umount-fstype.patch Hello, I find weird behaviour of umount applet when it is calles with "-t fstype" flag. It causes additional unmount of last entry in mtab with this filesystem type: # mount -t tmpfs test /test1 # mount -t tmpfs test /test2 # mount -t tmpfs test /test3 # cat /proc/mounts | grep test test /test1 tmpfs rw,relatime 0 0 test /test2 tmpfs rw,relatime 0 0 test /test3 tmpfs rw,relatime 0 0 # cat /proc/mounts | tail -n 3 test /test1 tmpfs rw,relatime 0 0 test /test2 tmpfs rw,relatime 0 0 test /test3 tmpfs rw,relatime 0 0 # busybox umount -t tmpfs /test2 # cat /proc/mounts | grep test test /test1 tmpfs rw,relatime 0 0 # busybox umount -t tmpfs /test1 umount: can't unmount /test1: Invalid argument # cat /proc/mounts | grep test # After first unmount run for /test2 - we can see that /test3 has been umounted too. And when we unmount /test1 which is the last tmpfs in mtab, it tries to umount it twice (you can see it in strace) and the second call fails. As I see in the code: https://git.busybox.net/busybox/tree/util-linux/umount.c It reads entries from mtab that matches the filesystem type into a linked list "m" and should forget about it in the case when we do not want to unmount all. But for whatever reason it checks that "-t" option is not specifed too and so do not forgets the list. I think this causes it to umount the top of the list (last enty in the mtab with that fstype) and then move towards to required path. I think attached patch should fix this behaviour. PS. Also it states in the code that "-t" option is ignored, but it is not so. And it is not documented.
Does this help? // If we're not umounting all, we need at least one argument. - if (!(opt & OPT_ALL) && !fstype) { + // Note: "-t FSTYPE" does not imply -a. + if (!(opt & OPT_ALL)) { if (!argv[0]) bb_show_usage(); m = NULL;
commit b083e8cc538ba6b27e19da541ca6a0f7ceb7daee Author: Denys Vlasenko <vda.linux@googlemail.com> Date: Tue Feb 20 17:58:19 2018 +0100 umount: fix "umount -t FSTYPE MNTPOINT" acting as if -a is specified While at it, add -t to --help, and fix comments which say that -t is ignored
> Does this help? I think so. I had the same idea in my patch. Thank you.