diff options
author | George Wilson <George.Wilson@delphix.com> | 2011-10-18 12:16:24 -0700 |
---|---|---|
committer | George Wilson <George.Wilson@delphix.com> | 2011-10-18 12:16:24 -0700 |
commit | 9729663dccf3af95363464bd23939c153a918fd9 (patch) | |
tree | 774e5546746d7965ff557030902ea28d8bbbba38 /usr/src/lib/libdiskmgt/common/findevs.c | |
parent | d66f292d0062ce8c43a0c493d881a24f3b991317 (diff) | |
download | illumos-joyent-9729663dccf3af95363464bd23939c153a918fd9.tar.gz |
1414 libdiskmgmt does not clean up invalid paths
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src/lib/libdiskmgt/common/findevs.c')
-rw-r--r-- | usr/src/lib/libdiskmgt/common/findevs.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/usr/src/lib/libdiskmgt/common/findevs.c b/usr/src/lib/libdiskmgt/common/findevs.c index a2a9c088c8..9728eab65e 100644 --- a/usr/src/lib/libdiskmgt/common/findevs.c +++ b/usr/src/lib/libdiskmgt/common/findevs.c @@ -21,6 +21,7 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2011 by Delphix. All rights reserved. */ #include <fcntl.h> @@ -860,7 +861,6 @@ add_ptr2array(void *p, void ***parray) static void remove_controller(controller_t *cp, controller_t *currp) { - disk_t *dp; int i; if (cp == currp) { @@ -884,20 +884,28 @@ remove_controller(controller_t *cp, controller_t *currp) * is a 'path' so any disk that has a reference to it * as a controller needs to have this reference removed. */ - dp = cp->disks[0]; - while (dp != NULL) { - for (i = 0; dp->controllers[i]; i++) { - if (libdiskmgt_str_eq(dp->controllers[i]->name, + for (i = 0; cp->disks[i]; i++) { + disk_t *dp = cp->disks[i]; + int j; + + for (j = 0; dp->controllers[j]; j++) { + int k; + + if (libdiskmgt_str_eq(dp->controllers[j]->name, cp->name)) { - int j; - for (j = i; dp->controllers[j]; j++) { - dp->controllers[j] = - dp->controllers[j + 1]; + if (dm_debug) { + (void) fprintf(stderr, + "INFO: REMOVING disk %s on " + "controller %s\n", + dp->kernel_name, cp->name); + } + for (k = j; dp->controllers[k]; k++) { + dp->controllers[k] = + dp->controllers[k + 1]; } } } - dp = dp->next; } } /* |