On 03/31/2010 04:50 PM, Hawrylewicz Czarnowski, Przemyslaw wrote: > Patch also adds some utilities One of which I see as being useful outside of the scope that you have envisioned: > diff --git a/mdstat.c b/mdstat.c > index 4a9f370..bb6179d 100644 > --- a/mdstat.c > +++ b/mdstat.c This is a generic file and routines in this code should be generic, not specific to a supertype. > + > +/* > + * Finds name of the active array holding this device > + * @param[in] devname name of member device > + * @param[out] devname name of array > + * > + * @return found (0), or > + * not found, failure (1) > + */ > + > +int mdstat_check_active(char *devname) > +{ > + struct mdstat_ent *mdstat = mdstat_read(0, 0); > + struct mdstat_ent *ent; > + char *name; > + > + if (!devname) > + return 1; > + name = strrchr(devname, '/'); > + if (name++ == NULL) > + return 1; > + > + for (ent = mdstat; ent; ent = ent->next) { > + struct dev_member *m; > + if (ent->active) /* only containers */ > + continue; > + for (m = ent->members; m; m = m->next) { > + if (!strcmp(m->name, name)) { > + strcpy(devname, ent->dev); > + return 0; > + } > + } > + } > + return 1; > +} This in particular is useful for things other than just looking up containers. It is useful for finding either native or external metadata based arrays that have a specific device in them. I will probably snag this for my code, but change it so that it is generic. -- Doug Ledford <dledford@xxxxxxxxxx> GPG KeyID: CFBFF194 http://people.redhat.com/dledford Infiniband specific RPMs available at http://people.redhat.com/dledford/Infiniband
Attachment:
signature.asc
Description: OpenPGP digital signature