umountfs: Use more sophisticated sed expression for PROTECTED_MOUNTS
This protects all mounts "up to the / ". However, such sed pattern
matches the root filesystem as "is mounted on path <slash> AND the
mount device starts with <slash>". If the root filesystem is mounted
from a node such as "aufs", the root line does not match, and all
mounts end up in PROTECTED_MOUNTS.
I suppose the additional "/" constraint is a hack used to prevent
matching the initial "rootfs /" entry. I would rewrite this as:
PROTECTED_MOUNTS="$(sed -n ':a;/^[^ ]* \//!{H;n;ba};{H;s/.*//;x;s/\n//;p}' /proc/mounts)"
This unmounts all entries down to the "base" root which is not the
kernel standard "rootfs". If / is mounted multiple times, this
unmounts all "stacked" entries as well. In the "aufs" case I described
above, this ensures the additional partitions are cleanly unmounted.
Loading
Please register or sign in to comment