diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 649c232aa3e5..a92acbfda278 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -352,6 +352,8 @@ zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, * http://www.kernel.org/pub/linux/utils/util-linux/libmount-docs/index.html */ +static pthread_mutex_t mount_lock = PTHREAD_MUTEX_INITIALIZER; + static int do_mount(const char *src, const char *mntpt, char *opts) { @@ -366,7 +368,9 @@ do_mount(const char *src, const char *mntpt, char *opts) int rc; /* Return only the most critical mount error */ + pthread_mutex_lock(&mount_lock); rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE); + pthread_mutex_unlock(&mount_lock); if (rc) { if (rc & MOUNT_FILEIO) return (EIO); @@ -409,7 +413,10 @@ do_unmount(const char *mntpt, int flags) } argv[count] = (char *)mntpt; + + pthread_mutex_lock(&mount_lock); rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE); + pthread_mutex_unlock(&mount_lock); return (rc ? EINVAL : 0); }