From cc4fbf2c35068c395a0ae896be25eff253b94bc5 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 18 Mar 2009 12:48:54 -0700 Subject: [PATCH] Revert to previous behavior zdb fails when unable to open /dev/zfs. For the moment I have added an error message to the failure path to make it clear what happened. I have also changed the zdb ASSERT to a VERIFY so we always catch the failure. For now we will just always ensure the module stack is loaded, longer term we need something a little more flexible. --- cmd/zdb/zdb.c | 2 +- lib/libzfs/libzfs_util.c | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index fb9c4be6f0..5aa9426e19 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -2330,7 +2330,7 @@ main(int argc, char **argv) kernel_init(FREAD); g_zfs = libzfs_init(); - ASSERT(g_zfs != NULL); + VERIFY(g_zfs != NULL); for (c = 0; c < 256; c++) { if (dump_all && c != 'l' && c != 'R') diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index e81a9535b2..1a2ee256f7 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -560,16 +560,10 @@ libzfs_init(void) } if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) { - /* 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); - } + (void) fprintf(stderr, "Unable to open %s: (%d) %s\n", + ZFS_DEV, errno, strerror(errno)); + free(hdl); + return (NULL); } if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) { @@ -589,8 +583,7 @@ libzfs_init(void) void libzfs_fini(libzfs_handle_t *hdl) { - if (hdl->libzfs_fd != -1) - (void) close(hdl->libzfs_fd); + (void) close(hdl->libzfs_fd); if (hdl->libzfs_mnttab) (void) fclose(hdl->libzfs_mnttab); if (hdl->libzfs_sharetab)