mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-10 04:26:19 -04:00
mkimage: Fix variable length header support
Support for variable length images like AIS image was introduced in commit f0662105b674a3874227316abf8536bebc9b5995. A parameter "-s" was also introduced to prohibit copying of the image file automatically in the main program. However, this parameter was implemented incorrectly and the image file was copied nevertheless. Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Cc: Stefano Babic <sbabic@denx.de> Cc: Heiko Schocher <hs@denx.de> Acked-by: Stefano Babic <sbabic@denx.de>
This commit is contained in:
parent
3d2c8e6c7f
commit
d1be8f922e
@ -383,65 +383,66 @@ NXTARG: ;
|
|||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.skipcpy &&
|
if (!params.skipcpy) {
|
||||||
(params.type == IH_TYPE_MULTI ||
|
if (params.type == IH_TYPE_MULTI ||
|
||||||
params.type == IH_TYPE_SCRIPT)) {
|
params.type == IH_TYPE_SCRIPT) {
|
||||||
char *file = params.datafile;
|
char *file = params.datafile;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char *sep = NULL;
|
char *sep = NULL;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
if ((sep = strchr(file, ':')) != NULL) {
|
if ((sep = strchr(file, ':')) != NULL) {
|
||||||
*sep = '\0';
|
*sep = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat (file, &sbuf) < 0) {
|
||||||
|
fprintf (stderr, "%s: Can't stat %s: %s\n",
|
||||||
|
params.cmdname, file, strerror(errno));
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
size = cpu_to_uimage (sbuf.st_size);
|
||||||
|
} else {
|
||||||
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat (file, &sbuf) < 0) {
|
if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) {
|
||||||
fprintf (stderr, "%s: Can't stat %s: %s\n",
|
fprintf (stderr, "%s: Write error on %s: %s\n",
|
||||||
params.cmdname, file, strerror(errno));
|
params.cmdname, params.imagefile,
|
||||||
|
strerror(errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
size = cpu_to_uimage (sbuf.st_size);
|
|
||||||
} else {
|
if (!file) {
|
||||||
size = 0;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sep) {
|
||||||
|
*sep = ':';
|
||||||
|
file = sep + 1;
|
||||||
|
} else {
|
||||||
|
file = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) {
|
file = params.datafile;
|
||||||
fprintf (stderr, "%s: Write error on %s: %s\n",
|
|
||||||
params.cmdname, params.imagefile,
|
|
||||||
strerror(errno));
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file) {
|
for (;;) {
|
||||||
break;
|
char *sep = strchr(file, ':');
|
||||||
}
|
if (sep) {
|
||||||
|
*sep = '\0';
|
||||||
if (sep) {
|
copy_file (ifd, file, 1);
|
||||||
*sep = ':';
|
*sep++ = ':';
|
||||||
file = sep + 1;
|
file = sep;
|
||||||
} else {
|
} else {
|
||||||
file = NULL;
|
copy_file (ifd, file, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
copy_file (ifd, params.datafile, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = params.datafile;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
char *sep = strchr(file, ':');
|
|
||||||
if (sep) {
|
|
||||||
*sep = '\0';
|
|
||||||
copy_file (ifd, file, 1);
|
|
||||||
*sep++ = ':';
|
|
||||||
file = sep;
|
|
||||||
} else {
|
|
||||||
copy_file (ifd, file, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
copy_file (ifd, params.datafile, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We're a bit of paranoid */
|
/* We're a bit of paranoid */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user