You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

248 lines
7.4 KiB

---
libmultipath/util.c | 22 ++++++++++++++++++++++
libmultipath/util.h | 1 +
multipath/main.c | 23 +----------------------
multipathd/cli_handlers.c | 18 ++++++++++++++++++
4 files changed, 42 insertions(+), 22 deletions(-)
Index: multipath-tools-130222/libmultipath/util.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/util.c
+++ multipath-tools-130222/libmultipath/util.c
@@ -236,6 +236,28 @@ skip_proc:
return 0;
}
+/* This function returns a pointer inside of the supplied pathname string.
+ * If is_path_device is true, it may also modify the supplied string */
+char *convert_dev(char *name, int is_path_device)
+{
+ char *ptr;
+
+ if (!name)
+ return NULL;
+ if (is_path_device) {
+ ptr = strstr(name, "cciss/");
+ if (ptr) {
+ ptr += 5;
+ *ptr = '!';
+ }
+ }
+ if (!strncmp(name, "/dev/", 5) && strlen(name) > 5)
+ ptr = name + 5;
+ else
+ ptr = name;
+ return ptr;
+}
+
dev_t parse_devt(const char *dev_t)
{
int maj, min;
Index: multipath-tools-130222/libmultipath/util.h
===================================================================
--- multipath-tools-130222.orig/libmultipath/util.h
+++ multipath-tools-130222/libmultipath/util.h
@@ -10,6 +10,7 @@ size_t strlcat(char *dst, const char *sr
void remove_trailing_chars(char *path, char c);
int devt2devname (char *, int, char *);
dev_t parse_devt(const char *dev_t);
+char *convert_dev(char *dev, int is_path_device);
#define safe_sprintf(var, format, args...) \
snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
Index: multipath-tools-130222/multipath/main.c
===================================================================
--- multipath-tools-130222.orig/multipath/main.c
+++ multipath-tools-130222/multipath/main.c
@@ -254,16 +254,7 @@ configure (void)
vecs.pathvec = pathvec;
vecs.mpvec = curmp;
- /*
- * dev is "/dev/" . "sysfs block dev"
- */
- if (conf->dev) {
- if (!strncmp(conf->dev, "/dev/", 5) &&
- strlen(conf->dev) > 5)
- dev = conf->dev + 5;
- else
- dev = conf->dev;
- }
+ dev = convert_dev(conf->dev, (conf->dev_type == DEV_DEVNODE));
/*
* if we have a blacklisted device parameter, exit early
@@ -427,16 +418,6 @@ get_dev_type(char *dev) {
return DEV_DEVMAP;
}
-static void
-convert_dev(char *dev)
-{
- char *ptr = strstr(dev, "cciss/");
- if (ptr) {
- ptr += 5;
- *ptr = '!';
- }
-}
-
int
main (int argc, char *argv[])
{
@@ -577,8 +558,6 @@ main (int argc, char *argv[])
strncpy(conf->dev, argv[optind], FILE_NAME_SIZE);
conf->dev_type = get_dev_type(conf->dev);
- if (conf->dev_type == DEV_DEVNODE)
- convert_dev(conf->dev);
}
conf->daemon = 0;
Index: multipath-tools-130222/multipathd/cli_handlers.c
===================================================================
--- multipath-tools-130222.orig/multipathd/cli_handlers.c
+++ multipath-tools-130222/multipathd/cli_handlers.c
@@ -235,6 +235,7 @@ cli_list_map_topology (void * v, char **
struct vectors * vecs = (struct vectors *)data;
char * param = get_keyparam(v, MAP);
+ param = convert_dev(param, 0);
get_path_layout(vecs->pathvec, 0);
mpp = find_mp_by_str(vecs->mpvec, param);
@@ -416,6 +417,7 @@ cli_add_path (void * v, char ** reply, i
struct path *pp;
int r;
+ param = convert_dev(param, 1);
condlog(2, "%s: add path (operator)", param);
if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
@@ -459,6 +461,7 @@ cli_del_path (void * v, char ** reply, i
char * param = get_keyparam(v, PATH);
struct path *pp;
+ param = convert_dev(param, 1);
condlog(2, "%s: remove path (operator)", param);
pp = find_path_by_dev(vecs->pathvec, param);
if (!pp) {
@@ -478,6 +481,7 @@ cli_add_map (void * v, char ** reply, in
char *alias;
int rc;
+ param = convert_dev(param, 0);
condlog(2, "%s: add map (operator)", param);
if (filter_wwid(conf->blist_wwid, conf->elist_wwid, param) > 0) {
@@ -518,6 +522,7 @@ cli_del_map (void * v, char ** reply, in
char *alias;
int rc;
+ param = convert_dev(param, 0);
condlog(2, "%s: remove map (operator)", param);
minor = dm_get_minor(param);
if (minor < 0) {
@@ -549,6 +554,7 @@ cli_reload(void *v, char **reply, int *l
struct multipath *mpp;
int minor;
+ mapname = convert_dev(mapname, 0);
condlog(2, "%s: reload map (operator)", mapname);
if (sscanf(mapname, "dm-%d", &minor) == 1)
mpp = find_mp_by_minor(vecs->mpvec, minor);
@@ -591,6 +597,7 @@ cli_resize(void *v, char **reply, int *l
struct pathgroup *pgp;
struct path *pp;
+ mapname = convert_dev(mapname, 0);
condlog(2, "%s: resize map (operator)", mapname);
if (sscanf(mapname, "dm-%d", &minor) == 1)
mpp = find_mp_by_minor(vecs->mpvec, minor);
@@ -665,6 +672,7 @@ cli_restore_queueing(void *v, char **rep
struct multipath *mpp;
int minor;
+ mapname = convert_dev(mapname, 0);
condlog(2, "%s: restore map queueing (operator)", mapname);
if (sscanf(mapname, "dm-%d", &minor) == 1)
mpp = find_mp_by_minor(vecs->mpvec, minor);
@@ -716,6 +724,7 @@ cli_disable_queueing(void *v, char **rep
struct multipath *mpp;
int minor;
+ mapname = convert_dev(mapname, 0);
condlog(2, "%s: disable map queueing (operator)", mapname);
if (sscanf(mapname, "dm-%d", &minor) == 1)
mpp = find_mp_by_minor(vecs->mpvec, minor);
@@ -753,6 +762,7 @@ cli_switch_group(void * v, char ** reply
char * mapname = get_keyparam(v, MAP);
int groupnum = atoi(get_keyparam(v, GROUP));
+ mapname = convert_dev(mapname, 0);
condlog(2, "%s: switch to path group #%i (operator)", mapname, groupnum);
return dm_switchgroup(mapname, groupnum);
@@ -775,6 +785,7 @@ cli_suspend(void * v, char ** reply, int
char * param = get_keyparam(v, MAP);
int r = dm_simplecmd_noflush(DM_DEVICE_SUSPEND, param);
+ param = convert_dev(param, 0);
condlog(2, "%s: suspend (operator)", param);
if (!r) /* error */
@@ -796,6 +807,7 @@ cli_resume(void * v, char ** reply, int
char * param = get_keyparam(v, MAP);
int r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param);
+ param = convert_dev(param, 0);
condlog(2, "%s: resume (operator)", param);
if (!r) /* error */
@@ -817,6 +829,7 @@ cli_reinstate(void * v, char ** reply, i
char * param = get_keyparam(v, PATH);
struct path * pp;
+ param = convert_dev(param, 1);
pp = find_path_by_dev(vecs->pathvec, param);
if (!pp)
@@ -837,6 +850,7 @@ cli_reassign (void * v, char ** reply, i
{
char * param = get_keyparam(v, MAP);
+ param = convert_dev(param, 0);
condlog(3, "%s: reset devices (operator)", param);
dm_reassign(param);
@@ -851,6 +865,7 @@ cli_fail(void * v, char ** reply, int *
struct path * pp;
int r;
+ param = convert_dev(param, 1);
pp = find_path_by_dev(vecs->pathvec, param);
if (!pp)
@@ -962,6 +977,7 @@ cli_getprstatus (void * v, char ** reply
struct vectors * vecs = (struct vectors *)data;
char * param = get_keyparam(v, MAP);
+ param = convert_dev(param, 0);
get_path_layout(vecs->pathvec, 0);
mpp = find_mp_by_str(vecs->mpvec, param);
@@ -991,6 +1007,7 @@ cli_setprstatus(void * v, char ** reply,
struct vectors * vecs = (struct vectors *)data;
char * param = get_keyparam(v, MAP);
+ param = convert_dev(param, 0);
get_path_layout(vecs->pathvec, 0);
mpp = find_mp_by_str(vecs->mpvec, param);
@@ -1013,6 +1030,7 @@ cli_unsetprstatus(void * v, char ** repl
struct vectors * vecs = (struct vectors *)data;
char * param = get_keyparam(v, MAP);
+ param = convert_dev(param, 0);
get_path_layout(vecs->pathvec, 0);
mpp = find_mp_by_str(vecs->mpvec, param);