-#define DLSYM(handle, func) \
- do { \
- sym.func = (typeof(sym.func))dlsym(handle, #func); \
- } while(0)
-
-/* populate the symbol table after a successful call to dlopen() */
-static int zfs_populate_symbols(void)
-{
- char *error;
-
- dlerror(); /* Clear any existing error */
-
- DLSYM(handle_libzfs, libzfs_init);
-#define libzfs_init (*sym.libzfs_init)
- DLSYM(handle_libzfs, libzfs_fini);
-#define libzfs_fini (*sym.libzfs_fini)
- DLSYM(handle_libzfs, libzfs_load_module);
-#define libzfs_load_module (*sym.libzfs_load_module)
- DLSYM(handle_libzfs, zfs_open);
-#define zfs_open (*sym.zfs_open)
- DLSYM(handle_libzfs, zfs_destroy);
-#define zfs_destroy (*sym.zfs_destroy)
- DLSYM(handle_libzfs, zfs_close);
-#define zfs_close (*sym.zfs_close)
- DLSYM(handle_libzfs, zfs_prop_set);
-#define zfs_prop_set (*sym.zfs_prop_set)
- DLSYM(handle_libzfs, zfs_get_user_props);
-#define zfs_get_user_props (*sym.zfs_get_user_props)
- DLSYM(handle_libzfs, zfs_name_valid);
-#define zfs_name_valid (*sym.zfs_name_valid)
- DLSYM(handle_libzfs, zpool_open);
-#define zpool_open (*sym.zpool_open)
- DLSYM(handle_libzfs, zpool_close);
-#define zpool_close (*sym.zpool_close)
- DLSYM(handle_nvpair, nvlist_lookup_string);
-#define nvlist_lookup_string (*sym.nvlist_lookup_string)
- DLSYM(handle_nvpair, nvlist_lookup_nvlist);
-#define nvlist_lookup_nvlist (*sym.nvlist_lookup_nvlist)
- DLSYM(handle_nvpair, nvlist_next_nvpair);
-#define nvlist_next_nvpair (*sym.nvlist_next_nvpair)
- DLSYM(handle_nvpair, nvpair_name);
-#define nvpair_name (*sym.nvpair_name)
-
- error = dlerror();
- if (error != NULL) {
- fatal();
- fprintf(stderr, "%s\n", error);
- return EINVAL;
- }
- return 0;
-}
-