EXPORTED void partlist_initialize(partlist_t *part_list, cb_part_filldata filldata, const char *key_prefix, const char *key_value, const char *excluded, partmode_t mode, int soft_usage_limit, int reinit) { partlist_conf_t part_list_conf; char *excluded_parts = NULL; srand(time(NULL)); memset(&part_list_conf, 0, sizeof(part_list_conf)); memset(part_list, 0, sizeof(partlist_t)); part_list->mode = mode; part_list->filldata = (filldata ? filldata : partition_filldata); part_list->size = 0; part_list->soft_usage_limit = soft_usage_limit; part_list->reinit = reinit; part_list_conf.part_list = part_list; part_list_conf.key_prefix = key_prefix; if (excluded && (strlen(excluded) > 0)) { char *item = NULL; char *lasts; excluded_parts = xstrdup(excluded); item = strtok_r(excluded_parts, " ,\t", &lasts); while (item) { part_list_conf.excluded_item = (const char **)xrealloc(part_list_conf.excluded_item, (part_list_conf.excluded_count+1) * sizeof(const char *)); part_list_conf.excluded_item[part_list_conf.excluded_count++] = item; item = strtok_r(NULL, " ,\t", &lasts); } } if (key_value) { char *items = xstrdup(key_value); char *item = NULL; char *lasts; item = strtok_r(items, " ,\t", &lasts); while (item) { partlist_fill(item, item, &part_list_conf); item = strtok_r(NULL, " ,\t", &lasts); } FREE(items); } else { config_foreachoverflowstring(partlist_fill, &part_list_conf); } /* excluded items no more necessary */ FREE(excluded_parts); FREE(part_list_conf.excluded_item); partlist_compute_quota(part_list); }
int main(int argc, char *argv[]) { int opt, code = 0; char *alt_config = NULL; int meta = 0; if ((geteuid()) == 0 && (become_cyrus() != 0)) { fatal("must run as the Cyrus user", EC_USAGE); } while ((opt = getopt(argc, argv, "C:m")) != EOF) { switch (opt) { case 'C': /* alt config file */ alt_config = optarg; break; case 'm': /* check metapartitions */ meta = 1; break; default: usage(); } } cyrus_init(alt_config, "cyr_df", 0); printf("%-12s %12s %12s %12s %3s %s\n", "Partition", "1k-blocks", "Used", "Available", "Use%", "Location"); config_foreachoverflowstring(get_part_stats, &meta); cyrus_done(); exit(code); }