Lines Matching +full:i +full:- +full:drive
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
16 * 3. Neither the name of the author nor the names of any co-contributors
55 switch (info->PhysDiskStatus.State) { in mpt_pdstate()
57 if ((info->PhysDiskStatus.Flags & in mpt_pdstate()
59 info->PhysDiskSettings.HotSparePool == 0) in mpt_pdstate()
78 sprintf(buf, "PSTATE 0x%02x", info->PhysDiskStatus.State); in mpt_pdstate()
88 * - IOC2 : This gives us a list of volumes, and by walking the volumes we
91 * - IOC3 : This gives us a list of all online physical drives including
92 * drives that are not part of a volume nor a spare drive. It
94 * - IOC5 : This gives us a list of all spare drives including failed
98 * found via IOC2, 2) a drive that is neither a volume member nor a spare
103 * routine to add each drive encountered. It quietly succeeds if the
104 * drive is already present in the list. It also sorts the list as it
110 int i, j; in mpt_pd_insert() local
114 * seen this drive. in mpt_pd_insert()
116 for (i = 0; i < list->ndrives; i++) { in mpt_pd_insert()
117 if (list->drives[i]->PhysDiskNum == PhysDiskNum) in mpt_pd_insert()
119 if (list->drives[i]->PhysDiskNum > PhysDiskNum) in mpt_pd_insert()
124 * 'i' is our slot for the 'new' drive. Make room and then in mpt_pd_insert()
125 * read the drive info. in mpt_pd_insert()
127 for (j = list->ndrives - 1; j >= i; j--) in mpt_pd_insert()
128 list->drives[j + 1] = list->drives[j]; in mpt_pd_insert()
129 list->drives[i] = mpt_pd_info(fd, PhysDiskNum, NULL); in mpt_pd_insert()
130 if (list->drives[i] == NULL) in mpt_pd_insert()
132 list->ndrives++; in mpt_pd_insert()
148 int count, error, i, j; in mpt_pd_list() local
162 warn("Failed to fetch drive list"); in mpt_pd_list()
182 volumes = malloc(sizeof(*volumes) * ioc2->NumActiveVolumes); in mpt_pd_list()
184 vol = ioc2->RaidVolume; in mpt_pd_list()
185 for (i = 0; i < ioc2->NumActiveVolumes; vol++, i++) { in mpt_pd_list()
186 volumes[i] = mpt_vol_info(fd, vol->VolumeBus, vol->VolumeID, in mpt_pd_list()
188 if (volumes[i] == NULL) { in mpt_pd_list()
198 count += volumes[i]->NumPhysDisks; in mpt_pd_list()
200 count += ioc3->NumPhysDisks; in mpt_pd_list()
201 count += ioc5->NumHotSpares; in mpt_pd_list()
207 for (i = 0; i < ioc2->NumActiveVolumes; i++) { in mpt_pd_list()
208 rdisk = volumes[i]->PhysDisk; in mpt_pd_list()
209 for (j = 0; j < volumes[i]->NumPhysDisks; rdisk++, j++) in mpt_pd_list()
210 if (mpt_pd_insert(fd, list, rdisk->PhysDiskNum) < 0) { in mpt_pd_list()
218 free(volumes[i]); in mpt_pd_list()
223 spare = ioc5->HotSpare; in mpt_pd_list()
224 for (i = 0; i < ioc5->NumHotSpares; spare++, i++) in mpt_pd_list()
225 if (mpt_pd_insert(fd, list, spare->PhysDiskNum) < 0) { in mpt_pd_list()
233 disk = ioc3->PhysDisk; in mpt_pd_list()
234 for (i = 0; i < ioc3->NumPhysDisks; disk++, i++) in mpt_pd_list()
235 if (mpt_pd_insert(fd, list, disk->PhysDiskNum) < 0) { in mpt_pd_list()
248 int i; in mpt_free_pd_list() local
250 for (i = 0; i < list->ndrives; i++) in mpt_free_pd_list()
251 free(list->drives[i]); in mpt_free_pd_list()
256 mpt_lookup_drive(struct mpt_drive_list *list, const char *drive, in mpt_lookup_drive() argument
264 val = strtol(drive, &cp, 0); in mpt_lookup_drive()
284 for (val = 0; val < list->ndrives; val++) { in mpt_lookup_drive()
285 if (list->drives[val]->PhysDiskBus == bus && in mpt_lookup_drive()
286 list->drives[val]->PhysDiskID == id) { in mpt_lookup_drive()
287 *PhysDiskNum = list->drives[val]->PhysDiskNum; in mpt_lookup_drive()
306 inq_data = &pd_info->InquiryData; in mpt_pd_inq_string()
307 cam_strvis(vendor, inq_data->VendorID, sizeof(inq_data->VendorID), in mpt_pd_inq_string()
309 cam_strvis(product, inq_data->ProductID, sizeof(inq_data->ProductID), in mpt_pd_inq_string()
311 cam_strvis(revision, inq_data->ProductRevLevel, in mpt_pd_inq_string()
312 sizeof(inq_data->ProductRevLevel), sizeof(revision)); in mpt_pd_inq_string()
324 /* Helper function to set a drive to a given state. */
326 drive_set_state(char *drive, U8 Action, U8 State, const char *name) in drive_set_state() argument
346 if (mpt_lookup_drive(list, drive, &PhysDiskNum) < 0) { in drive_set_state()
348 warn("Failed to find drive %s", drive); in drive_set_state()
354 /* Get the info for this drive. */ in drive_set_state()
358 warn("Failed to fetch info for drive %u", PhysDiskNum); in drive_set_state()
364 if (info->PhysDiskStatus.State == State) { in drive_set_state()
365 warnx("Drive %u is already in the desired state", PhysDiskNum); in drive_set_state()
374 warnc(error, "Failed to set drive %u to %s", PhysDiskNum, name); in drive_set_state()
392 "drive required"); in fail_drive()
407 "drive required"); in online_drive()
422 "drive required"); in offline_drive()