* Translate internal fail_point structure into human-readable text. */
| 662 | * Translate internal fail_point structure into human-readable text. |
| 663 | */ |
| 664 | static void |
| 665 | fail_point_get(struct fail_point *fp, struct sbuf *sb, |
| 666 | bool verbose) |
| 667 | { |
| 668 | struct fail_point_entry *ent; |
| 669 | struct fail_point_setting *fp_setting; |
| 670 | struct fail_point_entry *fp_entry_cpy; |
| 671 | int cnt_sleeping; |
| 672 | int idx; |
| 673 | int printed_entry_count; |
| 674 | |
| 675 | cnt_sleeping = 0; |
| 676 | idx = 0; |
| 677 | printed_entry_count = 0; |
| 678 | |
| 679 | fp_entry_cpy = fp_malloc(sizeof(struct fail_point_entry) * |
| 680 | (FP_MAX_ENTRY_COUNT + 1), M_WAITOK); |
| 681 | |
| 682 | fp_setting = fail_point_setting_get_ref(fp); |
| 683 | |
| 684 | if (fp_setting != NULL) { |
| 685 | TAILQ_FOREACH(ent, &fp_setting->fp_entry_queue, fe_entries) { |
| 686 | if (ent->fe_stale) |
| 687 | continue; |
| 688 | |
| 689 | KASSERT(printed_entry_count < FP_MAX_ENTRY_COUNT, |
| 690 | ("FP entry list larger than allowed")); |
| 691 | |
| 692 | fp_entry_cpy[printed_entry_count] = *ent; |
| 693 | ++printed_entry_count; |
| 694 | } |
| 695 | } |
| 696 | fail_point_setting_release_ref(fp); |
| 697 | |
| 698 | /* This is our equivalent of a NULL terminator */ |
| 699 | fp_entry_cpy[printed_entry_count].fe_type = FAIL_POINT_INVALID; |
| 700 | |
| 701 | while (idx < printed_entry_count) { |
| 702 | ent = &fp_entry_cpy[idx]; |
| 703 | ++idx; |
| 704 | if (ent->fe_prob < PROB_MAX) { |
| 705 | int decimal = ent->fe_prob % (PROB_MAX / 100); |
| 706 | int units = ent->fe_prob / (PROB_MAX / 100); |
| 707 | sbuf_printf(sb, "%d", units); |
| 708 | if (decimal) { |
| 709 | int digits = PROB_DIGITS - 2; |
| 710 | while (!(decimal % 10)) { |
| 711 | digits--; |
| 712 | decimal /= 10; |
| 713 | } |
| 714 | sbuf_printf(sb, ".%0*d", digits, decimal); |
| 715 | } |
| 716 | sbuf_printf(sb, "%%"); |
| 717 | } |
| 718 | if (ent->fe_count >= 0) |
| 719 | sbuf_printf(sb, "%d*", ent->fe_count); |
| 720 | sbuf_printf(sb, "%s", fail_type_strings[ent->fe_type].name); |
| 721 | if (ent->fe_arg) |
no test coverage detected