memzap

replay memory writes
git clone git://git.2f30.org/memzap.git
Log | Files | Refs | README | LICENSE

commit 5f721ec36e692243453e5d728aeb8f0710bfcfc2
parent c9552cead65bebac9467eb348ac95ba573624edf
Author: sin <sin@2f30.org>
Date:   Sun Mar  3 16:01:45 +0000

mdiffdump: Initial commit

Diffstat:
mdiffdump.c | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)
diff --git a/mdiffdump.c b/mdiffdump.c @@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ + +#include "proto.h" + +int +main(int argc, char *argv[]) +{ + int fd; + struct mdiff_hdr *hdr; + struct mdiff_region *mdiff; + uint32_t i, j; + char *p; + + if (argc != 2) { + fprintf(stderr, "usage: %s <mdiff-file>\n", *argv); + return 1; + } + + fd = open_mdiff(argv[1]); + hdr = parse_mdiff_hdr(fd); + if (!hdr) + errx(1, "%s: failed to parse mdiff", argv[1]); + printf("nregions: %lu\n", (unsigned long)hdr->nregions); + printf("blksize: %lu\n", (unsigned long)hdr->blksize); + for (i = 0; i < hdr->nregions; i++) { + mdiff = mdiff_read_diff(fd, hdr, i); + printf("offset: %lu\n", (unsigned long)mdiff->offset); + printf("len: %lu\n", (unsigned long)mdiff->len); + printf("buf: "); + p = mdiff->buf; + for (j = 0; j < mdiff->len; j++) + putchar(p[j]); + putchar('\n'); + } + close_mdiff(fd); + return 0; +}