diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-11-07 19:53:01 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2013-11-07 19:53:01 +0000 |
commit | 8124ffd8d20791a2710bc5cb7afdd16cd58ff99c (patch) | |
tree | 966acdbcceb42e32417d597b5f71cfb00b1db745 /tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch | |
parent | 65e8ac294b9be6270e42c1321a74752542a84a77 (diff) | |
download | master-187ad058-8124ffd8d20791a2710bc5cb7afdd16cd58ff99c.tar.gz master-187ad058-8124ffd8d20791a2710bc5cb7afdd16cd58ff99c.tar.bz2 master-187ad058-8124ffd8d20791a2710bc5cb7afdd16cd58ff99c.zip |
tools/mtd-utils: add EOF marker support to libubigen/ubinize
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38682 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch')
-rw-r--r-- | tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch b/tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch new file mode 100644 index 0000000000..8bd642fbc8 --- /dev/null +++ b/tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch @@ -0,0 +1,89 @@ +--- a/ubi-utils/src/libubigen.c ++++ b/ubi-utils/src/libubigen.c +@@ -122,8 +122,9 @@ int ubigen_add_volume(const struct ubige + return 0; + } + +-void ubigen_init_ec_hdr(const struct ubigen_info *ui, +- struct ubi_ec_hdr *hdr, long long ec) ++static void __ubigen_init_ec_hdr(const struct ubigen_info *ui, ++ struct ubi_ec_hdr *hdr, long long ec, ++ int eof) + { + uint32_t crc; + +@@ -136,10 +137,22 @@ void ubigen_init_ec_hdr(const struct ubi + hdr->data_offset = cpu_to_be32(ui->data_offs); + hdr->image_seq = cpu_to_be32(ui->image_seq); + ++ if (eof) { ++ hdr->padding1[0] = 'E'; ++ hdr->padding1[1] = 'O'; ++ hdr->padding1[2] = 'F'; ++ } ++ + crc = mtd_crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC); + hdr->hdr_crc = cpu_to_be32(crc); + } + ++void ubigen_init_ec_hdr(const struct ubigen_info *ui, ++ struct ubi_ec_hdr *hdr, long long ec) ++{ ++ __ubigen_init_ec_hdr(ui, hdr, ec, 0); ++} ++ + void ubigen_init_vid_hdr(const struct ubigen_info *ui, + const struct ubigen_vol_info *vi, + struct ubi_vid_hdr *hdr, int lnum, +@@ -307,6 +320,39 @@ int ubigen_write_layout_vol(const struct + } + + free(outbuf); ++ return 0; ++ ++out_free: ++ free(outbuf); ++ return -1; ++} ++ ++int ubigen_write_eof_markers(const struct ubigen_info *ui, long long ec, ++ int count, int out_fd) ++{ ++ char *outbuf; ++ int peb_size = ui->peb_size; ++ ++ outbuf = malloc(peb_size); ++ if (!outbuf) { ++ sys_errmsg("cannot allocate %d bytes of memory", peb_size); ++ return -1; ++ } ++ ++ memset(outbuf, 0xFF, peb_size); ++ __ubigen_init_ec_hdr(ui, (struct ubi_ec_hdr *)outbuf, ec, 1); ++ ++ while (count) { ++ if (write(out_fd, outbuf, peb_size) != peb_size) { ++ sys_errmsg("cannot write %d bytes to the output file", ++ peb_size); ++ goto out_free; ++ } ++ ++ count--; ++ } ++ ++ free(outbuf); + return 0; + + out_free: +--- a/ubi-utils/include/libubigen.h ++++ b/ubi-utils/include/libubigen.h +@@ -188,6 +188,9 @@ int ubigen_write_layout_vol(const struct + long long ec1, long long ec2, + struct ubi_vtbl_record *vtbl, int fd); + ++int ubigen_write_eof_markers(const struct ubigen_info *ui, long long ec, ++ int count, int out_fd); ++ + #ifdef __cplusplus + } + #endif |