From e1b213ceabcc5984c7cb9e73c44eaced31c6d7e9 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Sun, 26 Jul 2009 18:06:58 +0300 Subject: 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 --- ubi-utils/src/libubigen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ubi-utils/src/libubigen.c') 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); -- cgit v1.2.3