diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index a229d7ecd3..bd75932c58 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -567,8 +567,16 @@ libzfs_init(void) #endif if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) { - free(hdl); - return (NULL); + /* XXX: Allow this failure on linux systems for now. It + * occurs when we attempt to open the /dev/zfs without the + * ZFS module stack loaded. This is normally a problem but + * tools such as zdb call this function and never use the + * ioctl() interface. Long term this should be cleaned up. + */ + if (errno != ENXIO) { + free(hdl); + return (NULL); + } } #ifdef HAVE_SETMNTENT @@ -592,7 +600,8 @@ libzfs_init(void) void libzfs_fini(libzfs_handle_t *hdl) { - (void) close(hdl->libzfs_fd); + if (hdl->libzfs_fd != -1) + (void) close(hdl->libzfs_fd); if (hdl->libzfs_mnttab) #ifdef HAVE_SETMNTENT (void) endmntent(hdl->libzfs_mnttab);