int engine_set(uu_list_t *args) { uu_list_walk_t *walk; string_list_t *slp; if (uu_list_first(args) == NULL) { /* Display current options. */ if (!g_verbose) (void) fputs("no", stdout); (void) puts("verbose"); return (0); } walk = uu_list_walk_start(args, UU_DEFAULT); if (walk == NULL) uu_die(gettext("Couldn't read arguments")); /* Use getopt? */ for (slp = uu_list_walk_next(walk); slp != NULL; slp = uu_list_walk_next(walk)) { if (slp->str[0] == '-') { char *op; for (op = &slp->str[1]; *op != '\0'; ++op) { switch (*op) { case 'v': g_verbose = 1; break; case 'V': g_verbose = 0; break; default: warn(gettext("Unknown option -%c.\n"), *op); } } } else { warn(gettext("No non-flag arguments defined.\n")); } } return (0); }
static void zfs_purge_cases(fmd_hdl_t *hdl) { zfs_case_t *zcp; uu_list_walk_t *walk; libzfs_handle_t *zhdl = fmd_hdl_getspecific(hdl); /* * There is no way to open a pool by GUID, or lookup a vdev by GUID. No * matter what we do, we're going to have to stomach an O(vdevs * cases) * algorithm. In reality, both quantities are likely so small that * neither will matter. Given that iterating over pools is more * expensive than iterating over the in-memory case list, we opt for a * 'present' flag in each case that starts off cleared. We then iterate * over all pools, marking those that are still present, and removing * those that aren't found. * * Note that we could also construct an FMRI and rely on * fmd_nvl_fmri_present(), but this would end up doing the same search. */ /* * Mark the cases as not present. */ for (zcp = uu_list_first(zfs_cases); zcp != NULL; zcp = uu_list_next(zfs_cases, zcp)) zcp->zc_present = B_FALSE; /* * Iterate over all pools and mark the pools and vdevs found. If this * fails (most probably because we're out of memory), then don't close * any of the cases and we cannot be sure they are accurate. */ if (zpool_iter(zhdl, zfs_mark_pool, NULL) != 0) return; /* * Remove those cases which were not found. */ walk = uu_list_walk_start(zfs_cases, UU_WALK_ROBUST); while ((zcp = uu_list_walk_next(walk)) != NULL) { if (!zcp->zc_present) fmd_case_close(hdl, zcp->zc_case); } uu_list_walk_end(walk); }