summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zfs/zfs_iter.c4
-rw-r--r--usr/src/lib/libdiskmgt/common/cache.c548
2 files changed, 278 insertions, 274 deletions
diff --git a/usr/src/cmd/zfs/zfs_iter.c b/usr/src/cmd/zfs/zfs_iter.c
index c888bbafde..4c8a3aed62 100644
--- a/usr/src/cmd/zfs/zfs_iter.c
+++ b/usr/src/cmd/zfs/zfs_iter.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -296,7 +296,7 @@ zfs_sort(const void *larg, const void *rarg, void *data)
if (lstr)
ret = strcmp(lstr, rstr);
- if (lnum < rnum)
+ else if (lnum < rnum)
ret = -1;
else if (lnum > rnum)
ret = 1;
diff --git a/usr/src/lib/libdiskmgt/common/cache.c b/usr/src/lib/libdiskmgt/common/cache.c
index 1d56c353fa..922847aa08 100644
--- a/usr/src/lib/libdiskmgt/common/cache.c
+++ b/usr/src/lib/libdiskmgt/common/cache.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -46,7 +45,7 @@
#define DEVPATHS 1
/*
- * Set DM_LIBDISKMGT_DEBUG in the environment. Two levels of debugging:
+ * Set DM_LIBDISKMGT_DEBUG in the environment. Two levels of debugging:
* 1 - errors, warnings and minimal tracing information
* 2 - verbose information
* All output prints on stderr.
@@ -89,7 +88,7 @@ static void update_desc_pathp(descriptor_t *descp,
/*
* We only cache some of the data that we can obtain. For much of the data
* (e.g. slices & disks getting repartitioned) there are no events which would
- * enable us to cache. As more events are added we can cache more information.
+ * enable us to cache. As more events are added we can cache more information.
*
* Currently we cache the information we get from the dev tree walk. This is
* basically the information about the drives, aliases, devpaths, controllers
@@ -97,15 +96,15 @@ static void update_desc_pathp(descriptor_t *descp,
* or slices.
*
* A fundamental part of the API design is that the application can hold on
- * to a set of descriptors for an indeterminate amount of time. Even if the
+ * to a set of descriptors for an indeterminate amount of time. Even if the
* application does not hold descriptors there is a window of time between the
* call that gets the descriptor and the use of the descriptor to get more
- * information. Because of this, the cache design must work even if the object
+ * information. Because of this, the cache design must work even if the object
* that the descriptor refers to no longer exists.
*
* Given this requirement, the code implements a two level cache. The
* descriptors that the application gets are really pointers into the first
- * level of the cache. This first level contains the actual descriptors.
+ * level of the cache. This first level contains the actual descriptors.
* These descriptors in turn refer to the objects we build from the dev tree
* walk which represent the drives and controllers. This is the second level
* in the cache.
@@ -114,13 +113,13 @@ static void update_desc_pathp(descriptor_t *descp,
* we go through the first level (the descriptors) and update the pointers
* in those descriptors to refer to the new objects in the second level. If
* the object that the descriptor referred to is no longer in existence, we
- * just null out the pointer in the descriptor. In this way the code that
+ * just null out the pointer in the descriptor. In this way the code that
* uses the descriptors knows that the object referred to by the descriptor
* no longer exists.
*
* We keep a reference count in the descriptors. This is incremented when
* we hand out a pointer to the descriptor and decremented when the application
- * frees the descriptor it has. When the reference count goes to 0 we garbage
+ * frees the descriptor it has. When the reference count goes to 0 we garbage
* collect the descriptors. In this way we only have to update active
* descriptors when we refresh the cache after an event.
*
@@ -137,7 +136,7 @@ static void update_desc_pathp(descriptor_t *descp,
* seperate the act of making the descriptor within the cache (which requires
* us to call back out to one of the object functions - drive_make_descriptors)
* from the act of handing out the descriptor (which requires us to increment
- * the refcnt). In this way we keep all of the refcnt handling centralized
+ * the refcnt). In this way we keep all of the refcnt handling centralized
* in one function instead of forcing each object to ensure it replicates
* the refcnt handling correctly.
*
@@ -146,7 +145,7 @@ static void update_desc_pathp(descriptor_t *descp,
* the descriptor keeps a pointer to that object. For objects that we
* dynamically build, the descriptor uses a combination of a pointer to the
* base object (usually the drive) along with a name (e.g. the media name or
- * the alias). For objects that are based on media (e.g. a slice) we actually
+ * the alias). For objects that are based on media (e.g. a slice) we actually
* have to maintain a pointer (to the disk) and two names (e.g. the slice name
* and the media name which is the secondary name).
*/
@@ -163,23 +162,23 @@ cache_free_alias(alias_t *aliasp)
/* free devpaths */
dp = aliasp->devpaths;
while (dp != NULL) {
- slice_t *nextp;
+ slice_t *nextp;
- nextp = dp->next;
- free(dp->devpath);
- free(dp);
- dp = nextp;
+ nextp = dp->next;
+ free(dp->devpath);
+ free(dp);
+ dp = nextp;
}
/* free orig_paths */
dp = aliasp->orig_paths;
while (dp != NULL) {
- slice_t *nextp;
+ slice_t *nextp;
- nextp = dp->next;
- free(dp->devpath);
- free(dp);
- dp = nextp;
+ nextp = dp->next;
+ free(dp->devpath);
+ free(dp);
+ dp = nextp;
}
free(aliasp);
@@ -203,13 +202,13 @@ cache_free_controller(controller_t *cp)
free(cp->kstat_name);
free(cp->disks);
if (cp->paths != NULL) {
- int i;
+ int i;
- for (i = 0; cp->paths[i]; i++) {
- /* free the path since it can't exist w/o the controller */
- cache_free_path(cp->paths[i]);
- }
- free(cp->paths);
+ for (i = 0; cp->paths[i]; i++) {
+ /* free the path since it can't exist w/o the ctrlr */
+ cache_free_path(cp->paths[i]);
+ }
+ free(cp->paths);
}
free(cp);
@@ -219,24 +218,24 @@ void
cache_free_descriptor(descriptor_t *desc)
{
if (!cache_is_valid_desc(desc)) {
- return;
+ return;
}
desc->refcnt--;
if (desc->refcnt <= 0) {
- free(desc->name);
- free(desc->secondary_name);
- if (desc->prev == NULL) {
- /* this is the first descriptor, update head ptr */
- desc_listp = desc->next;
- } else {
- desc->prev->next = desc->next;
- }
- if (desc->next != NULL) {
- desc->next->prev = desc->prev;
- }
- free(desc);
+ free(desc->name);
+ free(desc->secondary_name);
+ if (desc->prev == NULL) {
+ /* this is the first descriptor, update head ptr */
+ desc_listp = desc->next;
+ } else {
+ desc->prev->next = desc->next;
+ }
+ if (desc->next != NULL) {
+ desc->next->prev = desc->prev;
+ }
+ free(desc);
}
}
@@ -246,7 +245,7 @@ cache_free_descriptors(descriptor_t **desc_list)
int i;
for (i = 0; desc_list[i]; i++) {
- cache_free_descriptor(desc_list[i]);
+ cache_free_descriptor(desc_list[i]);
}
free(desc_list);
@@ -259,7 +258,7 @@ cache_free_disk(disk_t *dp)
free(dp->device_id);
if (dp->devid != NULL) {
- devid_free(dp->devid);
+ devid_free(dp->devid);
}
free(dp->kernel_name);
free(dp->product_id);
@@ -269,11 +268,11 @@ cache_free_disk(disk_t *dp)
free(dp->paths);
ap = dp->aliases;
while (ap != NULL) {
- alias_t *nextp;
+ alias_t *nextp;
- nextp = ap->next;
- cache_free_alias(ap);
- ap = nextp;
+ nextp = ap->next;
+ cache_free_alias(ap);
+ ap = nextp;
}
free(dp);
@@ -282,16 +281,18 @@ cache_free_disk(disk_t *dp)
void
cache_free_path(path_t *pp)
{
- int i;
-
free(pp->name);
free(pp->disks);
free(pp->states);
- for (i = 0; pp->wwns[i]; i++) {
- free(pp->wwns[i]);
+ if (pp->wwns) {
+ int i;
+
+ for (i = 0; pp->wwns[i]; i++) {
+ free(pp->wwns[i]);
+ }
+ free(pp->wwns);
}
- free(pp->wwns);
free(pp);
}
@@ -300,7 +301,7 @@ bus_t *
cache_get_buslist()
{
if (initialize() != 0) {
- return (NULL);
+ return (NULL);
}
return (bus_listp);
@@ -310,7 +311,7 @@ controller_t *
cache_get_controllerlist()
{
if (initialize() != 0) {
- return (NULL);
+ return (NULL);
}
return (controller_listp);
@@ -319,7 +320,7 @@ cache_get_controllerlist()
/*
* This routine will either get the existing descriptor from the descriptor
* cache or make make a new descriptor and put it in the descriptor cache and
- * return a pointer to that descriptor. We increment the refcnt when we hand
+ * return a pointer to that descriptor. We increment the refcnt when we hand
* out the descriptor.
*/
descriptor_t *
@@ -329,14 +330,15 @@ cache_get_desc(int type, void *gp, char *name, char *secondary_name, int *errp)
*errp = 0;
if ((dp = have_desc(type, gp, name, secondary_name)) == NULL) {
- /* make a new desc */
- if ((dp = new_descriptor(type, gp, name, secondary_name)) == NULL) {
- *errp = ENOMEM;
- }
+ /* make a new desc */
+ if ((dp = new_descriptor(type, gp, name, secondary_name))
+ == NULL) {
+ *errp = ENOMEM;
+ }
}
if (dp != NULL) {
- dp->refcnt++;
+ dp->refcnt++;
}
return (dp);
@@ -351,33 +353,33 @@ cache_get_descriptors(int type, int *errp)
int pos;
if ((*errp = make_descriptors(type)) != 0) {
- return (NULL);
+ return (NULL);
}
/* count the number of active descriptors in the descriptor cache */
descp = desc_listp;
while (descp != NULL) {
- if (descp->type == type && descp->p.generic != NULL) {
- cnt++;
- }
- descp = descp->next;
+ if (descp->type == type && descp->p.generic != NULL) {
+ cnt++;
+ }
+ descp = descp->next;
}
descs = (descriptor_t **)calloc(cnt + 1, sizeof (descriptor_t *));
if (descs == NULL) {
- *errp = ENOMEM;
- return (NULL);
+ *errp = ENOMEM;
+ return (NULL);
}
pos = 0;
descp = desc_listp;
while (descp != NULL) {
- if (descp->type == type && descp->p.generic != NULL) {
- /* update refcnts before handing out the descriptors */
- descp->refcnt++;
- descs[pos++] = descp;
- }
- descp = descp->next;
+ if (descp->type == type && descp->p.generic != NULL) {
+ /* update refcnts before handing out the descriptors */
+ descp->refcnt++;
+ descs[pos++] = descp;
+ }
+ descp = descp->next;
}
descs[pos] = NULL;
@@ -389,7 +391,7 @@ disk_t *
cache_get_disklist()
{
if (initialize() != 0) {
- return (NULL);
+ return (NULL);
}
return (disk_listp);
@@ -401,9 +403,9 @@ cache_is_valid_desc(descriptor_t *d)
descriptor_t *descp;
for (descp = desc_listp; descp != NULL; descp = descp->next) {
- if (descp == d) {
- return (1);
- }
+ if (descp == d) {
+ return (1);
+ }
}
return (0);
@@ -420,10 +422,10 @@ cache_load_desc(int type, void *gp, char *name, char *secondary_name, int *errp)
{
*errp = 0;
if (have_desc(type, gp, name, secondary_name) == NULL) {
- /* make a new desc */
- if (new_descriptor(type, gp, name, secondary_name) == NULL) {
- *errp = ENOMEM;
- }
+ /* make a new desc */
+ if (new_descriptor(type, gp, name, secondary_name) == NULL) {
+ *errp = ENOMEM;
+ }
}
}
@@ -440,7 +442,7 @@ cache_unlock()
}
/*
- * This function is called when we get a devtree event. Type is either add
+ * This function is called when we get a devtree event. Type is either add
* or delete of a drive.
*
* For delete, we need to clean up the 2nd level structures and clean up
@@ -456,15 +458,15 @@ cache_update(dm_event_type_t ev_type, char *devname)
/* update the cache */
switch (ev_type) {
case DM_EV_DISK_ADD:
- rewalk_tree();
- events_new_event(devname, DM_DRIVE, DM_EV_TADD);
- break;
+ rewalk_tree();
+ events_new_event(devname, DM_DRIVE, DM_EV_TADD);
+ break;
case DM_EV_DISK_DELETE:
- orig_name = devname;
- devname = basename(devname);
- del_drive_by_name(devname);
- events_new_event(orig_name, DM_DRIVE, DM_EV_TREMOVE);
- break;
+ orig_name = devname;
+ devname = basename(devname);
+ del_drive_by_name(devname);
+ events_new_event(orig_name, DM_DRIVE, DM_EV_TREMOVE);
+ break;
}
cache_unlock();
@@ -489,10 +491,10 @@ clear_descriptors(void *gp)
descriptor_t *descp;
for (descp = desc_listp; descp != NULL; descp = descp->next) {
- if (descp->p.generic == gp) {
- /* clear descriptor */
- descp->p.generic = NULL;
- }
+ if (descp->p.generic == gp) {
+ /* clear descriptor */
+ descp->p.generic = NULL;
+ }
}
}
@@ -503,14 +505,14 @@ clr_ctrl_disk_ptr(controller_t *cp, disk_t *dp)
int i;
for (i = 0; cp->disks[i]; i++) {
- if (dp == cp->disks[i]) {
- int j;
+ if (dp == cp->disks[i]) {
+ int j;
- for (j = i; cp->disks[j]; j++) {
- cp->disks[j] = cp->disks[j + 1];
+ for (j = i; cp->disks[j]; j++) {
+ cp->disks[j] = cp->disks[j + 1];
+ }
+ return;
}
- return;
- }
}
}
@@ -521,14 +523,14 @@ clr_path_disk_ptr(path_t *pp, disk_t *dp)
int i;
for (i = 0; pp->disks[i]; i++) {
- if (dp == pp->disks[i]) {
- int j;
+ if (dp == pp->disks[i]) {
+ int j;
- for (j = i; pp->disks[j]; j++) {
- pp->disks[j] = pp->disks[j + 1];
+ for (j = i; pp->disks[j]; j++) {
+ pp->disks[j] = pp->disks[j + 1];
+ }
+ return;
}
- return;
- }
}
}
@@ -543,35 +545,35 @@ del_drive(disk_t *dp)
/* clear any ptrs from controllers to this drive */
if (dp->controllers != NULL) {
- for (i = 0; dp->controllers[i]; i++) {
- clr_ctrl_disk_ptr(dp->controllers[i], dp);
- }
+ for (i = 0; dp->controllers[i]; i++) {
+ clr_ctrl_disk_ptr(dp->controllers[i], dp);
+ }
}
/* clear any ptrs from paths to this drive */
if (dp->paths != NULL) {
- for (i = 0; dp->paths[i]; i++) {
- clr_path_disk_ptr(dp->paths[i], dp);
- }
+ for (i = 0; dp->paths[i]; i++) {
+ clr_path_disk_ptr(dp->paths[i], dp);
+ }
}
/* clear drive from disk list */
for (listp = disk_listp; listp != NULL; listp = listp->next) {
- if (dp == listp) {
+ if (dp == listp) {
+ if (prev == NULL) {
+ disk_listp = dp->next;
+ } else {
+ prev->next = dp->next;
+ }
+
+ break;
+ }
+
if (prev == NULL) {
- disk_listp = dp->next;
+ prev = disk_listp;
} else {
- prev->next = dp->next;
+ prev = prev->next;
}
-
- break;
- }
-
- if (prev == NULL) {
- prev = disk_listp;
- } else {
- prev = prev->next;
- }
}
cache_free_disk(dp);
@@ -586,14 +588,14 @@ del_drive_by_name(char *name)
disk_t *listp;
for (listp = disk_listp; listp != NULL; listp = listp->next) {
- alias_t *ap;
+ alias_t *ap;
- for (ap = listp->aliases; ap; ap = ap->next) {
- if (libdiskmgt_str_eq(name, ap->alias)) {
- del_drive(listp);
- return;
+ for (ap = listp->aliases; ap; ap = ap->next) {
+ if (libdiskmgt_str_eq(name, ap->alias)) {
+ del_drive(listp);
+ return;
+ }
}
- }
}
}
@@ -603,28 +605,28 @@ have_desc(int type, void *gp, char *name, char *secondary_name)
descriptor_t *descp;
if (name != NULL && name[0] == 0) {
- name = NULL;
+ name = NULL;
}
if (secondary_name != NULL && secondary_name[0] == 0) {
- secondary_name = NULL;
+ secondary_name = NULL;
}
descp = desc_listp;
while (descp != NULL) {
- if (descp->type == type && descp->p.generic == gp &&
- libdiskmgt_str_eq(descp->name, name)) {
- if (type == DM_SLICE || type == DM_PARTITION ||
- type == DM_PATH) {
- if (libdiskmgt_str_eq(descp->secondary_name,
- secondary_name)) {
- return (descp);
- }
- } else {
- return (descp);
+ if (descp->type == type && descp->p.generic == gp &&
+ libdiskmgt_str_eq(descp->name, name)) {
+ if (type == DM_SLICE || type == DM_PARTITION ||
+ type == DM_PATH) {
+ if (libdiskmgt_str_eq(descp->secondary_name,
+ secondary_name)) {
+ return (descp);
+ }
+ } else {
+ return (descp);
+ }
}
- }
- descp = descp->next;
+ descp = descp->next;
}
return (NULL);
@@ -676,34 +678,34 @@ make_descriptors(int type)
int error;
if ((error = initialize()) != 0) {
- return (error);
+ return (error);
}
switch (type) {
case DM_DRIVE:
- error = drive_make_descriptors();
- break;
+ error = drive_make_descriptors();
+ break;
case DM_BUS:
- error = bus_make_descriptors();
- break;
+ error = bus_make_descriptors();
+ break;
case DM_CONTROLLER:
- error = controller_make_descriptors();
- break;
+ error = controller_make_descriptors();
+ break;
case DM_PATH:
- error = path_make_descriptors();
- break;
+ error = path_make_descriptors();
+ break;
case DM_ALIAS:
- error = alias_make_descriptors();
- break;
+ error = alias_make_descriptors();
+ break;
case DM_MEDIA:
- error = media_make_descriptors();
- break;
+ error = media_make_descriptors();
+ break;
case DM_PARTITION:
- error = partition_make_descriptors();
- break;
+ error = partition_make_descriptors();
+ break;
case DM_SLICE:
- error = slice_make_descriptors();
- break;
+ error = slice_make_descriptors();
+ break;
}
return (error);
@@ -713,14 +715,14 @@ static int
match_alias(alias_t *ap, alias_t *listp)
{
if (ap->alias == NULL) {
- return (0);
+ return (0);
}
while (listp != NULL) {
- if (libdiskmgt_str_eq(ap->alias, listp->alias)) {
- return (1);
- }
- listp = listp->next;
+ if (libdiskmgt_str_eq(ap->alias, listp->alias)) {
+ return (1);
+ }
+ listp = listp->next;
}
return (0);
@@ -732,15 +734,15 @@ match_aliases(disk_t *d1p, disk_t *d2p)
alias_t *ap;
if (d1p->aliases == NULL || d2p->aliases == NULL) {
- return (0);
+ return (0);
}
ap = d1p->aliases;
while (ap != NULL) {
- if (match_alias(ap, d2p->aliases)) {
- return (1);
- }
- ap = ap->next;
+ if (match_alias(ap, d2p->aliases)) {
+ return (1);
+ }
+ ap = ap->next;
}
return (0);
@@ -750,19 +752,19 @@ static int
match_disk(disk_t *oldp, disk_t *newp)
{
if (oldp->devid != NULL) {
- if (newp->devid != NULL &&
- devid_compare(oldp->devid, newp->devid) == 0) {
- return (1);
- }
+ if (newp->devid != NULL &&
+ devid_compare(oldp->devid, newp->devid) == 0) {
+ return (1);
+ }
} else {
- /* oldp device id is null */
- if (newp->devid == NULL) {
- /* both disks have no device id, check aliases */
- if (match_aliases(oldp, newp)) {
- return (1);
+ /* oldp device id is null */
+ if (newp->devid == NULL) {
+ /* both disks have no device id, check aliases */
+ if (match_aliases(oldp, newp)) {
+ return (1);
+ }
}
- }
}
return (0);
@@ -774,59 +776,59 @@ new_descriptor(dm_desc_type_t type, void *op, char *name, char *secondary_name)
descriptor_t *d;
if (name != NULL && name[0] == 0) {
- name = NULL;
+ name = NULL;
}
if (secondary_name != NULL && secondary_name[0] == 0) {
- secondary_name = NULL;
+ secondary_name = NULL;
}
d = (descriptor_t *)malloc(sizeof (descriptor_t));
if (d == NULL) {
- return (NULL);
+ return (NULL);
}
d->type = type;
switch (type) {
case DM_CONTROLLER:
- d->p.controller = op;
- break;
+ d->p.controller = op;
+ break;
case DM_BUS:
- d->p.bus = op;
- break;
+ d->p.bus = op;
+ break;
default:
- d->p.disk = op;
- break;
+ d->p.disk = op;
+ break;
}
if (name != NULL) {
- d->name = strdup(name);
- if (d->name == NULL) {
- free(d);
- return (NULL);
- }
+ d->name = strdup(name);
+ if (d->name == NULL) {
+ free(d);
+ return (NULL);
+ }
} else {
- d->name = NULL;
+ d->name = NULL;
}
if (type == DM_SLICE || type == DM_PARTITION) {
- if (secondary_name != NULL) {
- d->secondary_name = strdup(secondary_name);
- if (d->secondary_name == NULL) {
- free(d->name);
- free(d);
- return (NULL);
+ if (secondary_name != NULL) {
+ d->secondary_name = strdup(secondary_name);
+ if (d->secondary_name == NULL) {
+ free(d->name);
+ free(d);
+ return (NULL);
+ }
+ } else {
+ d->secondary_name = NULL;
}
- } else {
- d->secondary_name = NULL;
- }
} else {
- d->secondary_name = NULL;
+ d->secondary_name = NULL;
}
d->refcnt = 0;
/* add this descriptor to the head of the list */
if (desc_listp != NULL) {
- desc_listp->prev = d;
+ desc_listp->prev = d;
}
d->prev = NULL;
d->next = desc_listp;
@@ -846,28 +848,28 @@ rewalk_tree()
findevs(&args);
if (args.dev_walk_status == 0) {
- descriptor_t *descp;
-
- /* walk the existing descriptors and update the ptrs */
- descp = desc_listp;
- while (descp != NULL) {
- update_desc(descp, args.disk_listp, args.controller_listp,
- args.bus_listp);
- descp = descp->next;
- }
+ descriptor_t *descp;
+
+ /* walk the existing descriptors and update the ptrs */
+ descp = desc_listp;
+ while (descp != NULL) {
+ update_desc(descp, args.disk_listp,
+ args.controller_listp, args.bus_listp);
+ descp = descp->next;
+ }
- /* update the cached object ptrs */
- free_disklistp = disk_listp;
- free_controllerlistp = controller_listp;
- free_buslistp = bus_listp;
- disk_listp = args.disk_listp;
- controller_listp = args.controller_listp;
- bus_listp = args.bus_listp;
+ /* update the cached object ptrs */
+ free_disklistp = disk_listp;
+ free_controllerlistp = controller_listp;
+ free_buslistp = bus_listp;
+ disk_listp = args.disk_listp;
+ controller_listp = args.controller_listp;
+ bus_listp = args.bus_listp;
} else {
- free_disklistp = args.disk_listp;
- free_controllerlistp = args.controller_listp;
- free_buslistp = args.bus_listp;
+ free_disklistp = args.disk_listp;
+ free_controllerlistp = args.controller_listp;
+ free_buslistp = args.bus_listp;
}
/*
@@ -875,25 +877,25 @@ rewalk_tree()
* update objects.
*/
while (free_disklistp != NULL) {
- disk_t *nextp;
+ disk_t *nextp;
- nextp = free_disklistp->next;
- cache_free_disk(free_disklistp);
- free_disklistp = nextp;
+ nextp = free_disklistp->next;
+ cache_free_disk(free_disklistp);
+ free_disklistp = nextp;
}
while (free_controllerlistp != NULL) {
- controller_t *nextp;
+ controller_t *nextp;
- nextp = free_controllerlistp->next;
- cache_free_controller(free_controllerlistp);
- free_controllerlistp = nextp;
+ nextp = free_controllerlistp->next;
+ cache_free_controller(free_controllerlistp);
+ free_controllerlistp = nextp;
}
while (free_buslistp != NULL) {
- bus_t *nextp;
+ bus_t *nextp;
- nextp = free_buslistp->next;
- cache_free_bus(free_buslistp);
- free_buslistp = nextp;
+ nextp = free_buslistp->next;
+ cache_free_bus(free_buslistp);
+ free_buslistp = nextp;
}
}
@@ -908,7 +910,7 @@ update_desc(descriptor_t *descp, disk_t *newdisksp, controller_t *newctrlp,
{
/* if the descriptor is already dead, we're done */
if (descp->p.generic == NULL) {
- return;
+ return;
}
/*
@@ -918,17 +920,17 @@ update_desc(descriptor_t *descp, disk_t *newdisksp, controller_t *newctrlp,
switch (descp->type) {
case DM_BUS:
- update_desc_busp(descp, newbusp);
- break;
+ update_desc_busp(descp, newbusp);
+ break;
case DM_CONTROLLER:
- update_desc_ctrlp(descp, newctrlp);
- break;
+ update_desc_ctrlp(descp, newctrlp);
+ break;
case DM_PATH:
- update_desc_pathp(descp, newctrlp);
- break;
+ update_desc_pathp(descp, newctrlp);
+ break;
default:
- update_desc_diskp(descp, newdisksp);
- break;
+ update_desc_diskp(descp, newdisksp);
+ break;
}
}
@@ -937,10 +939,10 @@ update_desc_busp(descriptor_t *descp, bus_t *busp)
{
/* walk the new objects and find the correct bus */
for (; busp; busp = busp->next) {
- if (libdiskmgt_str_eq(descp->p.bus->name, busp->name)) {
- descp->p.bus = busp;
- return;
- }
+ if (libdiskmgt_str_eq(descp->p.bus->name, busp->name)) {
+ descp->p.bus = busp;
+ return;
+ }
}
/* we did not find the controller any more, clear the ptr in the desc */
@@ -952,10 +954,11 @@ update_desc_ctrlp(descriptor_t *descp, controller_t *newctrlp)
{
/* walk the new objects and find the correct controller */
for (; newctrlp; newctrlp = newctrlp->next) {
- if (libdiskmgt_str_eq(descp->p.controller->name, newctrlp->name)) {
- descp->p.controller = newctrlp;
- return;
- }
+ if (libdiskmgt_str_eq(descp->p.controller->name,
+ newctrlp->name)) {
+ descp->p.controller = newctrlp;
+ return;
+ }
}
/* we did not find the controller any more, clear the ptr in the desc */
@@ -967,10 +970,10 @@ update_desc_diskp(descriptor_t *descp, disk_t *newdisksp)
{
/* walk the new objects and find the correct disk */
for (; newdisksp; newdisksp = newdisksp->next) {
- if (match_disk(descp->p.disk, newdisksp)) {
- descp->p.disk = newdisksp;
- return;
- }
+ if (match_disk(descp->p.disk, newdisksp)) {
+ descp->p.disk = newdisksp;
+ return;
+ }
}
/* we did not find the disk any more, clear the ptr in the descriptor */
@@ -982,19 +985,20 @@ update_desc_pathp(descriptor_t *descp, controller_t *newctrlp)
{
/* walk the new objects and find the correct path */
for (; newctrlp; newctrlp = newctrlp->next) {
- path_t **pp;
-
- pp = newctrlp->paths;
- if (pp != NULL) {
- int i;
-
- for (i = 0; pp[i]; i++) {
- if (libdiskmgt_str_eq(descp->p.path->name, pp[i]->name)) {
- descp->p.path = pp[i];
- return;
- }
+ path_t **pp;
+
+ pp = newctrlp->paths;
+ if (pp != NULL) {
+ int i;
+
+ for (i = 0; pp[i]; i++) {
+ if (libdiskmgt_str_eq(descp->p.path->name,
+ pp[i]->name)) {
+ descp->p.path = pp[i];
+ return;
+ }
+ }
}
- }
}
/* we did not find the path any more, clear the ptr in the desc */