From 6b424c2dd3576e0938762365411f75042e41b6b8 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 24 Jan 2008 13:17:24 +0200 Subject: ubinize: add autoresize flag support Signed-off-by: Artem Bityutskiy --- ubi-utils/include/libubigen.h | 3 +++ ubi-utils/src/libubigen.c | 1 + ubi-utils/src/ubinize.c | 35 +++++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ubi-utils/include/libubigen.h b/ubi-utils/include/libubigen.h index 66f5fb1..f5c7616 100644 --- a/ubi-utils/include/libubigen.h +++ b/ubi-utils/include/libubigen.h @@ -25,6 +25,7 @@ #ifndef __LIBUBIGEN_H__ #define __LIBUBIGEN_H__ +#include #include #include @@ -73,6 +74,7 @@ struct ubigen_info * for static volumes only) * @bytes: size of the volume contents in bytes (relevant for static volumes * only) + * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG) */ struct ubigen_vol_info { @@ -86,6 +88,7 @@ struct ubigen_vol_info int compat; int used_ebs; long long bytes; + uint8_t flags; }; void ubigen_info_init(struct ubigen_info *ui, int peb_size, int min_io_size, diff --git a/ubi-utils/src/libubigen.c b/ubi-utils/src/libubigen.c index 9cbd1b7..83cea91 100644 --- a/ubi-utils/src/libubigen.c +++ b/ubi-utils/src/libubigen.c @@ -132,6 +132,7 @@ int ubigen_add_volume(const struct ubigen_info *ui, vtbl_rec->vol_type = vi->type; tmp = ui->leb_size % vi->alignment; vtbl_rec->data_pad = __cpu_to_be32(tmp); + vtbl_rec->flags = vi->flags; memcpy(vtbl_rec->name, vi->name, vi->name_len); vtbl_rec->name[vi->name_len] = '\0'; diff --git a/ubi-utils/src/ubinize.c b/ubi-utils/src/ubinize.c index e36c3ba..86a18eb 100644 --- a/ubi-utils/src/ubinize.c +++ b/ubi-utils/src/ubinize.c @@ -90,15 +90,16 @@ static const char *ini_doc = "INI-file format.\n" "vol_size=30MiB\n" "vol_type=dynamic\n" "vol_name=jffs2_volume\n" +"vol_flags=autoresize\n" "vol_alignment=1\n\n" "This example configuration file tells the utility to create an UBI image\n" "with one volume with ID 1, volume size 30MiB, the volume is dynamic, has\n" -"name \"jffs2_volume\" and alignment 1. The \"image=../jffs2.img\" line tells\n" -"the utility to take the contents of the volume from the \"../jffs2.img\"\n" -"file. The size of the image file has to be less or equivalent to the volume\n" -"size (30MiB). The \"mode=ubi\" line is mandatory and just tells that the\n" -"section describes an UBI volume - other section modes may be added in\n" -"future.\n" +"name \"jffs2_volume\", \"autoresize\" volume flag, and alignment 1. The\n" +"\"image=../jffs2.img\" line tells the utility to take the contents of the\n" +"volume from the \"../jffs2.img\" file. The size of the image file has to be\n" +"less or equivalent to the volume size (30MiB). The \"mode=ubi\" line is\n" +"mandatory and just tells that the section describes an UBI volume - other\n" +"section modes may be added in the future.\n" "Notes:\n" " * size in vol_size might be specified kilobytes (KiB), megabytes (MiB),\n" " gigabytes (GiB) or bytes (no modifier);\n" @@ -108,7 +109,7 @@ static const char *ini_doc = "INI-file format.\n" " * volume alignment must not be greater than the logical eraseblock size;\n" " * one ini file may contain arbitrary number of sections, the utility will\n" " put all the volumes which are described by these section to the output\n" -" UBI image file.\n"; +" UBI image file."; struct option long_options[] = { { .name = "output", .has_arg = 1, .flag = NULL, .val = 'o' }, @@ -253,8 +254,8 @@ static int parse_opt(int argc, char * const argv[]) case 'h': ubiutils_print_text(stderr, doc, 80); - fprintf(stderr, "\n%s\n", ini_doc); - fprintf(stderr, "\n\n%s\n\n", usage); + fprintf(stderr, "\n%s\n\n", ini_doc); + fprintf(stderr, "%s\n", usage); fprintf(stderr, "%s\n", optionsstr); exit(EXIT_SUCCESS); @@ -465,6 +466,20 @@ int read_section(const char *sname, struct ubigen_vol_info *vi, verbose(args.verbose, "volume alignment: %d", vi->alignment); + /* Fetch volume flags */ + sprintf(buf, "%s:vol_flags", sname); + p = iniparser_getstring(args.dict, buf, NULL); + if (p) { + if (!strcmp(p, "autoresize")) { + verbose(args.verbose, "autoresize flags found"); + vi->flags |= UBI_VTBL_AUTORESIZE_FLG; + } else { + errmsg("unknown flags \"%s\" in section \"%s\"", + p, sname); + return -1; + } + } + return 0; } @@ -588,7 +603,7 @@ int main(int argc, char * const argv[]) } verbose(args.verbose, "writing volume %d", vi.id); - verbose(args.verbose, "image file: %s", img); + verbose(args.verbose, "image file: %s", img); err = ubigen_write_volume(&ui, &vi, st.st_size, f, args.fp_out); fclose(f); -- cgit v1.2.3