# HG changeset patch # User Mychaela Falconia # Date 1613539913 0 # Node ID 54cebab70c1923979ec9c7a5c37b429f4ab083cf # Parent b0982c0cf54d036eabb8762fdc6582d66c6aacf8 fc-simtool restore-file: add support for cyclic files diff -r b0982c0cf54d -r 54cebab70c19 simtool/restorebin.c --- a/simtool/restorebin.c Wed Feb 17 05:21:34 2021 +0000 +++ b/simtool/restorebin.c Wed Feb 17 05:31:53 2021 +0000 @@ -49,6 +49,24 @@ return(0); } +static +restore_cyclic(data) + u_char *data; +{ + unsigned count; + u_char *dp; + int rc; + + dp = data + curfile_total_size; + for (count = 0; count < curfile_record_count; count++) { + dp -= curfile_record_len; + rc = update_rec_op(0, 0x03, dp, curfile_record_len); + if (rc < 0) + return(rc); + } + return(0); +} + cmd_restore_file(argc, argv) char **argv; { @@ -112,8 +130,9 @@ rc = restore_records(databuf); break; case 0x03: - fprintf(stderr, "error: cyclic files are not supported\n"); - rc = -1; + /* cyclic */ + rc = restore_cyclic(databuf); + break; } free(databuf); return(rc);