Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:Test
multipath-tools
multipath-tools-enhance-error-for-checkers
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File multipath-tools-enhance-error-for-checkers of Package multipath-tools
From 5974ba6dd190ed7b5633467962c2cd1dd2beb85d Mon Sep 17 00:00:00 2001 From: Hannes Reinecke <hare@suse.de> Date: Fri, 12 Dec 2008 13:49:30 +0100 Subject: [PATCH] Enhanced error for invalid checker or prioritizer An invalid checker or prioritizer shouldn't be greeted with the incomprehensible 'A dynamic linking error ...' message. Rather display something sensible here. Oh, and fix up list initialization alloc_X(). References: 456214 Signed-off-by: Hannes Reinecke <hare@suse.de> --- libmultipath/checkers.c | 23 +++++++++++++++++------ libmultipath/prio.c | 22 +++++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 2640281..231b408 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -2,6 +2,7 @@ #include <string.h> #include <stddef.h> #include <dlfcn.h> +#include <sys/stat.h> #include "debug.h" #include "checkers.h" @@ -35,7 +36,12 @@ int init_checkers (void) struct checker * alloc_checker (void) { - return zalloc(sizeof(struct checker)); + struct checker *c; + + c = zalloc(sizeof(struct checker)); + if (c) + INIT_LIST_HEAD(&c->node); + return c; } void free_checker (struct checker * c) @@ -75,6 +81,7 @@ struct checker * checker_lookup (char * name) struct checker * add_checker (char * name) { char libname[LIB_CHECKER_NAMELEN]; + struct stat stbuf; struct checker * c; char *errstr; @@ -83,14 +90,18 @@ struct checker * add_checker (char * name) return NULL; snprintf(libname, LIB_CHECKER_NAMELEN, "%s/libcheck%s.so", conf->multipath_dir, name); + if (stat(libname,&stbuf) < 0) { + condlog(0,"Invalid checker '%s'", name); + goto out; + } condlog(3, "loading %s checker", libname); c->handle = dlopen(libname, RTLD_NOW); - errstr = dlerror(); - if (errstr != NULL) - condlog(0, "A dynamic linking error occurred: (%s)", errstr); - if (!c->handle) + if (!c->handle) { + if ((errstr = dlerror()) != NULL) + condlog(0, "A dynamic linking error occurred: (%s)", + errstr); goto out; - + } c->check = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_check"); errstr = dlerror(); if (errstr != NULL) diff --git a/libmultipath/prio.c b/libmultipath/prio.c index 352e9ca..1b9f51b 100644 --- a/libmultipath/prio.c +++ b/libmultipath/prio.c @@ -2,6 +2,7 @@ #include <string.h> #include <stddef.h> #include <dlfcn.h> +#include <sys/stat.h> #include "debug.h" #include "prio.h" @@ -19,7 +20,12 @@ int init_prio (void) struct prio * alloc_prio (void) { - return zalloc(sizeof(struct prio)); + struct prio *p; + + p = zalloc(sizeof(struct prio)); + if (p) + INIT_LIST_HEAD(&p->node); + return p; } void free_prio (struct prio * p) @@ -59,6 +65,7 @@ struct prio * prio_lookup (char * name) struct prio * add_prio (char * name) { char libname[LIB_PRIO_NAMELEN]; + struct stat stbuf; struct prio * p; char *errstr; @@ -67,13 +74,18 @@ struct prio * add_prio (char * name) return NULL; snprintf(libname, LIB_PRIO_NAMELEN, "%s/libprio%s.so", conf->multipath_dir, name); + if (stat(libname,&stbuf) < 0) { + condlog(0,"Invalid prioritizer '%s'", name); + goto out; + } condlog(3, "loading %s prioritizer", libname); p->handle = dlopen(libname, RTLD_NOW); - errstr = dlerror(); - if (errstr != NULL) - condlog(0, "A dynamic linking error occurred: (%s)", errstr); - if (!p->handle) + if (!p->handle) { + if ((errstr = dlerror()) != NULL) + condlog(0, "A dynamic linking error occurred: (%s)", + errstr); goto out; + } p->getprio = (int (*)(struct path *)) dlsym(p->handle, "getprio"); errstr = dlerror(); if (errstr != NULL) -- 1.6.0.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor