diff options
| author | Keith Packard <keithp@keithp.com> | 2016-11-11 23:34:54 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:50 -0800 | 
| commit | 33aeffc123af1f9063969acf585f1caac885ced4 (patch) | |
| tree | bf4f87c83c46ce815070933b947ba27fa65724c8 /src/test/ao_lisp_test.c | |
| parent | 8f2d60b4c029bffaa559bd1f31f5b15230dfa674 (diff) | |
altos/lisp: Append a CRC to the saved image to validate on restore
The CRC is actually of the ROM bits, so we can tell if the restored
image relates to the currently running code.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/test/ao_lisp_test.c')
| -rw-r--r-- | src/test/ao_lisp_test.c | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/src/test/ao_lisp_test.c b/src/test/ao_lisp_test.c index 41dae07a..648d1abe 100644 --- a/src/test/ao_lisp_test.c +++ b/src/test/ao_lisp_test.c @@ -35,6 +35,24 @@ ao_lisp_os_save(void)  }  int +ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset) +{ +	FILE	*restore = fopen(save_file, "r"); +	size_t	ret; + +	if (!restore) { +		perror(save_file); +		return 0; +	} +	fseek(restore, offset, SEEK_SET); +	ret = fread(save, sizeof (struct ao_lisp_os_save), 1, restore); +	fclose(restore); +	if (ret != 1) +		return 0; +	return 1; +} + +int  ao_lisp_os_restore(void)  {  	FILE	*restore = fopen(save_file, "r"); | 
