# HG changeset patch # User Michael Spacefalcon # Date 1390799289 0 # Node ID 872d92404b6a0a18a86c74ce61ee12908db1dd26 # Parent 2dfd9cfa9df6cece55ddc19f6b7fa8b9b7b7ea1e ffstools: pirffs wrapper diff -r 2dfd9cfa9df6 -r 872d92404b6a .hgignore --- a/.hgignore Mon Jan 27 04:14:57 2014 +0000 +++ b/.hgignore Mon Jan 27 05:08:09 2014 +0000 @@ -7,6 +7,7 @@ ^ffstools/tiffs-rd/tiffs$ ^ffstools/tiffs-wrappers/mokoffs$ +^ffstools/tiffs-wrappers/pirffs$ ^gsm-fw/build\.conf$ ^gsm-fw/config\.stamp$ diff -r 2dfd9cfa9df6 -r 872d92404b6a ffstools/tiffs-wrappers/Makefile --- a/ffstools/tiffs-wrappers/Makefile Mon Jan 27 04:14:57 2014 +0000 +++ b/ffstools/tiffs-wrappers/Makefile Mon Jan 27 05:08:09 2014 +0000 @@ -1,15 +1,19 @@ CC= gcc CFLAGS= -O2 -PROGS= mokoffs +PROGS= mokoffs pirffs INSTBIN=/usr/local/bin MOKOFFS_OBJS= installpath.o mokoffs.o +PIRFFS_OBJS= installpath.o pirffs.o all: ${PROGS} mokoffs: ${MOKOFFS_OBJS} ${CC} ${CFLAGS} -o $@ ${MOKOFFS_OBJS} +pirffs: ${PIRFFS_OBJS} + ${CC} ${CFLAGS} -o $@ ${PIRFFS_OBJS} + install: ${PROGS} mkdir -p ${INSTBIN} install -c ${PROGS} ${INSTBIN} diff -r 2dfd9cfa9df6 -r 872d92404b6a ffstools/tiffs-wrappers/pirffs.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ffstools/tiffs-wrappers/pirffs.c Mon Jan 27 05:08:09 2014 +0000 @@ -0,0 +1,78 @@ +/* + * pirffs is a wrapper around tiffs: we pass the user's command along, + * together with any options, but insert the 256x18 FFS organization argument + * automatically. + */ + +#include +#include +#include +#include +#include + +extern char tiffs_prog_pathname[]; + +char *imgfile; +char *aopt, *ropt; +char **passon_argv; +int passon_argc; +int output_argc; +char **output_argv; + +main(argc, argv) + char **argv; +{ + extern int optind; + extern char *optarg; + int c; + char **sp, **dp; + + while ((c = getopt(argc, argv, "+a:r:")) != EOF) + switch (c) { + case 'a': + aopt = optarg; + continue; + case 'r': + ropt = optarg; + continue; + default: +usage: fprintf(stderr, + "usage: %s [global-options] ...\n", + argv[0]); + exit(1); + } + if (argc - optind < 2) + goto usage; + imgfile = argv[optind++]; + passon_argv = argv + optind; + passon_argc = argc - optind; + + output_argc = passon_argc + 3; + if (aopt) + output_argc += 2; + if (ropt) + output_argc += 2; + output_argv = malloc(sizeof(char *) * (output_argc + 1)); + if (!output_argv) { + perror("malloc for tiffs argument list"); + exit(1); + } + dp = output_argv; + *dp++ = "tiffs"; + if (aopt) { + *dp++ = "-a"; + *dp++ = aopt; + } + if (ropt) { + *dp++ = "-r"; + *dp++ = ropt; + } + *dp++ = imgfile; + *dp++ = "256x18"; + for (sp = passon_argv; *sp; sp++) + *dp++ = *sp; + *dp = 0; + execvp(tiffs_prog_pathname, output_argv); + perror(tiffs_prog_pathname); + exit(1); +}