0da28b71f2e44625ba07af8bd652f192dad192c6
[openwrt/openwrt.git] / tools / mtd-utils / patches / 201-ubinize-add-terminator-support.patch
1 --- a/ubi-utils/ubinize.c
2 +++ b/ubi-utils/ubinize.c
3 @@ -60,6 +60,8 @@ static const char optionsstr[] =
4 " (default is 1)\n"
5 "-Q, --image-seq=<num> 32-bit UBI image sequence number to use\n"
6 " (by default a random number is picked)\n"
7 +"-E, --eof-markers=<num> number of eof-markers to put at the end of the\n"
8 +" output image\n"
9 "-v, --verbose be verbose\n"
10 "-h, --help print help message\n"
11 "-V, --version print program version\n\n";
12 @@ -79,6 +81,7 @@ static const struct option long_options[
13 { .name = "erase-counter", .has_arg = 1, .flag = NULL, .val = 'e' },
14 { .name = "ubi-ver", .has_arg = 1, .flag = NULL, .val = 'x' },
15 { .name = "image-seq", .has_arg = 1, .flag = NULL, .val = 'Q' },
16 + { .name = "eof-markers", .has_arg = 1, .flag = NULL, .val = 'E' },
17 { .name = "verbose", .has_arg = 0, .flag = NULL, .val = 'v' },
18 { .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' },
19 { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
20 @@ -98,6 +101,7 @@ struct args {
21 uint32_t image_seq;
22 int verbose;
23 dictionary *dict;
24 + int eof_markers;
25 };
26
27 static struct args args = {
28 @@ -116,7 +120,7 @@ static int parse_opt(int argc, char * co
29 int key, error = 0;
30 unsigned long int image_seq;
31
32 - key = getopt_long(argc, argv, "o:p:m:s:O:e:x:Q:vhV", long_options, NULL);
33 + key = getopt_long(argc, argv, "o:p:m:s:O:e:x:Q:E:vhV", long_options, NULL);
34 if (key == -1)
35 break;
36
37 @@ -176,6 +180,12 @@ static int parse_opt(int argc, char * co
38 args.image_seq = image_seq;
39 break;
40
41 + case 'E':
42 + args.eof_markers = simple_strtoul(optarg, &error);
43 + if (error)
44 + return errmsg("bad number of eof-markers: \"%s\"", optarg);
45 + break;
46 +
47 case 'v':
48 args.verbose = 1;
49 break;
50 @@ -559,6 +569,18 @@ int main(int argc, char * const argv[])
51 printf("\n");
52 }
53
54 + if (args.eof_markers) {
55 + verbose(args.verbose, "writing %d eof-marker blocks",
56 + args.eof_markers);
57 +
58 + err = ubigen_write_eof_markers(&ui, args.ec, args.eof_markers,
59 + args.out_fd);
60 + if (err) {
61 + errmsg("cannot write eof-marker blocks");
62 + goto out_free;
63 + }
64 + }
65 +
66 verbose(args.verbose, "writing layout volume");
67
68 err = ubigen_write_layout_vol(&ui, 0, 1, args.ec, args.ec, vtbl, args.out_fd);