Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/mptutil/mpt_show.c
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | if (fd < 0) { | ||||
warn("mpt_open"); | warn("mpt_open"); | ||||
return (error); | return (error); | ||||
} | } | ||||
man0 = mpt_read_man_page(fd, 0, NULL); | man0 = mpt_read_man_page(fd, 0, NULL); | ||||
if (man0 == NULL) { | if (man0 == NULL) { | ||||
error = errno; | error = errno; | ||||
warn("Failed to get controller info"); | warn("Failed to get controller info"); | ||||
close(fd); | |||||
return (error); | return (error); | ||||
} | } | ||||
if (man0->Header.PageLength < sizeof(*man0) / 4) { | if (man0->Header.PageLength < sizeof(*man0) / 4) { | ||||
warnx("Invalid controller info"); | warnx("Invalid controller info"); | ||||
free(man0); | |||||
close(fd); | |||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
printf("mpt%d Adapter:\n", mpt_unit); | printf("mpt%d Adapter:\n", mpt_unit); | ||||
printf(" Board Name: %.16s\n", man0->BoardName); | printf(" Board Name: %.16s\n", man0->BoardName); | ||||
printf(" Board Assembly: %.16s\n", man0->BoardAssembly); | printf(" Board Assembly: %.16s\n", man0->BoardAssembly); | ||||
printf(" Chip Name: %.16s\n", man0->ChipName); | printf(" Chip Name: %.16s\n", man0->ChipName); | ||||
printf(" Chip Revision: %.16s\n", man0->ChipRevision); | printf(" Chip Revision: %.16s\n", man0->ChipRevision); | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | show_config(int ac, char **av) | ||||
} | } | ||||
/* Get the config from the controller. */ | /* Get the config from the controller. */ | ||||
ioc2 = mpt_read_ioc_page(fd, 2, NULL); | ioc2 = mpt_read_ioc_page(fd, 2, NULL); | ||||
ioc5 = mpt_read_ioc_page(fd, 5, NULL); | ioc5 = mpt_read_ioc_page(fd, 5, NULL); | ||||
if (ioc2 == NULL || ioc5 == NULL) { | if (ioc2 == NULL || ioc5 == NULL) { | ||||
error = errno; | error = errno; | ||||
warn("Failed to get config"); | warn("Failed to get config"); | ||||
free(ioc2); | |||||
close(fd); | |||||
return (error); | return (error); | ||||
} | } | ||||
if (mpt_fetch_disks(fd, &nsdisks, &sdisks) < 0) { | if (mpt_fetch_disks(fd, &nsdisks, &sdisks) < 0) { | ||||
error = errno; | error = errno; | ||||
warn("Failed to get standalone drive list"); | warn("Failed to get standalone drive list"); | ||||
free(ioc5); | |||||
free(ioc2); | |||||
close(fd); | |||||
return (error); | return (error); | ||||
} | } | ||||
/* Dump out the configuration. */ | /* Dump out the configuration. */ | ||||
printf("mpt%d Configuration: %d volumes, %d drives\n", | printf("mpt%d Configuration: %d volumes, %d drives\n", | ||||
mpt_unit, ioc2->NumActiveVolumes, ioc2->NumActivePhysDisks + | mpt_unit, ioc2->NumActiveVolumes, ioc2->NumActivePhysDisks + | ||||
nsdisks); | nsdisks); | ||||
vol = ioc2->RaidVolume; | vol = ioc2->RaidVolume; | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | for (i = 0; i < ioc2->NumActiveVolumes; vol++, i++) { | ||||
vnames = mpt_vol_names(fd, vol->VolumeBus, vol->VolumeID, NULL); | vnames = mpt_vol_names(fd, vol->VolumeBus, vol->VolumeID, NULL); | ||||
if (vnames != NULL) { | if (vnames != NULL) { | ||||
if (vnames->Name[0] != '\0') | if (vnames->Name[0] != '\0') | ||||
printf(" <%s>", vnames->Name); | printf(" <%s>", vnames->Name); | ||||
free(vnames); | free(vnames); | ||||
} | } | ||||
printf("\n"); | printf("\n"); | ||||
} | } | ||||
free(volumes); | |||||
free(ioc2); | free(ioc2); | ||||
close(fd); | close(fd); | ||||
return (0); | return (0); | ||||
} | } | ||||
MPT_COMMAND(show, volumes, show_volumes); | MPT_COMMAND(show, volumes, show_volumes); | ||||
static int | static int | ||||
Show All 14 Lines | if (fd < 0) { | ||||
warn("mpt_open"); | warn("mpt_open"); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* Get the drive list. */ | /* Get the drive list. */ | ||||
list = mpt_pd_list(fd); | list = mpt_pd_list(fd); | ||||
if (list == NULL) { | if (list == NULL) { | ||||
error = errno; | error = errno; | ||||
close(fd); | |||||
warn("Failed to get drive list"); | warn("Failed to get drive list"); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* Fetch the list of standalone disks for this controller. */ | /* Fetch the list of standalone disks for this controller. */ | ||||
state_len = 0; | state_len = 0; | ||||
if (mpt_fetch_disks(fd, &nsdisks, &sdisks) != 0) { | if (mpt_fetch_disks(fd, &nsdisks, &sdisks) != 0) { | ||||
nsdisks = 0; | nsdisks = 0; | ||||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |