Linux 3.3 compat, sops->show_options()
[zfs.git] / cmd / zdb / zdb.c
index 012d009..2f5f19e 100644 (file)
@@ -55,7 +55,6 @@
 #include <sys/arc.h>
 #include <sys/ddt.h>
 #undef ZFS_MAXNAMELEN
-#undef verify
 #include <libzfs.h>
 
 #define        ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
@@ -87,7 +86,7 @@ libzfs_handle_t *g_zfs;
  * debugging facilities.
  */
 const char *
-_umem_debug_init()
+_umem_debug_init(void)
 {
        return ("default,verbose"); /* $UMEM_DEBUG setting */
 }
@@ -1221,7 +1220,7 @@ static boolean_t sa_loaded;
 sa_attr_type_t *sa_attr_table;
 
 static void
-fuid_table_destroy()
+fuid_table_destroy(void)
 {
        if (fuid_table_loaded) {
                zfs_fuid_table_destroy(&idx_tree, &domain_tree);
@@ -1804,7 +1803,7 @@ dump_label(const char *dev)
                exit(1);
        }
 
-       if (fstat64(fd, &statbuf) != 0) {
+       if (fstat64_blk(fd, &statbuf) != 0) {
                (void) printf("failed to stat '%s': %s\n", path,
                    strerror(errno));
                free(path);
@@ -1812,14 +1811,6 @@ dump_label(const char *dev)
                exit(1);
        }
 
-       if (S_ISBLK(statbuf.st_mode)) {
-               (void) printf("cannot use '%s': character device required\n",
-                   path);
-               free(path);
-               (void) close(fd);
-               exit(1);
-       }
-
        psize = statbuf.st_size;
        psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
 
@@ -2179,7 +2170,7 @@ count_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
 static int
 dump_block_stats(spa_t *spa)
 {
-       zdb_cb_t zcb = { 0 };
+       zdb_cb_t zcb;
        zdb_blkstats_t *zb, *tzb;
        uint64_t norm_alloc, norm_space, total_alloc, total_found;
        int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD;
@@ -2201,6 +2192,7 @@ dump_block_stats(spa_t *spa)
         * it's not part of any space map) is a double allocation,
         * reference to a freed block, or an unclaimed log block.
         */
+       bzero(&zcb, sizeof(zdb_cb_t));
        zdb_leak_init(spa, &zcb);
 
        /*
@@ -2413,8 +2405,11 @@ dump_simulated_ddt(spa_t *spa)
        avl_tree_t t;
        void *cookie = NULL;
        zdb_ddt_entry_t *zdde;
-       ddt_histogram_t ddh_total = { 0 };
-       ddt_stat_t dds_total = { 0 };
+       ddt_histogram_t ddh_total;
+       ddt_stat_t dds_total;
+
+       bzero(&ddh_total, sizeof (ddt_histogram_t));
+       bzero(&dds_total, sizeof (ddt_stat_t));
 
        avl_create(&t, ddt_entry_compare,
            sizeof (zdb_ddt_entry_t), offsetof(zdb_ddt_entry_t, zdde_node));
@@ -2884,7 +2879,7 @@ find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
        nvlist_t *match = NULL;
        char *name = NULL;
        char *sepp = NULL;
-       char sep;
+       char sep = 0;
        int count = 0;
        importargs_t args = { 0 };
 
@@ -3033,8 +3028,8 @@ main(int argc, char **argv)
        }
 
        kernel_init(FREAD);
-       g_zfs = libzfs_init();
-       ASSERT(g_zfs != NULL);
+       if ((g_zfs = libzfs_init()) == NULL)
+               return (1);
 
        if (dump_all)
                verbose = MAX(verbose, 1);