/* * This routine implements the 'config' command. It simply prints out * the values of all the variables controlling surface analysis. It * is meant to complement the 'setup' command by allowing the user to * check the current setup. */ int a_config() { fmt_print(" Analyze entire disk? "); fmt_print(scan_entire ? "yes\n" : "no\n"); if (!scan_entire) { fmt_print(" Starting block number: %llu (", scan_lower); pr_dblock(fmt_print, scan_lower); fmt_print(")\n Ending block number: %llu (", scan_upper); pr_dblock(fmt_print, scan_upper); fmt_print(")\n"); } fmt_print(" Loop continuously? "); fmt_print(scan_loop ? "yes\n" : "no\n"); if (!scan_loop) { fmt_print(" Number of passes: %d\n", scan_passes); } fmt_print(" Repair defective blocks? "); fmt_print(scan_correct ? "yes\n" : "no\n"); fmt_print(" Stop after first error? "); fmt_print(scan_stop ? "yes\n" : "no\n"); fmt_print(" Use random bit patterns? "); fmt_print(scan_random ? "yes\n" : "no\n"); fmt_print(" Number of blocks per transfer: %d (", scan_size); pr_dblock(fmt_print, (daddr_t)scan_size); fmt_print(")\n"); fmt_print(" Verify media after formatting? "); fmt_print(scan_auto ? "yes\n" : "no\n"); fmt_print(" Enable extended messages? "); fmt_print(option_msg ? "yes\n" : "no\n"); fmt_print(" Restore defect list? "); fmt_print(scan_restore_defects ? "yes\n" : "no\n"); fmt_print(" Restore disk label? "); fmt_print(scan_restore_label ? "yes\n" : "no\n"); fmt_print("\n"); return (0); }
/*ARGSUSED*/ void print_partition(struct partition_info *pinfo, int partnum, int want_header) { int i; blkaddr_t nblks; int cyl1; int cyl2; float scaled; int maxcyl2; int ncyl2_digits; char *s; blkaddr_t maxnblks = 0; blkaddr_t len; /* * To align things nicely, we need to know the maximum * width of the number of cylinders field. */ maxcyl2 = 0; for (i = 0; i < NDKMAP; i++) { nblks = (uint_t)pinfo->pinfo_map[i].dkl_nblk; cyl1 = pinfo->pinfo_map[i].dkl_cylno; cyl2 = cyl1 + (nblks / spc()) - 1; if (nblks > 0) { maxcyl2 = max(cyl2, maxcyl2); maxnblks = max(nblks, maxnblks); } } /* * Get the number of digits required */ ncyl2_digits = ndigits(maxcyl2); /* * Print the header, if necessary */ if (want_header) { fmt_print("Part "); fmt_print("Tag Flag "); fmt_print("Cylinders"); nspaces(ncyl2_digits); fmt_print(" Size Blocks\n"); } /* * Print the partition information */ nblks = pinfo->pinfo_map[partnum].dkl_nblk; cyl1 = pinfo->pinfo_map[partnum].dkl_cylno; cyl2 = cyl1 + (nblks / spc()) - 1; fmt_print(" %x ", partnum); /* * Print the partition tag. If invalid, print - */ s = find_string(ptag_choices, (int)pinfo->vtoc.v_part[partnum].p_tag); if (s == (char *)NULL) s = "-"; nspaces(10 - (int)strlen(s)); fmt_print("%s", s); /* * Print the partition flag. If invalid print - */ s = find_string(pflag_choices, (int)pinfo->vtoc.v_part[partnum].p_flag); if (s == (char *)NULL) s = "-"; nspaces(6 - (int)strlen(s)); fmt_print("%s", s); nspaces(2); if (nblks == 0) { fmt_print("%6d ", cyl1); nspaces(ncyl2_digits); fmt_print(" 0 "); } else { fmt_print("%6d - ", cyl1); nspaces(ncyl2_digits - ndigits(cyl2)); fmt_print("%d ", cyl2); scaled = bn2mb(nblks); if (scaled > (float)1024.0 * 1024.0) { fmt_print("%8.2fTB ", scaled/((float)1024.0 * 1024.0)); } else if (scaled > (float)1024.0) { fmt_print("%8.2fGB ", scaled/(float)1024.0); } else { fmt_print("%8.2fMB ", scaled); } } fmt_print("("); pr_dblock(fmt_print, nblks); fmt_print(")"); nspaces(ndigits(maxnblks/spc()) - ndigits(nblks/spc())); /* * Allocates size of the printf format string. * ndigits(ndigits(maxblks)) gives the byte size of * the printf width field for maxnblks. */ len = strlen(" %") + ndigits(ndigits(maxnblks)) + strlen("d\n") + 1; s = zalloc(len); (void) snprintf(s, len, "%s%u%s", " %", ndigits(maxnblks), "u\n"); fmt_print(s, nblks); (void) free(s); }