Rename hwrev to hwrevs and fix unpacking fiasco images. hwrevs do not have to be separated by nullterm if size of hwrev is 8.
This commit is contained in:
1 parent
8bc521f3e5
commit
b4575a40fc
2 files changed
+23
-13
No files matched your search
+20
-10
@@ -125,7 +125,7 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
/* XXX this is not ok */
|
/* XXX this is not ok */
|
||||||
//printf("BUF8: %02x\n", buf[8]);
|
//printf("BUF8: %02x\n", buf[8]);
|
||||||
memset(header.device, 0, sizeof(header.device));
|
memset(header.device, 0, sizeof(header.device));
|
||||||
memset(header.hwrev, 0, sizeof(header.hwrev));
|
memset(header.hwrevs, 0, sizeof(header.hwrevs));
|
||||||
memset(header.version, 0, sizeof(header.version));
|
memset(header.version, 0, sizeof(header.version));
|
||||||
if (header.layout) {
|
if (header.layout) {
|
||||||
free(header.layout);
|
free(header.layout);
|
||||||
@@ -151,6 +151,11 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
pdata = data;
|
pdata = data;
|
||||||
pdataend = data+i;
|
pdataend = data+i;
|
||||||
while(pdata<pdataend) {
|
while(pdata<pdataend) {
|
||||||
|
char buf2[9];
|
||||||
|
if (buf[8] == '2' && pdata != data) {
|
||||||
|
memset(buf2, 0, 9);
|
||||||
|
strncpy(buf2, (char *)pdata, 8);
|
||||||
|
}
|
||||||
if (v) {
|
if (v) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
if (buf[8] == '1') printf("version");
|
if (buf[8] == '1') printf("version");
|
||||||
@@ -158,7 +163,9 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
else if (buf[8] == '2' && pdata != data) printf("hw revision");
|
else if (buf[8] == '2' && pdata != data) printf("hw revision");
|
||||||
else if (buf[8] == '3') printf("layout");
|
else if (buf[8] == '3') printf("layout");
|
||||||
else printf("data");
|
else printf("data");
|
||||||
if (buf[8] != '3' && buf[8] != '/')
|
if (buf[8] == '2' && pdata != data)
|
||||||
|
printf(": %s\n", buf2);
|
||||||
|
else if (buf[8] != '3' && buf[8] != '/')
|
||||||
printf(": %s\n", pdata);
|
printf(": %s\n", pdata);
|
||||||
else
|
else
|
||||||
printf(": (not printing)\n");
|
printf(": (not printing)\n");
|
||||||
@@ -168,18 +175,21 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
} else if (buf[8] == '2' && pdata == data) {
|
} else if (buf[8] == '2' && pdata == data) {
|
||||||
strcpy(header.device, (char *)pdata);
|
strcpy(header.device, (char *)pdata);
|
||||||
} else if (buf[8] == '2' && pdata != data) {
|
} else if (buf[8] == '2' && pdata != data) {
|
||||||
if (header.hwrev[0] == 0)
|
if (header.hwrevs[0] == 0)
|
||||||
strcpy(header.hwrev, (char *)pdata);
|
strcpy(header.hwrevs, buf2);
|
||||||
else {
|
else {
|
||||||
strcat(header.hwrev, ",");
|
strcat(header.hwrevs, ",");
|
||||||
strcat(header.hwrev, (char *)pdata);
|
strcat(header.hwrevs, buf2);
|
||||||
}
|
}
|
||||||
} else if (buf[8] == '3') {
|
} else if (buf[8] == '3') {
|
||||||
if (header.layout) free(header.layout);
|
if (header.layout) free(header.layout);
|
||||||
header.layout = malloc(strlen((char*)pdata)+1);
|
header.layout = malloc(strlen((char*)pdata)+1);
|
||||||
if (header.layout) strcpy(header.layout, (char *)pdata);
|
if (header.layout) strcpy(header.layout, (char *)pdata);
|
||||||
}
|
}
|
||||||
pdata = pdata+strlen((char*)pdata)+1;
|
if (buf[8] == '2' && pdata != data && strlen((char *)pdata) > 8)
|
||||||
|
pdata += 8;
|
||||||
|
else
|
||||||
|
pdata += strlen((char*)pdata)+1;
|
||||||
for(;*pdata=='\0' && pdata<pdataend; pdata++);
|
for(;*pdata=='\0' && pdata<pdataend; pdata++);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -195,9 +205,9 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
strcat(header.name, "-");
|
strcat(header.name, "-");
|
||||||
strcat(header.name, header.device);
|
strcat(header.name, header.device);
|
||||||
}
|
}
|
||||||
if (header.hwrev[0]) {
|
if (header.hwrevs[0]) {
|
||||||
strcat(header.name, "-");
|
strcat(header.name, "-");
|
||||||
strcat(header.name, header.hwrev);
|
strcat(header.name, header.hwrevs);
|
||||||
}
|
}
|
||||||
if (header.version[0]) {
|
if (header.version[0]) {
|
||||||
strcat(header.name, "-");
|
strcat(header.name, "-");
|
||||||
@@ -208,7 +218,7 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
if (v) {
|
if (v) {
|
||||||
printf(" version: %s\n", header.version);
|
printf(" version: %s\n", header.version);
|
||||||
printf(" device: %s\n", header.device);
|
printf(" device: %s\n", header.device);
|
||||||
printf(" hwrev: %s\n", header.hwrev);
|
printf(" hwrevs: %s\n", header.hwrevs);
|
||||||
printf(" name: %s\n", header.name);
|
printf(" name: %s\n", header.name);
|
||||||
printf(" body-at: 0x%08x\n", (unsigned int)off);
|
printf(" body-at: 0x%08x\n", (unsigned int)off);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -103,11 +103,11 @@ enum {
|
|||||||
struct header_t {
|
struct header_t {
|
||||||
int fd;
|
int fd;
|
||||||
char fwname[128];
|
char fwname[128];
|
||||||
char version[128];
|
char name[128];
|
||||||
char type[128];
|
char type[128];
|
||||||
char device[16];
|
char device[16];
|
||||||
char hwrev[128];
|
char hwrevs[128];
|
||||||
char name[128];
|
char version[128];
|
||||||
unsigned short hash;
|
unsigned short hash;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|||||||
Reference in new issue
Block a user