MCPcopy Create free account
hub / github.com/F-Stack/f-stack / draid_verify

Function draid_verify

freebsd/contrib/openzfs/tests/zfs-tests/cmd/draid/draid.c:926–1121  ·  view source on GitHub ↗

* Verify each map in the file by generating its in-memory permutation array * and comfirming its checksum is correct. */

Source from the content-addressed store, hash-verified

924 * and comfirming its checksum is correct.
925 */
926static int
927draid_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];

Callers 1

mainFunction · 0.85

Calls 15

draid_usageFunction · 0.85
mallocFunction · 0.85
bzeroFunction · 0.85
strncpyFunction · 0.85
snprintfFunction · 0.85
alloc_fixed_mapFunction · 0.85
read_map_keyFunction · 0.85
free_mapFunction · 0.85
fnvlist_lookup_uint64Function · 0.85
eval_declusterFunction · 0.85
getoptFunction · 0.50

Tested by

no test coverage detected