From: oetiker Date: Thu, 25 Aug 2005 20:43:04 +0000 (+0000) Subject: when resize converts a v1 rrd to v3 it should also change the version number in the... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f696261a1a2cb434eac70b7c3e5b9f4de7378246;p=rrdtool-all.git when resize converts a v1 rrd to v3 it should also change the version number in the head ... git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@675 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_resize.c b/program/src/rrd_resize.c index 4613a878..11d1ca88 100644 --- a/program/src/rrd_resize.c +++ b/program/src/rrd_resize.c @@ -11,15 +11,16 @@ int rrd_resize(int argc, char **argv) { - char *infilename,outfilename[11]="resize.rrd"; - FILE *infile,*outfile; - rrd_t rrdold,rrdnew; - rrd_value_t buffer; - unsigned long l,rra; - long modify; - unsigned long target_rra; - int grow=0,shrink=0; - char *endptr; + char *infilename,outfilename[11]="resize.rrd"; + FILE *infile,*outfile; + rrd_t rrdold,rrdnew; + rrd_value_t buffer; + int version; + unsigned long l,rra; + long modify; + unsigned long target_rra; + int grow=0,shrink=0; + char *endptr; infilename=argv[1]; if (!strcmp(infilename,"resize.rrd")) { @@ -84,6 +85,19 @@ rrd_resize(int argc, char **argv) rrdnew.cdp_prep = rrdold.cdp_prep; rrdnew.rra_ptr = rrdold.rra_ptr; + version = atoi(rrdold.stat_head->version); + switch (version) { + case 3: break; + case 1: rrdold.stat_head->version[3]='3'; + break; + default: { + rrd_set_error("Do not know how to handle RRD version %s",rrdold.stat_head->version); + rrd_free(&rrdold); + fclose(infile); + return(-1); + } + } + if ((outfile=fopen(outfilename,"wb"))==NULL) { rrd_set_error("Can't create '%s'",outfilename); return(-1);