int get_enclosure_info(struct enclosure *enclosure) { char name[LEN]; uint64_t sas_addr[SLOTNUM]; struct sys_sas_dev sys_sas_dev[SASNUM]; int i, j; if (-1 == get_boxname(name)) { perror("why"); return -1; } get_slot_info(name, sas_addr); i = get_scsidev_info(sys_sas_dev); fill_enclosure(sas_addr, sys_sas_dev, i, enclosure); return 0; }
int main(int ac, char **av) { char *path = NULL; int so = -1; int nslot; int i; if (proc_arg(ac, av) < 0) goto out; if ((so = connect_to_pccardd(&path)) < 0) goto out; if ((nslot = get_slot_number(so)) < 0) goto out; if (slot_map == 0) { printf("%d\n", nslot); } else { for (i = 0; i < nslot; i++) { if ((slot_map & (1 << i))) { char *manuf; char *version; char *device; int state; if (get_slot_info(so, i, &manuf, &version, &device, &state) < 0) goto out; if (manuf == NULL || version == NULL || device == NULL) goto out; printf("%d~%s~%s~%s~%s\n", i, manuf, version, device, strstate(state)); free(manuf); free(version); free(device); } } } out: if (path) { unlink(path); free(path); } if (so >= 0) close(so); exit(0); }