diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c index e28129eee5b..d0247470996 100644 --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -84,6 +84,23 @@ unmount_by_statfs(const struct statfs *sb, bool force) return (error); } +static int +unmount_by_umount(struct statfs* sfp, bool force) +{ + FILE *f; + + if (sfp->f_fsid.val[0] == 0 || sfp->f_fsid.val[1] == 0) + return (-1); + + if (force) + f = auto_popen("umount", "-f", sfp->f_mntfromname, NULL); + else + f = auto_popen("umount", sfp->f_mntfromname, NULL); + + assert(f != NULL); + return (auto_pclose(f)); +} + static const struct statfs * find_statfs(const struct statfs *mntbuf, int nitems, const char *mountpoint) { @@ -304,7 +321,8 @@ unmount_automounted(bool force) continue; } - unmount_by_statfs(&(mntbuf[i]), force); + if (unmount_by_umount(&(mntbuf[i]), force) != 0) + unmount_by_statfs(&(mntbuf[i]), force); } }