diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2012-08-07 14:20:54 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2012-08-07 14:20:54 +0200 |
commit | 589443a35669d5be37aa61734d53b7348b37694a (patch) | |
tree | b3eb2a90baf6e7bd666b1e217e8794fadbaef005 | |
parent | 869a872897f094b8f90bb2e4fad8904e4d2ff2ce (diff) | |
download | 0xFFFF-589443a35669d5be37aa61734d53b7348b37694a.tar.bz2 |
fiasco: align also kernel
-rw-r--r-- | src/fiasco2.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/fiasco2.c b/src/fiasco2.c index 4532465..cd20374 100644 --- a/src/fiasco2.c +++ b/src/fiasco2.c @@ -371,9 +371,16 @@ int fiasco_write_to_file(struct fiasco * fiasco, const char * file) { /* image size */ size = image->size; + /* Align mmc image size */ if ( image->type == IMAGE_MMC ) size = ((size >> 8) + 1) << 8; + /* Align kernel image size */ + else if ( image->type == IMAGE_KERNEL ) + size = ((size >> 7) + 1) << 7; + + /* TODO: update hash after align */ + size = htonl(size); WRITE_OR_FAIL(fd, &size, 4); @@ -447,13 +454,17 @@ int fiasco_write_to_file(struct fiasco * fiasco, const char * file) { WRITE_OR_FAIL(fd, buf, size); } - /* Align mmc image (fill with 0xff) */ - if ( image->type == IMAGE_MMC ) { + size = image->size; + + if ( image->type == IMAGE_MMC ) size = ((image->size >> 8) + 1) << 8; - while ( size > image->size ) { - WRITE_OR_FAIL(fd, "\xff", 1); - --size; - } + else if ( image->type == IMAGE_KERNEL ) + size = ((image->size >> 7) + 1) << 7; + + /* Align image if needed (fill with 0xff) */ + while ( size > image->size ) { + WRITE_OR_FAIL(fd, "\xff", 1); + --size; } image_list = image_list->next; @@ -494,6 +505,8 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) { name = calloc(1, length); + /* TODO: Unpack image */ + image_list = image_list->next; } |