1 --- a/ubi-utils/src/libubigen.c
2 +++ b/ubi-utils/src/libubigen.c
3 @@ -122,8 +122,9 @@ int ubigen_add_volume(const struct ubige
7 -void ubigen_init_ec_hdr(const struct ubigen_info *ui,
8 - struct ubi_ec_hdr *hdr, long long ec)
9 +static void __ubigen_init_ec_hdr(const struct ubigen_info *ui,
10 + struct ubi_ec_hdr *hdr, long long ec,
15 @@ -136,10 +137,22 @@ void ubigen_init_ec_hdr(const struct ubi
16 hdr->data_offset = cpu_to_be32(ui->data_offs);
17 hdr->image_seq = cpu_to_be32(ui->image_seq);
20 + hdr->padding1[0] = 'E';
21 + hdr->padding1[1] = 'O';
22 + hdr->padding1[2] = 'F';
25 crc = mtd_crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
26 hdr->hdr_crc = cpu_to_be32(crc);
29 +void ubigen_init_ec_hdr(const struct ubigen_info *ui,
30 + struct ubi_ec_hdr *hdr, long long ec)
32 + __ubigen_init_ec_hdr(ui, hdr, ec, 0);
35 void ubigen_init_vid_hdr(const struct ubigen_info *ui,
36 const struct ubigen_vol_info *vi,
37 struct ubi_vid_hdr *hdr, int lnum,
38 @@ -307,6 +320,39 @@ int ubigen_write_layout_vol(const struct
49 +int ubigen_write_eof_markers(const struct ubigen_info *ui, long long ec,
50 + int count, int out_fd)
53 + int peb_size = ui->peb_size;
55 + outbuf = malloc(peb_size);
57 + sys_errmsg("cannot allocate %d bytes of memory", peb_size);
61 + memset(outbuf, 0xFF, peb_size);
62 + __ubigen_init_ec_hdr(ui, (struct ubi_ec_hdr *)outbuf, ec, 1);
65 + if (write(out_fd, outbuf, peb_size) != peb_size) {
66 + sys_errmsg("cannot write %d bytes to the output file",
78 --- a/ubi-utils/include/libubigen.h
79 +++ b/ubi-utils/include/libubigen.h
80 @@ -188,6 +188,9 @@ int ubigen_write_layout_vol(const struct
81 long long ec1, long long ec2,
82 struct ubi_vtbl_record *vtbl, int fd);
84 +int ubigen_write_eof_markers(const struct ubigen_info *ui, long long ec,
85 + int count, int out_fd);