summaryrefslogtreecommitdiff
path: root/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c')
-rw-r--r--usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c
index 176306a3f7..ac73286fdd 100644
--- a/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c
+++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c
@@ -25,6 +25,7 @@
#include <dlfcn.h>
#include <link.h>
#include <stdio.h>
+#include <bunyan.h>
static varpd_impl_t *varpd_load_handle;
static const char *varpd_load_path;
@@ -58,18 +59,21 @@ libvarpd_plugin_alloc(uint_t version, int *errp)
errp = &err;
if (version != VARPD_VERSION_ONE) {
- (void) fprintf(stderr,
- "unsupported registration version %u - %s\n",
- version, varpd_load_path);
+ (void) bunyan_warn(varpd_load_handle->vdi_bunyan,
+ "unsupported registration version",
+ BUNYAN_T_STRING, "module_path", varpd_load_path,
+ BUNYAN_T_INT32, "module_version", version,
+ BUNYAN_T_END);
*errp = EINVAL;
return (NULL);
}
vprp = umem_alloc(sizeof (varpd_plugin_register_t), UMEM_DEFAULT);
if (vprp == NULL) {
- (void) fprintf(stderr,
- "failed to allocate registration handle - %s\n",
- varpd_load_path);
+ (void) bunyan_warn(varpd_load_handle->vdi_bunyan,
+ "failed to allocate registration handle",
+ BUNYAN_T_STRING, "module_path", varpd_load_path,
+ BUNYAN_T_END);
*errp = ENOMEM;
return (NULL);
}
@@ -93,17 +97,20 @@ libvarpd_plugin_register(varpd_plugin_register_t *vprp)
vpp = umem_alloc(sizeof (varpd_plugin_t), UMEM_DEFAULT);
if (vpp == NULL) {
- (void) fprintf(stderr,
- "failed to allocate memory for the varpd_plugin_t - %s\n",
- varpd_load_path);
+ (void) bunyan_warn(varpd_load_handle->vdi_bunyan,
+ "failed to allocate memory for the varpd_plugin_t",
+ BUNYAN_T_STRING, "module_path", varpd_load_path,
+ BUNYAN_T_END);
return (ENOMEM);
}
/* Watch out for an evil plugin */
if (vprp->vpr_version != VARPD_VERSION_ONE) {
- (void) fprintf(stderr,
- "unsupported registration version %u - %s\n",
- vprp->vpr_version, varpd_load_path);
+ (void) bunyan_warn(varpd_load_handle->vdi_bunyan,
+ "unsupported registration version",
+ BUNYAN_T_STRING, "module_path", varpd_load_path,
+ BUNYAN_T_INT32, "module_version", vprp->vpr_version,
+ BUNYAN_T_END);
return (EINVAL);
}
@@ -114,9 +121,11 @@ libvarpd_plugin_register(varpd_plugin_register_t *vprp)
mutex_enter(&varpd_load_handle->vdi_lock);
lookup.vpp_name = vprp->vpr_name;
if (avl_find(&varpd_load_handle->vdi_plugins, &lookup, NULL) != NULL) {
- (void) fprintf(stderr,
- "module already exists with requested name '%s' - %s\n",
- vprp->vpr_name, varpd_load_path);
+ (void) bunyan_warn(varpd_load_handle->vdi_bunyan,
+ "module already exists with requested name",
+ BUNYAN_T_STRING, "module_path", varpd_load_path,
+ BUNYAN_T_STRING, "name", vprp->vpr_name,
+ BUNYAN_T_END);
mutex_exit(&varpd_load_handle->vdi_lock);
mutex_exit(&varpd_load_lock);
umem_free(vpp, sizeof (varpd_plugin_t));
@@ -124,9 +133,10 @@ libvarpd_plugin_register(varpd_plugin_register_t *vprp)
}
vpp->vpp_name = strdup(vprp->vpr_name);
if (vpp->vpp_name == NULL) {
- (void) fprintf(stderr,
- "failed to allocate memory to duplicate name - %s\n",
- varpd_load_path);
+ (void) bunyan_warn(varpd_load_handle->vdi_bunyan,
+ "failed to allocate memory to duplicate name",
+ BUNYAN_T_STRING, "module_path", varpd_load_path,
+ BUNYAN_T_END);
mutex_exit(&varpd_load_handle->vdi_lock);
mutex_exit(&varpd_load_lock);
umem_free(vpp, sizeof (varpd_plugin_t));
@@ -167,8 +177,11 @@ libvarpd_plugin_load_cb(varpd_impl_t *vip, const char *path, void *unused)
varpd_load_path = path;
dlp = dlopen(path, RTLD_LOCAL | RTLD_NOW);
- if (dlp == NULL)
- (void) fprintf(stderr, "dlopen failed - %s\n", path);
+ if (dlp == NULL) {
+ (void) bunyan_error(vip->vdi_bunyan, "dlopen failed",
+ BUNYAN_T_STRING, "module path", path,
+ BUNYAN_T_END);
+ }
path = NULL;
return (0);