diff --git a/tools/.gitignore b/tools/.gitignore index 0c44728..1bb6708 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,3 +1,4 @@ *.o /memdumpb +/blkdumpb /uploadb diff --git a/tools/Makefile b/tools/Makefile index 580ea8b..0d05b18 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,8 +1,10 @@ MEMDUMP_TGT = memdumpb MEMDUMP_SRC = memdump.c +BLKDUMP_TGT = blkdumpb +BLKDUMP_SRC = blkdump.c UPLOAD_TGT = uploadb UPLOAD_SRC = upload.c -TARGETS = $(MEMDUMP_TGT) $(UPLOAD_TGT) +TARGETS = $(MEMDUMP_TGT) $(BLKDUMP_TGT) $(UPLOAD_TGT) OBJS = common.o all: $(TARGETS) @@ -14,6 +16,9 @@ all: $(TARGETS) $(MEMDUMP_TGT): $(MEMDUMP_SRC) $(OBJS) $(CC) $(CFLAGS) $(MEMDUMP_SRC) $(OBJS) -o $@ +$(BLKDUMP_TGT): $(BLKDUMP_SRC) $(OBJS) + $(CC) $(CFLAGS) $(BLKDUMP_SRC) $(OBJS) -o $@ + $(UPLOAD_TGT): $(UPLOAD_SRC) $(OBJS) $(CC) $(CFLAGS) $(UPLOAD_SRC) $(OBJS) -o $@ diff --git a/tools/blkdump.c b/tools/blkdump.c new file mode 100644 index 0000000..d0c8803 --- /dev/null +++ b/tools/blkdump.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +#include "common.h" + +/* Read specified number of bytes in active blkdev at active offset. + */ + +int main(int argc, char **argv) +{ + if (argc != 3) { + fprintf(stderr, "Usage: ./memdump device bytecount\n"); + return 1; + } + unsigned int bytecount = strtol(argv[2], NULL, 16); + if (!bytecount) { + // nothing to spit + return 0; + } + + int fd = open(argv[1], O_RDWR|O_NOCTTY); + char s[3]; + for (int i=0; i