int disksim_syncset_loadparams(struct lp_block *b) { int c; unparse_block(b, outputfile); for(c = 0; c < b->params_len; c++) { if(!b->params[c]) continue; if(PTYPE(b->params[c]) != S) continue; if(strcmp(b->params[c]->name, "type")) continue; else { if(!strcmp(SVAL(b->params[c]), "simpledisk")) { fprintf(stderr, "*** warning: no simpledisk syncsets\n"); /* simpledisk_load_syncsets(b); */ } else if(!strcmp(SVAL(b->params[c]), "disk")) { return disk_load_syncsets(b); } else if(!strcmp(SVAL(b->params[c]), "mems")) { fprintf(stderr, "*** warning: no mems syncsets\n"); /* mems_load_syncsets(b); */ } else { } } } return 1; }
void unparse_value(struct lp_value *v, FILE *outfile) { int c; switch(v->t) { case I: fprintf(outfile, "%d", v->v.i); break; case D: if(v->v.d == 0.0) { fprintf(outfile, "0.0"); } else { fprintf(outfile, "%f", v->v.d); } break; case S: fprintf(outfile, "%s", v->v.s); break; case LIST: unparse_list(v->v.l, outfile); break; case TOPOSPEC: for(c = 0; c < v->v.t.len; c++) unparse_topospec(&v->v.t.l[c], outfile); break; default: case BLOCK: unparse_block(v->v.b, outfile); break; } }
void unparse_tlt(struct lp_tlt *tlt, FILE *outfile, char *infile) { if(tlt->source_file && infile) { if(strcmp(tlt->source_file, infile)) { unparse_source(tlt->source_file, outfile); return; } } switch(tlt->what) { case TLT_BLOCK: unparse_block(tlt->it.block, outfile); break; case TLT_TOPO: unparse_tl_topospec(tlt->it.topo, outfile); break; case TLT_INST: unparse_inst(tlt->it.inst, outfile); break; default: ddbg_assert(0); break; }; }
int main(int argc, char **argv) { int c; static struct option opts[] = { { "parv", 1, 0, 0 }, { "outv", 1, 0, 0 }, { "model", 1, 0, 0 }, { "mode", 1, 0, 0 }, { "trace", 1, 0, 0 }, {0,0,0,0} }; enum optt { PARV = 0, OUTV = 1, MODEL = 2, MODE = 3, TRACE = 4 }; struct dm_disk_if *d; struct dm_layout_g4 *l; struct trace *t; struct dsstuff *ds = calloc(1, sizeof(*ds)); struct lp_block *unm; setlinebuf(stdout); FILE *outfile = NULL; int optind; char *parv = 0; char *outv = 0; char *model = 0; char *trace = 0; while((c = getopt_long(argc, argv, "q", opts, &optind)) != -1) { switch(c) { case -1: break; case 0: switch(optind) { case PARV: parv = strdup(optarg); break; case OUTV: outv = strdup(optarg); break; case MODEL: model = strdup(optarg); break; case MODE: if(!strcmp(optarg, "calib")) { mode = CALIB; } else if(!strcmp(optarg, "gentrace")) { mode = GENTRACE; } else { fprintf(stderr, "*** bad mode %s\n", optarg); exit(1); } break; case TRACE: trace = strdup(optarg); break; default: ddbg_assert(0); break; } break; default: ddbg_assert(0); break; } } t = setup_trace(trace); if(mode == CALIB) { outfile = fopen(model, "w"); ddbg_assert(outfile); } ds->iface = disksim_interface_initialize(parv, outv, cb, schedule_callback, deschedule_callback, ds, 18, // argc nocache_over); d = disksim_getdiskmodel(ds->iface, 0); l = (struct dm_layout_g4 *)d->layout; do_idx(d, 0, l->root, l, ds, t, 0); extern struct lp_block* marshal_layout_g4(struct dm_layout_g4 *); if(mode == CALIB) { unm = marshal_layout_g4(l); unparse_block(unm, outfile); fclose(outfile); } free(ds); fclose(t->fp); free(t); return 0; }