From 4bf57acec86ef4e6c64699de4fa35dd3b6642cd2 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 9 Aug 2005 17:24:21 +0000 Subject: [PATCH] Factor out _get_library_path(). --- WHATS_NEW | 1 + lib/misc/sharedlib.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 43226f56b..5012def6f 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.01.15 - ================================= + Factor out _get_library_path(). Recognise ATA over Ethernet (aoe) devices. Version 2.01.14 - 4th August 2005 diff --git a/lib/misc/sharedlib.c b/lib/misc/sharedlib.c index 52a7506f3..c4314d747 100644 --- a/lib/misc/sharedlib.c +++ b/lib/misc/sharedlib.c @@ -22,21 +22,28 @@ #include #include -void *load_shared_library(struct config_tree *cft, const char *libname, - const char *desc) +static void _get_library_path(struct config_tree *cft, const char *libname, + char *path, int path_len) { - char path[PATH_MAX]; struct stat info; const char *lib_dir; - void *library; /* If libname doesn't begin with '/' then use lib_dir/libname, * if present */ if (libname[0] == '/' || !(lib_dir = find_config_str(cft->root, "global/library_dir", 0)) || - (lvm_snprintf(path, sizeof(path), "%s/%s", lib_dir, + (lvm_snprintf(path, path_len, "%s/%s", lib_dir, libname) == -1) || stat(path, &info) == -1) - strncpy(path, libname, sizeof(path)); + strncpy(path, libname, path_len); +} + +void *load_shared_library(struct config_tree *cft, const char *libname, + const char *desc) +{ + char path[PATH_MAX]; + void *library; + + _get_library_path(cft, libname, path, sizeof(path)); log_very_verbose("Opening shared %s library %s", desc, path);