summaryrefslogtreecommitdiff
path: root/ubi-utils/src/libubigen.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-07-26 18:06:58 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-07-26 18:45:03 +0300
commite1b213ceabcc5984c7cb9e73c44eaced31c6d7e9 (patch)
tree107ff94d4d9a2cb38f1c0af9daac1d21331a7342 /ubi-utils/src/libubigen.c
parent8b3cdd8105452737eba043c2e83cbfd8454223e1 (diff)
ubinize: add sequence number support
UBI now supports the image sequence number feature which prevents UBI from mistakingly accepting half-written images, if the image was written on top of an older image. Support this feature in ubinize and make it pick a random number for the UBI image sequence number. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/libubigen.c')
-rw-r--r--ubi-utils/src/libubigen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ubi-utils/src/libubigen.c b/ubi-utils/src/libubigen.c
index a34963e..db58cae 100644
--- a/ubi-utils/src/libubigen.c
+++ b/ubi-utils/src/libubigen.c
@@ -46,9 +46,11 @@
* @min_io_size if does not exist)
* @vid_hdr_offs: offset of the VID header
* @ubi_ver: UBI version
+ * @image_seq: UBI image sequence number
*/
void ubigen_info_init(struct ubigen_info *ui, int peb_size, int min_io_size,
- int subpage_size, int vid_hdr_offs, int ubi_ver)
+ int subpage_size, int vid_hdr_offs, int ubi_ver,
+ uint32_t image_seq)
{
if (!vid_hdr_offs) {
vid_hdr_offs = UBI_EC_HDR_SIZE + subpage_size - 1;
@@ -64,6 +66,7 @@ void ubigen_info_init(struct ubigen_info *ui, int peb_size, int min_io_size,
ui->data_offs *= min_io_size;
ui->leb_size = peb_size - ui->data_offs;
ui->ubi_ver = ubi_ver;
+ ui->image_seq = image_seq;
ui->max_volumes = ui->leb_size / UBI_VTBL_RECORD_SIZE;
if (ui->max_volumes > UBI_MAX_VOLUMES)
@@ -157,8 +160,8 @@ void ubigen_init_ec_hdr(const struct ubigen_info *ui,
hdr->version = ui->ubi_ver;
hdr->ec = cpu_to_be64(ec);
hdr->vid_hdr_offset = cpu_to_be32(ui->vid_hdr_offs);
-
hdr->data_offset = cpu_to_be32(ui->data_offs);
+ hdr->image_seq = cpu_to_be32(ui->image_seq);
crc = crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
hdr->hdr_crc = cpu_to_be32(crc);