From 568161d91a6de2605db9a396f324af14e65eb7d4 Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Tue, 3 Dec 2024 11:49:35 +0900 Subject: [PATCH] Check if mnt_cache is enabled before trying to use it. Signed-off-by: Jorgen Lundman --- lib/libzfs/libzfs_mount.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index def3111c6f28..f107a2ef7658 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -532,11 +532,13 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags, } /* remove the mounted entry before re-adding on remount */ - if (remount) - libzfs_mnttab_remove(hdl, zhp->zfs_name); + if (hdl->libzfs_mnttab_enable) { + if (remount) + libzfs_mnttab_remove(hdl, zhp->zfs_name); - /* add the mounted entry into our cache */ - libzfs_mnttab_add(hdl, zfs_get_name(zhp), mountpoint, mntopts); + /* add the mounted entry into our cache */ + libzfs_mnttab_add(hdl, zfs_get_name(zhp), mountpoint, mntopts); + } return (0); }