Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / cmd / format / menu_defect.c
blobbed61ac53697d4fde102588593efdf85b7ddd9ea
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2016 by Delphix. All rights reserved.
28 * This file contains functions to implement the defect menu commands.
30 #include "global.h"
31 #include <unistd.h>
32 #include <string.h>
33 #include "misc.h"
34 #include "menu_defect.h"
35 #include "param.h"
36 #include "ctlr_scsi.h"
39 * This is the working defect list. All the commands here operate on
40 * the working list, except for 'commit'. This way the user can
41 * change their mind at any time without having mangled the current defect
42 * list.
44 struct defect_list work_list;
46 #ifdef __STDC__
48 /* Function prototypes for ANSI C Compilers */
49 static int commit_list(void);
51 #else /* __STDC__ */
53 /* Function prototypes for non-ANSI C Compilers */
54 static int commit_list();
56 #endif /* __STDC__ */
59 * This routine implements the 'restore' command. It sets the working
60 * list equal to the current list.
62 int
63 d_restore()
65 int i;
67 assert(!EMBEDDED_SCSI);
70 * If the working list has not been modified, there's nothing to do.
72 if (!(work_list.flags & LIST_DIRTY)) {
73 err_print("working list was not modified.\n");
74 return (0);
77 * Make sure the user is serious.
79 if (check("Ready to update working list, continue"))
80 return (-1);
82 * Lock out interrupts so the lists can't get mangled.
84 enter_critical();
86 * Kill off the old working list.
88 kill_deflist(&work_list);
90 * If the current isn't null, set the working list to be a
91 * copy of it.
93 if (cur_list.list != NULL) {
94 work_list.header = cur_list.header;
95 work_list.list = (struct defect_entry *)zalloc(
96 deflist_size(cur_blksz, work_list.header.count) *
97 cur_blksz);
98 for (i = 0; i < work_list.header.count; i++)
99 *(work_list.list + i) = *(cur_list.list + i);
102 * Initialize the flags since they are now in sync.
104 work_list.flags = 0;
105 if (work_list.list == NULL)
106 fmt_print("working list set to null.\n\n");
107 else
108 fmt_print("working list updated, total of %d defects.\n\n",
109 work_list.header.count);
110 exit_critical();
111 return (0);
115 * This routine implements the 'original' command. It extracts the
116 * manufacturer's defect list from the current disk.
119 d_original()
121 int status;
125 * If the controller does not support the extraction, we're out
126 * of luck.
128 if (cur_ops->op_ex_man == NULL) {
129 err_print("Controller does not support extracting ");
130 err_print("manufacturer's defect list.\n");
131 return (-1);
134 * Make sure the user is serious. Note, for SCSI disks
135 * since this is instantaneous, we will just do it and
136 * not ask for confirmation.
138 if (!(cur_ctype->ctype_flags & CF_CONFIRM) &&
139 check(
140 "Ready to update working list. This cannot be interrupted\n\
141 and may take a long while. Continue"))
142 return (-1);
144 * Lock out interrupts so we don't get half the list.
146 enter_critical();
148 * Kill off the working list.
150 kill_deflist(&work_list);
151 fmt_print("Extracting manufacturer's defect list...");
153 * Do the extraction.
155 status = (*cur_ops->op_ex_man)(&work_list);
156 if (status)
157 fmt_print("Extraction failed.\n\n");
158 else {
159 fmt_print("Extraction complete.\n");
160 fmt_print("Working list updated, total of %d defects.\n\n",
161 work_list.header.count);
164 * Mark the working list dirty since we modified it.
166 work_list.flags |= LIST_DIRTY;
167 exit_critical();
169 * Return status.
171 return (status);
175 * This routine implements the 'extract' command. It extracts the
176 * entire defect list from the current disk.
179 d_extract()
181 int status;
184 * If the controller does not support the extraction, we are out
185 * of luck.
187 if (cur_ops->op_ex_cur == NULL) {
188 err_print("Controller does not support extracting ");
189 err_print("current defect list.\n");
190 return (-1);
194 * If disk is unformatted, you really shouldn't do this.
195 * However, ask user to be sure.
197 if (! (cur_flags & DISK_FORMATTED) &&
198 (check(
199 "Cannot extract defect list from an unformatted disk. Continue")))
200 return (-1);
203 * If this takes a long time, let's ask the user if they
204 * doesn't mind waiting. Note, for SCSI disks
205 * this operation is instantaneous so we won't ask for
206 * for confirmation.
208 if (! (cur_ctype->ctype_flags & CF_CONFIRM) &&
209 check(
210 "Ready to extract working list. This cannot be interrupted\n\
211 and may take a long while. Continue"))
212 return (-1);
214 * Lock out interrupts so we don't get half the list and
215 * Kill off the working list.
217 enter_critical();
218 kill_deflist(&work_list);
219 fmt_print("Extracting defect list...");
222 * Do the extraction.
224 status = (*cur_ops->op_ex_cur)(&work_list);
225 if (status) {
226 if (!EMBEDDED_SCSI) {
227 if (cur_flags & DISK_FORMATTED)
228 read_list(&work_list);
230 if (work_list.list != NULL) {
231 status = 0;
232 fmt_print("Extraction complete.\n");
233 fmt_print(
234 "Working list updated, total of %d defects.\n\n",
235 work_list.header.count);
236 } else {
237 fmt_print("Extraction failed.\n\n");
239 } else {
240 fmt_print("Extraction failed.\n\n");
242 } else {
243 fmt_print("Extraction complete.\n");
244 fmt_print("Working list updated, total of %d defects.\n\n",
245 work_list.header.count);
248 * Mark the working list dirty since we modified it.
250 work_list.flags |= LIST_DIRTY;
251 exit_critical();
253 * Return status.
255 return (status);
259 * This routine implements the 'add' command. It allows the user to
260 * enter the working defect list manually. It loops infinitely until
261 * the user breaks out with a ctrl-C.
264 d_add()
266 int type, deflt, index;
267 diskaddr_t bn;
268 u_ioparam_t ioparam;
269 struct defect_entry def;
271 assert(!EMBEDDED_SCSI);
274 * Ask the user which mode of input they'd like to use.
276 fmt_print(" 0. bytes-from-index\n");
277 fmt_print(" 1. logical block\n");
278 deflt = 0;
279 ioparam.io_bounds.lower = 0;
280 ioparam.io_bounds.upper = 1;
281 type = input(FIO_INT, "Select input format (enter its number)", ':',
282 &ioparam, &deflt, DATA_INPUT);
283 fmt_print("\nEnter Control-C to terminate.\n");
284 loop:
285 if (type) {
287 * Mode selected is logical block. Input the defective block
288 * and fill in the defect entry with the info.
290 def.bfi = def.nbits = UNKNOWN;
291 ioparam.io_bounds.lower = 0;
292 if (cur_disk->label_type == L_TYPE_SOLARIS) {
293 ioparam.io_bounds.upper = physsects() - 1;
294 } else {
295 ioparam.io_bounds.upper = cur_parts->etoc->efi_last_lba;
297 bn = input(FIO_BN, "Enter defective block number", ':',
298 &ioparam, NULL, DATA_INPUT);
299 def.cyl = bn2c(bn);
300 def.head = bn2h(bn);
301 def.sect = bn2s(bn);
302 } else {
304 * Mode selected is bytes-from-index. Input the information
305 * about the defect and fill in the defect entry.
307 def.sect = UNKNOWN;
308 ioparam.io_bounds.lower = 0;
309 ioparam.io_bounds.upper = pcyl - 1;
310 def.cyl = input(FIO_INT,
311 "Enter defect's cylinder number", ':',
312 &ioparam, NULL, DATA_INPUT);
313 ioparam.io_bounds.upper = nhead - 1;
314 def.head = input(FIO_INT, "Enter defect's head number",
315 ':', &ioparam, NULL, DATA_INPUT);
316 ioparam.io_bounds.upper = cur_dtype->dtype_bpt - 1;
317 def.bfi = input(FIO_INT, "Enter defect's bytes-from-index",
318 ':', &ioparam, NULL, DATA_INPUT);
319 ioparam.io_bounds.lower = -1;
320 ioparam.io_bounds.upper = (cur_dtype->dtype_bpt - def.bfi) * 8;
321 if (ioparam.io_bounds.upper >= 32 * 1024)
322 ioparam.io_bounds.upper = 32 * 1024 - 1;
324 * Note: a length of -1 means the length is not known. We
325 * make this the default value.
327 deflt = -1;
328 def.nbits = input(FIO_INT, "Enter defect's length (in bits)",
329 ':', &ioparam, &deflt, DATA_INPUT);
332 * Calculate where in the defect list this defect belongs
333 * and print it out.
335 index = sort_defect(&def, &work_list);
336 fmt_print(DEF_PRINTHEADER);
337 pr_defect(&def, index);
340 * Lock out interrupts so lists don't get mangled.
341 * Also, mark the working list dirty since we are modifying it.
343 enter_critical();
344 work_list.flags |= LIST_DIRTY;
346 * If the list is null, create it with zero length. This is
347 * necessary because the routines to add a defect to the list
348 * assume the list is initialized.
350 if (work_list.list == NULL) {
351 work_list.header.magicno = (uint_t)DEFECT_MAGIC;
352 work_list.header.count = 0;
353 work_list.list = (struct defect_entry *)zalloc(
354 deflist_size(cur_blksz, 0) * cur_blksz);
357 * Add the defect to the working list.
359 add_def(&def, &work_list, index);
360 fmt_print("defect number %d added.\n\n", index + 1);
361 exit_critical();
363 * Loop back for the next defect.
365 goto loop;
366 /*NOTREACHED*/
370 * This routine implements the 'delete' command. It allows the user
371 * to manually delete a defect from the working list.
374 d_delete()
376 int i, count, num;
377 u_ioparam_t ioparam;
379 assert(!EMBEDDED_SCSI);
382 * If the working list is null or zero length, there's nothing
383 * to delete.
385 count = work_list.header.count;
386 if (work_list.list == NULL || count == 0) {
387 err_print("No defects to delete.\n");
388 return (-1);
391 * Ask the user which defect should be deleted. Bounds are off by
392 * one because user sees a one-relative list.
394 ioparam.io_bounds.lower = 1;
395 ioparam.io_bounds.upper = count;
396 num = input(FIO_INT, "Specify defect to be deleted (enter its number)",
397 ':', &ioparam, NULL, DATA_INPUT);
400 * The user thinks it's one relative but it's not really.
402 --num;
404 * Print the defect selected and ask the user for confirmation.
406 fmt_print(DEF_PRINTHEADER);
407 pr_defect(work_list.list + num, num);
409 * Lock out interrupts so the lists don't get mangled.
411 enter_critical();
413 * Move down all the defects beyond the one deleted so the defect
414 * list is still fully populated.
416 for (i = num; i < count - 1; i++)
417 *(work_list.list + i) = *(work_list.list + i + 1);
419 * If the size of the list in sectors has changed, reallocate
420 * the list to shrink it appropriately.
422 if (deflist_size(cur_blksz, count - 1) <
423 deflist_size(cur_blksz, count))
424 work_list.list = (struct defect_entry *)rezalloc(
425 (void *)work_list.list,
426 deflist_size(cur_blksz, count - 1) * cur_blksz);
428 * Decrement the defect count.
430 work_list.header.count--;
432 * Recalculate the list's checksum.
434 (void) checkdefsum(&work_list, CK_MAKESUM);
436 * Mark the working list dirty since we modified it.
438 work_list.flags |= LIST_DIRTY;
439 fmt_print("defect number %d deleted.\n\n", ++num);
440 exit_critical();
441 return (0);
445 * This routine implements the 'print' command. It prints the working
446 * defect list out in human-readable format.
449 d_print()
451 int i, nomore = 0;
452 int c, one_line = 0;
453 int tty_lines = get_tty_lines();
456 * If the working list is null, there's nothing to print.
458 if (work_list.list == NULL) {
459 if (EMBEDDED_SCSI)
460 err_print(
461 "No list defined,extract primary or grown or both defects list first.\n");
462 else
463 err_print("No working list defined.\n");
464 return (-1);
467 * If we're running from a file, don't use the paging scheme.
468 * If we are running interactive, turn off echoing.
470 if (option_f || (!isatty(0)) || (!isatty(1)))
471 nomore++;
472 else {
473 enter_critical();
474 echo_off();
475 charmode_on();
476 exit_critical();
478 /* Print out the banner. */
479 if (work_list.header.count != 0)
480 fmt_print(DEF_PRINTHEADER);
483 * Loop through the each defect in the working list.
485 for (i = 0; i < work_list.header.count; i++) {
487 * If we are paging and hit the end of a page, wait for
488 * the user to hit either space-bar, "q", or return
489 * before going on.
491 if (one_line ||
492 (!nomore && ((i + 1) % (tty_lines - 1) == 0))) {
494 * Get the next character.
496 fmt_print("- hit space for more - ");
497 c = getchar();
498 fmt_print("\015");
499 one_line = 0;
500 /* Handle display one line command (return key) */
501 if (c == '\012') {
502 one_line++;
504 /* Handle Quit command */
505 if (c == 'q') {
506 fmt_print(" \015");
507 goto PRINT_EXIT;
509 /* Handle ^D */
510 if (c == '\004')
511 fullabort();
514 * Print the defect.
516 pr_defect(work_list.list + i, i);
518 fmt_print("total of %d defects.\n\n", i);
520 * If we were doing paging, turn echoing back on.
522 PRINT_EXIT:
523 if (!nomore) {
524 enter_critical();
525 charmode_off();
526 echo_on();
527 exit_critical();
529 return (0);
533 * This routine implements the 'dump' command. It writes the working
534 * defect list to a file.
537 d_dump()
539 int i, status = 0;
540 char *str;
541 FILE *fptr;
542 struct defect_entry *dptr;
545 * If the working list is null, there's nothing to do.
547 if (work_list.list == NULL) {
548 if (EMBEDDED_SCSI)
549 err_print(
550 "No list defined,extract primary or grown or both defects list first.\n");
551 else
552 err_print("No working list defined.\n");
553 return (-1);
556 * Ask the user for the name of the defect file. Note that the
557 * input will be in malloc'd space since we are inputting
558 * type OSTR.
560 str = (char *)(uintptr_t)input(FIO_OSTR, "Enter name of defect file",
561 ':', (u_ioparam_t *)NULL, NULL, DATA_INPUT);
563 * Lock out interrupts so the file doesn't get half written.
565 enter_critical();
567 * Open the file for writing.
569 if ((fptr = fopen(str, "w+")) == NULL) {
570 err_print("unable to open defect file.\n");
571 status = -1;
572 goto out;
575 * Print a header containing the magic number, count, and checksum.
577 (void) fprintf(fptr, "0x%08x%8d 0x%08x\n",
578 work_list.header.magicno,
579 work_list.header.count, work_list.header.cksum);
581 * Loop through each defect in the working list. Write the
582 * defect info to the defect file.
584 for (i = 0; i < work_list.header.count; i++) {
585 dptr = work_list.list + i;
586 (void) fprintf(fptr, "%4d%8d%7d%8d%8d%8d\n",
587 i+1, dptr->cyl, dptr->head,
588 dptr->bfi, dptr->nbits, dptr->sect);
590 fmt_print("defect file updated, total of %d defects.\n", i);
592 * Close the defect file.
594 (void) fclose(fptr);
595 out:
597 * Destroy the string used for the file name.
599 destroy_data(str);
600 exit_critical();
601 fmt_print("\n");
602 return (status);
606 * This routine implements the 'load' command. It reads the working
607 * list in from a file.
610 d_load()
612 int i, items, status = 0, count, cksum;
613 uint_t magicno;
614 char *str;
615 TOKEN filename;
616 FILE *fptr;
617 struct defect_entry *dptr;
619 assert(!EMBEDDED_SCSI);
622 * Ask the user for the name of the defect file. Note that the
623 * input will be malloc'd space since we inputted type OSTR.
625 str = (char *)(uintptr_t)input(FIO_OSTR, "Enter name of defect file",
626 ':', (u_ioparam_t *)NULL, NULL, DATA_INPUT);
628 * Copy the file name into local space then destroy the string
629 * it came in. This is simply a precaution against later having
630 * to remember to destroy this space.
632 enter_critical();
633 (void) strcpy(filename, str);
634 destroy_data(str);
635 exit_critical();
637 * See if the defect file is accessable. If not, we can't load
638 * from it. We do this here just so we can get out before asking
639 * the user for confirmation.
641 status = access(filename, 4);
642 if (status) {
643 err_print("defect file not accessable.\n");
644 return (-1);
647 * Make sure the user is serious.
649 if (check("ready to update working list, continue"))
650 return (-1);
652 * Lock out interrupts so the list doesn't get half loaded.
654 enter_critical();
656 * Open the defect file.
658 if ((fptr = fopen(filename, "r")) == NULL) {
659 err_print("unable to open defect file.\n");
660 exit_critical();
661 return (-1);
664 * Scan in the header.
666 items = fscanf(fptr, "0x%x%d 0x%x\n", &magicno,
667 &count, (uint_t *)&cksum);
669 * If the header is wrong, this isn't a good defect file.
671 if (items != 3 || count < 0 ||
672 (magicno != (uint_t)DEFECT_MAGIC &&
673 magicno != (uint_t)NO_CHECKSUM)) {
674 err_print("Defect file is corrupted.\n");
675 status = -1;
676 goto out;
679 * Kill off any old defects in the working list.
681 kill_deflist(&work_list);
683 * Load the working list header with the header info.
685 if (magicno == NO_CHECKSUM)
686 work_list.header.magicno = (uint_t)DEFECT_MAGIC;
687 else
688 work_list.header.magicno = magicno;
689 work_list.header.count = count;
690 work_list.header.cksum = cksum;
692 * Allocate space for the new list.
694 work_list.list = (struct defect_entry *)zalloc(
695 deflist_size(cur_blksz, count) * cur_blksz);
697 * Mark the working list dirty since we are modifying it.
699 work_list.flags |= LIST_DIRTY;
701 * Loop through each defect in the defect file.
703 for (i = 0; i < count; i++) {
704 dptr = work_list.list + i;
706 * Scan the info into the defect entry.
708 items = fscanf(fptr, "%*d%hd%hd%d%hd%hd\n", &dptr->cyl,
709 &dptr->head, &dptr->bfi, &dptr->nbits, &dptr->sect);
711 * If it didn't scan right, give up.
713 if (items != 5)
714 goto bad;
717 * Check to be sure the checksum from the defect file was correct
718 * unless there wasn't supposed to be a checksum.
719 * If there was supposed to be a valid checksum and there isn't
720 * then give up.
722 if (magicno != NO_CHECKSUM && checkdefsum(&work_list, CK_CHECKSUM))
723 goto bad;
724 fmt_print("working list updated, total of %d defects.\n", i);
725 goto out;
727 bad:
729 * Some kind of error occurred. Kill off the working list and
730 * mark the status bad.
732 err_print("Defect file is corrupted, working list set to NULL.\n");
733 kill_deflist(&work_list);
734 status = -1;
735 out:
737 * Close the defect file.
739 (void) fclose(fptr);
740 exit_critical();
741 fmt_print("\n");
742 return (status);
746 * This routine implements the 'commit' command. It causes the current
747 * defect list to be set equal to the working defect list. It is the only
748 * way that changes made to the working list can actually take effect in
749 * the next format.
752 d_commit()
755 * If the working list wasn't modified, no commit is necessary.
757 if (work_list.list != NULL && !(work_list.flags & LIST_DIRTY)) {
758 err_print("working list was not modified.\n");
759 return (0);
763 * Make sure the user is serious.
765 if (check("Ready to update Current Defect List, continue"))
766 return (-1);
767 return (do_commit());
771 do_commit()
773 int status;
775 if ((status = commit_list()) == 0) {
777 * Remind the user to format the drive, since changing
778 * the list does nothing unless a format is performed.
780 fmt_print(\
781 "Disk must be reformatted for changes to take effect.\n\n");
783 return (status);
787 static int
788 commit_list()
790 int i;
793 * Lock out interrupts so the list doesn't get half copied.
795 enter_critical();
797 * Kill off any current defect list.
799 kill_deflist(&cur_list);
801 * If the working list is null, initialize it to zero length.
802 * This is so the user can do a commit on a null list and get
803 * a zero length list. Otherwise there would be no way to get
804 * a zero length list conveniently.
806 if (work_list.list == NULL) {
807 work_list.header.magicno = (uint_t)DEFECT_MAGIC;
808 work_list.header.count = 0;
809 work_list.list = (struct defect_entry *)zalloc(
810 deflist_size(cur_blksz, 0) * cur_blksz);
813 * Copy the working list into the current list.
815 cur_list.header = work_list.header;
816 cur_list.list = (struct defect_entry *)zalloc(
817 deflist_size(cur_blksz, cur_list.header.count) * cur_blksz);
818 for (i = 0; i < cur_list.header.count; i++)
819 *(cur_list.list + i) = *(work_list.list + i);
821 * Mark the working list clean, since it is now the same as the
822 * current list. Note we do not mark the current list dirty,
823 * even though it has been changed. This is because it does
824 * not reflect the state of disk, so we don't want it written
825 * out until a format has been done. The format will mark it
826 * dirty and write it out.
828 work_list.flags &= ~(LIST_DIRTY|LIST_RELOAD);
829 cur_list.flags = work_list.flags;
830 if (EMBEDDED_SCSI)
831 fmt_print("Defect List has a total of %d defects.\n",
832 cur_list.header.count);
833 else
834 fmt_print("Current Defect List updated, total of %d defects.\n",
835 cur_list.header.count);
836 exit_critical();
837 return (0);
842 * This routine implements the 'create' command. It creates the
843 * manufacturer's defect on the current disk from the defect list
846 d_create()
848 int status;
850 assert(!EMBEDDED_SCSI);
853 * If the controller does not support the extraction, we're out
854 * of luck.
856 if (cur_ops->op_create == NULL) {
857 err_print("Controller does not support creating ");
858 err_print("manufacturer's defect list.\n");
859 return (-1);
862 * Make sure the user is serious. Note, for SCSI disks
863 * since this is instantaneous, we will just do it and
864 * not ask for confirmation.
866 if (! (cur_ctype->ctype_flags & CF_SCSI) &&
867 check(
868 "Ready to create the manufacturers defect information on the disk.\n\
869 This cannot be interrupted and may take a long while.\n\
870 IT WILL DESTROY ALL OF THE DATA ON THE DISK! Continue"))
871 return (-1);
873 * Lock out interrupts so we don't get half the list.
875 enter_critical();
876 fmt_print("Creating manufacturer's defect list...");
878 * Do the Creation
880 status = (*cur_ops->op_create)(&work_list);
881 if (status) {
882 fmt_print("Creation failed.\n\n");
883 } else {
884 fmt_print("Creation complete.\n");
886 exit_critical();
888 * Return status.
890 return (status);
895 * Extract primary defect list - SCSI only
898 d_primary()
900 int status;
902 assert(EMBEDDED_SCSI);
905 * Lock out interrupts so we don't get half the list and
906 * Kill off the working list.
908 enter_critical();
909 kill_deflist(&work_list);
910 fmt_print("Extracting primary defect list...");
913 * Do the extraction.
915 status = scsi_ex_man(&work_list);
916 if (status) {
917 fmt_print("Extraction failed.\n\n");
918 } else {
919 fmt_print("Extraction complete.\n");
921 * Mark the working list dirty since we modified it.
922 * Automatically commit it, for SCSI only.
924 work_list.flags |= LIST_DIRTY;
925 status = commit_list();
926 fmt_print("\n");
928 exit_critical();
931 * Return status.
933 return (status);
938 * Extract grown defects list - SCSI only
941 d_grown()
943 int status;
945 assert(EMBEDDED_SCSI);
948 * Lock out interrupts so we don't get half the list and
949 * Kill off the working list.
951 enter_critical();
952 kill_deflist(&work_list);
953 fmt_print("Extracting grown defects list...");
956 * Do the extraction.
958 status = scsi_ex_grown(&work_list);
959 if (status) {
960 fmt_print("Extraction failed.\n\n");
961 } else {
962 fmt_print("Extraction complete.\n");
964 * Mark the working list dirty since we modified it.
965 * Automatically commit it, for SCSI only.
967 work_list.flags |= LIST_DIRTY;
968 status = commit_list();
969 fmt_print("\n");
971 exit_critical();
974 * Return status.
976 return (status);
981 * Extract both primary and grown defects list - SCSI only
984 d_both()
986 int status;
988 assert(EMBEDDED_SCSI);
991 * Lock out interrupts so we don't get half the list and
992 * Kill off the working list.
994 enter_critical();
995 kill_deflist(&work_list);
996 fmt_print("Extracting both primary and grown defects lists...");
999 * Do the extraction.
1001 status = scsi_ex_cur(&work_list);
1002 if (status) {
1003 fmt_print("Extraction failed.\n\n");
1004 } else {
1005 fmt_print("Extraction complete.\n");
1007 * Mark the working list dirty since we modified it.
1008 * Automatically commit it, for SCSI only.
1010 work_list.flags |= LIST_DIRTY;
1011 status = commit_list();
1012 fmt_print("\n");
1014 exit_critical();
1017 * Return status.
1019 return (status);