diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/mips/ingenic_x1000/installer-x1000.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/firmware/target/mips/ingenic_x1000/installer-x1000.c b/firmware/target/mips/ingenic_x1000/installer-x1000.c index 617e6645b7..0a09ad0e91 100644 --- a/firmware/target/mips/ingenic_x1000/installer-x1000.c +++ b/firmware/target/mips/ingenic_x1000/installer-x1000.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "nand-x1000.h" | 23 | #include "nand-x1000.h" |
24 | #include "core_alloc.h" | 24 | #include "core_alloc.h" |
25 | #include "file.h" | 25 | #include "file.h" |
26 | #include "microtar.h" | 26 | #include "microtar-rockbox.h" |
27 | #include <stddef.h> | 27 | #include <stddef.h> |
28 | 28 | ||
29 | struct update_part { | 29 | struct update_part { |
@@ -90,21 +90,21 @@ static void get_image_loc(nand_drv* ndrv, size_t* offptr, size_t* lenptr) | |||
90 | static int patch_part(mtar_t* tar, const struct update_part* part, | 90 | static int patch_part(mtar_t* tar, const struct update_part* part, |
91 | uint8_t* img_buf, size_t img_off) | 91 | uint8_t* img_buf, size_t img_off) |
92 | { | 92 | { |
93 | mtar_header_t h; | 93 | int rc = mtar_find(tar, part->filename); |
94 | int rc = mtar_find(tar, part->filename, &h); | ||
95 | if(rc != MTAR_ESUCCESS) | 94 | if(rc != MTAR_ESUCCESS) |
96 | return IERR_BAD_FORMAT; | 95 | return IERR_BAD_FORMAT; |
97 | 96 | ||
98 | if(h.type != 0 && h.type != MTAR_TREG) | 97 | const mtar_header_t* h = mtar_get_header(tar); |
98 | if(h->type != 0 && h->type != MTAR_TREG) | ||
99 | return IERR_BAD_FORMAT; | 99 | return IERR_BAD_FORMAT; |
100 | 100 | ||
101 | if(h.size > part->length) | 101 | if(h->size > part->length) |
102 | return IERR_BAD_FORMAT; | 102 | return IERR_BAD_FORMAT; |
103 | 103 | ||
104 | /* wipe the patched area, and read in the new data */ | 104 | /* wipe the patched area, and read in the new data */ |
105 | memset(&img_buf[part->offset - img_off], 0xff, part->length); | 105 | memset(&img_buf[part->offset - img_off], 0xff, part->length); |
106 | rc = mtar_read_data(tar, &img_buf[part->offset - img_off], h.size); | 106 | rc = mtar_read_data(tar, &img_buf[part->offset - img_off], h->size); |
107 | if(rc != MTAR_ESUCCESS) | 107 | if(rc < 0 || (unsigned)rc != h->size) |
108 | return IERR_FILE_IO; | 108 | return IERR_FILE_IO; |
109 | 109 | ||
110 | return IERR_SUCCESS; | 110 | return IERR_SUCCESS; |
@@ -165,7 +165,7 @@ static int updater_init(struct updater* u) | |||
165 | 165 | ||
166 | CACHEALIGN_BUFFER(buffer, buf_len); | 166 | CACHEALIGN_BUFFER(buffer, buf_len); |
167 | u->tar = (mtar_t*)buffer; | 167 | u->tar = (mtar_t*)buffer; |
168 | memset(u->tar, 0, sizeof(struct mtar_t)); | 168 | memset(u->tar, 0, sizeof(mtar_t)); |
169 | 169 | ||
170 | rc = IERR_SUCCESS; | 170 | rc = IERR_SUCCESS; |
171 | 171 | ||
@@ -175,7 +175,7 @@ static int updater_init(struct updater* u) | |||
175 | 175 | ||
176 | static void updater_cleanup(struct updater* u) | 176 | static void updater_cleanup(struct updater* u) |
177 | { | 177 | { |
178 | if(u->tar && u->tar->close) | 178 | if(u->tar && mtar_is_open(u->tar)) |
179 | mtar_close(u->tar); | 179 | mtar_close(u->tar); |
180 | 180 | ||
181 | if(u->buf_hnd >= 0) | 181 | if(u->buf_hnd >= 0) |
@@ -202,7 +202,7 @@ int install_bootloader(const char* filename) | |||
202 | } | 202 | } |
203 | 203 | ||
204 | /* get the tarball */ | 204 | /* get the tarball */ |
205 | rc = mtar_open(u.tar, filename, "r"); | 205 | rc = mtar_open(u.tar, filename, O_RDONLY); |
206 | if(rc != MTAR_ESUCCESS) { | 206 | if(rc != MTAR_ESUCCESS) { |
207 | if(rc == MTAR_EOPENFAIL) | 207 | if(rc == MTAR_EOPENFAIL) |
208 | rc = IERR_FILE_NOT_FOUND; | 208 | rc = IERR_FILE_NOT_FOUND; |