]> git.zerfleddert.de Git - rsbs2/commitdiff
add 'list all files in image' option
authorMichael Gernoth <michael@gernoth.net>
Sun, 1 Feb 2009 23:23:09 +0000 (00:23 +0100)
committerMichael Gernoth <michael@gernoth.net>
Sun, 1 Feb 2009 23:23:09 +0000 (00:23 +0100)
filesystem.c
filesystem.h
firmware.c

index d05361d7304c6bae8d5ff8ceac9bf1182245713e..84c592cac3b00e01760e8d8fb7e32601681b67ba 100644 (file)
@@ -137,6 +137,16 @@ void replace_add_file(unsigned char *fw, int len, char *fwname, char *lname)
        exit(1);
 }
 
+void list_files(unsigned char *fw, int len)
+{
+       struct file_entry *fent;
+
+       for (fent = get_next_file(fw, len); fent != NULL; fent = get_next_file(NULL, 0)) {
+               printf("0x%x %8d %s\n", fent->unknown, fent->length, fent->name);
+       }
+
+}
+
 void mkdir_p(char *dir)
 {
        char *copy, *parent;
index cd72929c871c5957cdb4e7ca1f60da5ac27aeba7..d4b91c77b7461ad99f5ba311a988f3963e8b5530 100644 (file)
@@ -8,4 +8,5 @@ struct file_entry {
 struct file_entry* get_next_file(unsigned char *fw, int len);
 void extract_files(unsigned char *fw, int len);
 void replace_add_file(unsigned char *fw, int len, char *fwname, char *lname);
+void list_files(unsigned char *fw, int len);
 void write_file(char *fname, unsigned char *buf, int len);
index 16b86183431ebd89bdba766af34f4710b75fd708..80e12e54f9ff73aaaa15449524dde10055601a7d 100644 (file)
@@ -263,6 +263,7 @@ void syntax(char *name)
        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");
@@ -375,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:x:")) != -1) {
+       while ((opt = getopt(argc, argv, "dubelt:f:w:r:x:")) != -1) {
                switch(opt) {
                        case 'd':
                                showall = 1;
@@ -393,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':
@@ -487,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);
        }
Impressum, Datenschutz