X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/blobdiff_plain/b5163e0dbed5fbeb23b9ffa872489c54731c4c3b..59a213c089f531918c27395ea8794da8cd3c2b9a:/firmware.c diff --git a/firmware.c b/firmware.c index aeef48c..80e12e5 100644 --- a/firmware.c +++ b/firmware.c @@ -8,7 +8,7 @@ #include #include #include "rsb-crc.h" -#include "extract.h" +#include "filesystem.h" #define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str))) @@ -259,14 +259,16 @@ void syntax(char *name) { fprintf(stderr,"Syntax: %s parameters firmware.bin\n", name); fprintf(stderr,"parameters as follows:\n"); - fprintf(stderr,"\t-d\t\tdisplay all properties of the image\n"); - fprintf(stderr,"\t-u\t\tupdate checksum of the image\n"); - fprintf(stderr,"\t-b\t\tmodify BOARD_DESCRIPTION for more power-switch options\n"); - fprintf(stderr,"\t-e\t\textract files in firmware\n"); - fprintf(stderr,"\t-t property\tset 'property' to true\n"); - fprintf(stderr,"\t-f property\tset 'property' to false\n"); - fprintf(stderr,"\t-w property\tallow read-write access to 'property'\n"); - fprintf(stderr,"\t-r property\tallow read-only access to 'property'\n"); + fprintf(stderr,"\t-d\t\t\tdisplay all properties of the image\n"); + fprintf(stderr,"\t-u\t\t\tupdate checksum of the image\n"); + fprintf(stderr,"\t-b\t\t\tmodify BOARD_DESCRIPTION for more power-switch options\n"); + fprintf(stderr,"\t-e\t\t\textract files in firmware\n"); + fprintf(stderr,"\t-l\t\t\tlist files in firmware\n"); + fprintf(stderr,"\t-t property\t\tset 'property' to true\n"); + fprintf(stderr,"\t-f property\t\tset 'property' to false\n"); + fprintf(stderr,"\t-w property\t\tallow read-write access to 'property'\n"); + fprintf(stderr,"\t-r property\t\tallow read-only access to 'property'\n"); + fprintf(stderr,"\t-x fw_file=local_file\treplace or add fw_file with content of local_file\n"); exit(1); } @@ -374,11 +376,12 @@ int main(int argc, char **argv) int patch_bd = 0; int patch_fw = 0; int extract = 0; + int list = 0; if (argc < 2) syntax(argv[0]); - while ((opt = getopt(argc, argv, "dubet:f:w:r:")) != -1) { + while ((opt = getopt(argc, argv, "dubelt:f:w:r:x:")) != -1) { switch(opt) { case 'd': showall = 1; @@ -392,6 +395,9 @@ int main(int argc, char **argv) case 'e': extract = 1; break; + case 'l': + list = 1; + break; case 't': case 'f': case 'w': @@ -399,6 +405,9 @@ int main(int argc, char **argv) patch_fw = 1; add_action(opt, optarg, &paction); break; + case 'x': + replace_add_file(NULL, 0, NULL, NULL); + break; default: syntax(argv[0]); } @@ -483,6 +492,10 @@ int main(int argc, char **argv) handle_boarddescription(fw, statbuf.st_size - 4, 0); } + if (list) { + list_files(fw, statbuf.st_size - 4); + } + if (extract) { extract_files(fw, statbuf.st_size - 4); } @@ -508,7 +521,7 @@ int main(int argc, char **argv) printf("Writing %s\n", newfile); if ((fd = open(newfile, O_WRONLY|O_CREAT, 0644)) == -1) { - fprintf(stderr,"%s: ", file); + fprintf(stderr,"%s: ", newfile); perror("open"); exit(1); }