diff options
author | Hannes Reinecke <hare@suse.de> | 2010-07-20 10:10:14 +0200 |
---|---|---|
committer | Christophe Varoqui <christophe.varoqui@opensvc.com> | 2010-07-26 10:30:17 +0200 |
commit | f3d38b8a2b62130833f05e20d1e3c925bb155196 (patch) | |
tree | 75135c85844fbb2855047866b5d229a43f34f770 | |
parent | 3eacec6d7be728605f92d748451494b048b49bb2 (diff) | |
download | multipath-tools-f3d38b8a2b62130833f05e20d1e3c925bb155196.tar.gz |
libmultipath: always allocate space for alias
We should always allocating space for alias. This makes
freeing up and allocation tracking far easier.
Signed-off-by: Hannes Reinecke <hare@suse.de>
-rw-r--r-- | libmultipath/propsel.c | 6 | ||||
-rw-r--r-- | libmultipath/structs.c | 4 | ||||
-rw-r--r-- | libmultipath/structs_vec.c | 10 |
3 files changed, 12 insertions, 8 deletions
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index ee4109e..3074ce1 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -239,7 +239,7 @@ extern int select_alias (struct multipath * mp) { if (mp->mpe && mp->mpe->alias) - mp->alias = mp->mpe->alias; + mp->alias = STRDUP(mp->mpe->alias); else { mp->alias = NULL; if (conf->user_friendly_names) { @@ -257,7 +257,7 @@ select_alias (struct multipath * mp) } } if (mp->alias == NULL) - mp->alias = mp->wwid; + mp->alias = STRDUP(mp->wwid); } return 0; @@ -472,7 +472,7 @@ select_pg_timeout(struct multipath *mp) return 0; } mp->pg_timeout = PGTIMEOUT_UNDEF; - condlog(3, "pg_timeout = NONE (internal default)"); + condlog(3, "%s: pg_timeout = NONE (internal default)", mp->alias); return 0; } diff --git a/libmultipath/structs.c b/libmultipath/structs.c index a4b86d2..82df680 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -163,9 +163,7 @@ free_multipath (struct multipath * mpp, int free_paths) free_multipath_attributes(mpp); - if (mpp->alias && - (!mpp->mpe || (mpp->mpe && mpp->alias != mpp->mpe->alias)) && - (mpp->wwid && mpp->alias != mpp->wwid)) { + if (mpp->alias) { FREE(mpp->alias); mpp->alias = NULL; } diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 699efa1..51c41e8 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -335,8 +335,13 @@ retry: condlog(3, "%s: discover", mpp->alias); if (update_multipath_strings(mpp, vecs->pathvec)) { - char new_alias[WWID_SIZE]; + char *new_alias; + new_alias = MALLOC(WWID_SIZE); + if (!new_alias) { + condlog(0, "%s: failed to allocate alias", mpp->alias); + goto out; + } /* * detect an external rename of the multipath device */ @@ -344,7 +349,8 @@ retry: condlog(3, "%s multipath mapped device name has " "changed from %s to %s", mpp->wwid, mpp->alias, new_alias); - strcpy(mpp->alias, new_alias); + FREE(mpp->alias); + mpp->alias = new_alias; if (mpp->waiter) strncpy(((struct event_thread *)mpp->waiter)->mapname, |