diff --git a/CHANGELOG b/CHANGELOG index ae991c7..0ea7bde 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ - use sprintf() when constructing hosts mapent. - fix mnts_remove_amdmount() uses wrong list. - eliminate cache_lookup_offset() usage. +- fix is mounted check on non existent path. xx/xx/2018 autofs-5.1.5 - fix flag file permission. diff --git a/lib/dev-ioctl-lib.c b/lib/dev-ioctl-lib.c index e851923..7040c3d 100644 --- a/lib/dev-ioctl-lib.c +++ b/lib/dev-ioctl-lib.c @@ -759,6 +759,9 @@ static int dev_ioctl_ismountpoint(unsigned int logopt, int save_errno = errno; free_dev_ioctl_path(param); errno = save_errno; + /* Path doesn't exist */ + if (errno == ENOENT) + return 0; return -1; } diff --git a/lib/mounts.c b/lib/mounts.c index 0f2eb50..2f757e7 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -1645,8 +1645,18 @@ static int table_is_mounted(const char *mp, unsigned int type) struct mntent mnt_wrk; char buf[PATH_MAX * 3]; size_t mp_len = strlen(mp); + struct stat st; FILE *tab; - int ret = 0; + int ret; + + ret = stat(mp, &st); + if (ret == -1) { + if (errno == ENOENT) { + /* Path does not exist */ + return 0; + } + ret = 0; + } if (!mp || !mp_len || mp_len >= PATH_MAX) return 0;