210 nvlist_t *f1 = NULL, *f2 = NULL;
211 nvlist_t **h1 = NULL, **h2 = NULL;
212 uint_t h1sz, h2sz;
213 int err, rc = 1;
214
215 if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
216 return (fmd_fmri_set_errno(EINVAL));
217
218 (void) topo_fmri_fru(thp, r1, &f1, &err);
219 (void) topo_fmri_fru(thp, r2, &f2, &err);
220 if (f1 != NULL && f2 != NULL) {
221 (void) nvlist_lookup_nvlist_array(f1, FM_FMRI_HC_LIST, &h1,
222 &h1sz);
223 (void) nvlist_lookup_nvlist_array(f2, FM_FMRI_HC_LIST, &h2,
224 &h2sz);
225 if (h1sz == h2sz && hclist_contains(h1, h1sz, h2, h2sz) == 1)
226 rc = 0;
227 }
228
229 fmd_fmri_topo_rele(thp);
230 if (f1 != NULL)
231 nvlist_free(f1);
232 if (f2 != NULL)
233 nvlist_free(f2);
234 return (rc);
235 }
236
237 int
238 fmd_fmri_contains(nvlist_t *er, nvlist_t *ee)
239 {
240 nvlist_t **erhcl, **eehcl;
241 uint_t erhclsz, eehclsz;
242 nvlist_t *hcsp;
243 uint64_t eroff, eeoff;
244
245 if (nvlist_lookup_nvlist_array(er, FM_FMRI_HC_LIST, &erhcl,
246 &erhclsz) != 0 || nvlist_lookup_nvlist_array(ee,
247 FM_FMRI_HC_LIST, &eehcl, &eehclsz) != 0)
248 return (fmd_fmri_set_errno(EINVAL));
249
250 /*
251 * Check ee is further down the hc tree than er; er and ee have
252 * the same auth and are on the same fru.
|
210 nvlist_t *f1 = NULL, *f2 = NULL;
211 nvlist_t **h1 = NULL, **h2 = NULL;
212 uint_t h1sz, h2sz;
213 int err, rc = 1;
214
215 if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
216 return (fmd_fmri_set_errno(EINVAL));
217
218 (void) topo_fmri_fru(thp, r1, &f1, &err);
219 (void) topo_fmri_fru(thp, r2, &f2, &err);
220 if (f1 != NULL && f2 != NULL) {
221 (void) nvlist_lookup_nvlist_array(f1, FM_FMRI_HC_LIST, &h1,
222 &h1sz);
223 (void) nvlist_lookup_nvlist_array(f2, FM_FMRI_HC_LIST, &h2,
224 &h2sz);
225 if (h1sz == h2sz && hclist_contains(h1, h1sz, h2, h2sz) == 1)
226 rc = 0;
227 }
228
229 fmd_fmri_topo_rele(thp);
230 nvlist_free(f1);
231 nvlist_free(f2);
232 return (rc);
233 }
234
235 int
236 fmd_fmri_contains(nvlist_t *er, nvlist_t *ee)
237 {
238 nvlist_t **erhcl, **eehcl;
239 uint_t erhclsz, eehclsz;
240 nvlist_t *hcsp;
241 uint64_t eroff, eeoff;
242
243 if (nvlist_lookup_nvlist_array(er, FM_FMRI_HC_LIST, &erhcl,
244 &erhclsz) != 0 || nvlist_lookup_nvlist_array(ee,
245 FM_FMRI_HC_LIST, &eehcl, &eehclsz) != 0)
246 return (fmd_fmri_set_errno(EINVAL));
247
248 /*
249 * Check ee is further down the hc tree than er; er and ee have
250 * the same auth and are on the same fru.
|