always use imageoutfile() when accessing an image

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Michael Olbrich 2011-10-10 16:38:14 +02:00 committed by Sascha Hauer
parent eb72f4eb22
commit 2a5479300e
4 changed files with 8 additions and 15 deletions

View File

@ -12,9 +12,9 @@ static int ext2_generate(struct image *image)
int ret;
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
ret = systemp(image, "%s -d %s --size-in-blocks=%lld %s/%s %s",
ret = systemp(image, "%s -d %s --size-in-blocks=%lld %s %s",
get_opt("genext2fs"),
mountpath(image), image->size / 1024, imagepath(), image->file,
mountpath(image), image->size / 1024, imageoutfile(image),
extraargs);
return ret;

View File

@ -19,7 +19,7 @@ static int flash_generate(struct image *image)
struct partition *part;
struct stat s;
int ret;
char *buf;
const char *buf;
list_for_each_entry(part, &image->partitions, list) {
struct image *child;
@ -29,9 +29,8 @@ static int flash_generate(struct image *image)
image_error(image, "could not find %s\n", part->name);
return -EINVAL;
}
asprintf(&buf, "%s/%s", imagepath(), part->image);
buf = imageoutfile(child);
ret = stat(buf, &s);
free(buf);
if (ret)
return -errno;

View File

@ -28,28 +28,25 @@ static int hdimage_generate(struct image *image)
{
struct partition *part;
enum pad_mode mode = MODE_OVERWRITE;
const char *outfile = imageoutfile(image);
int ret;
list_for_each_entry(part, &image->partitions, list) {
struct image *child;
char *infile, *outfile;
const char *infile;
child = image_get(part->image);
if (!child) {
image_error(image, "could not find %s\n", part->image);
return -EINVAL;
}
asprintf(&infile, "%s/%s", imagepath(), part->image);
asprintf(&outfile, "%s", imageoutfile(image));
infile = imageoutfile(child);
if (part->offset) {
ret = pad_file(NULL, outfile, part->offset, 0x0, mode);
if (ret) {
image_error(image, "failed to pad image to size %lld\n",
part->offset);
free(infile);
free(outfile);
return ret;
}
mode = MODE_APPEND;
@ -57,9 +54,6 @@ static int hdimage_generate(struct image *image)
ret = pad_file(infile, outfile, part->size, 0x0, mode);
free(infile);
free(outfile);
if (ret)
return ret;
mode = MODE_APPEND;

View File

@ -59,7 +59,7 @@ static int ubi_generate(struct image *image)
fprintf(fini, "[%s]\n", part->name);
fprintf(fini, "mode=ubi\n");
fprintf(fini, "image=%s/%s\n", imagepath(), child->file);
fprintf(fini, "image=%s\n", imageoutfile(child));
fprintf(fini, "vol_id=%d\n", i);
fprintf(fini, "vol_size=%lld\n", child->size);
fprintf(fini, "vol_type=dynamic\n");