]> www.infradead.org Git - mtd-utils.git/commitdiff
ubinize: add autoresize flag support
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 24 Jan 2008 11:17:24 +0000 (13:17 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 24 Jan 2008 11:17:24 +0000 (13:17 +0200)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/include/libubigen.h
ubi-utils/src/libubigen.c
ubi-utils/src/ubinize.c

index 66f5fb1a758cb9024e4a3e20068baada0333a14f..f5c76161e5bdcd009b164dac3e8decfb432ddc13 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef __LIBUBIGEN_H__
 #define __LIBUBIGEN_H__
 
+#include <stdint.h>
 #include <stdio.h>
 #include <asm/byteorder.h>
 
@@ -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,
index 9cbd1b7d086d933592a2ffbece396c899c0366df..83cea91f64c9f0d09c9d70afbbd9f37fd7642745 100644 (file)
@@ -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';
index e36c3ba280e96d8c8cd28fc7d6d7f42d7e7e4d65..86a18ebeb703dc88336fccca2214516e61d7d097 100644 (file)
@@ -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);