* Verify each map in the file by generating its in-memory permutation array * and comfirming its checksum is correct. */
| 924 | * and comfirming its checksum is correct. |
| 925 | */ |
| 926 | static int |
| 927 | draid_verify(int argc, char *argv[]) |
| 928 | { |
| 929 | char filename[MAXPATHLEN]; |
| 930 | int n = 0, c, error, verbose = 1; |
| 931 | int check_ratios = 0; |
| 932 | |
| 933 | while ((c = getopt(argc, argv, ":rv")) != -1) { |
| 934 | switch (c) { |
| 935 | case 'r': |
| 936 | check_ratios++; |
| 937 | break; |
| 938 | case 'v': |
| 939 | verbose++; |
| 940 | break; |
| 941 | case ':': |
| 942 | (void) fprintf(stderr, |
| 943 | "missing argument for '%c' option\n", optopt); |
| 944 | draid_usage(); |
| 945 | break; |
| 946 | case '?': |
| 947 | (void) fprintf(stderr, "invalid option '%c'\n", |
| 948 | optopt); |
| 949 | draid_usage(); |
| 950 | break; |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | if (argc > optind) { |
| 955 | char *abspath = malloc(MAXPATHLEN); |
| 956 | if (abspath == NULL) |
| 957 | return (ENOMEM); |
| 958 | |
| 959 | bzero(filename, MAXPATHLEN); |
| 960 | if (realpath(argv[optind], abspath) != NULL) |
| 961 | strncpy(filename, abspath, MAXPATHLEN - 1); |
| 962 | else |
| 963 | strncpy(filename, argv[optind], MAXPATHLEN - 1); |
| 964 | |
| 965 | free(abspath); |
| 966 | } else { |
| 967 | (void) fprintf(stderr, "A FILE must be specified.\n"); |
| 968 | return (1); |
| 969 | } |
| 970 | |
| 971 | printf("Verifying permutation maps: '%s'\n", filename); |
| 972 | |
| 973 | /* |
| 974 | * Lookup hardcoded permutation map for each valid number of children |
| 975 | * and verify a generated map has the correct checksum. Then compare |
| 976 | * the generated map values with the nvlist map values read from the |
| 977 | * reference file to cross-check the permutation. |
| 978 | */ |
| 979 | for (uint64_t children = VDEV_DRAID_MIN_CHILDREN; |
| 980 | children <= VDEV_DRAID_MAX_CHILDREN; |
| 981 | children++) { |
| 982 | draid_map_t *map; |
| 983 | char key[8]; |
no test coverage detected