2
0

201-ubinize-add-terminator-support.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --- a/ubi-utils/ubinize.c
  2. +++ b/ubi-utils/ubinize.c
  3. @@ -70,6 +70,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";
  12. @@ -79,7 +81,7 @@ static const char usage[] =
  13. "\t\t[-x <num>] [-Q <num>] [-v] [-h] [-V] [--output=<filename>] [--peb-size=<bytes>]\n"
  14. "\t\t[--min-io-size=<bytes>] [--sub-page-size=<bytes>] [--vid-hdr-offset=<num>]\n"
  15. "\t\t[--erase-counter=<num>] [--ubi-ver=<num>] [--image-seq=<num>] [--verbose] [--help]\n"
  16. -"\t\t[--version] ini-file\n"
  17. +"\t\t[--eof-markers=<num>] [--version] ini-file\n"
  18. "Example: " PROGRAM_NAME " -o ubi.img -p 16KiB -m 512 -s 256 cfg.ini - create UBI image\n"
  19. " 'ubi.img' as described by configuration file 'cfg.ini'";
  20. @@ -125,6 +127,7 @@ static const struct option long_options[
  21. { .name = "erase-counter", .has_arg = 1, .flag = NULL, .val = 'e' },
  22. { .name = "ubi-ver", .has_arg = 1, .flag = NULL, .val = 'x' },
  23. { .name = "image-seq", .has_arg = 1, .flag = NULL, .val = 'Q' },
  24. + { .name = "eof-markers", .has_arg = 1, .flag = NULL, .val = 'E' },
  25. { .name = "verbose", .has_arg = 0, .flag = NULL, .val = 'v' },
  26. { .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' },
  27. { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
  28. @@ -144,6 +147,7 @@ struct args {
  29. uint32_t image_seq;
  30. int verbose;
  31. dictionary *dict;
  32. + int eof_markers;
  33. };
  34. static struct args args = {
  35. @@ -162,7 +166,7 @@ static int parse_opt(int argc, char * co
  36. int key, error = 0;
  37. unsigned long int image_seq;
  38. - key = getopt_long(argc, argv, "o:p:m:s:O:e:x:Q:vhV", long_options, NULL);
  39. + key = getopt_long(argc, argv, "o:p:m:s:O:e:x:Q:E:vhV", long_options, NULL);
  40. if (key == -1)
  41. break;
  42. @@ -222,6 +226,12 @@ static int parse_opt(int argc, char * co
  43. args.image_seq = image_seq;
  44. break;
  45. + case 'E':
  46. + args.eof_markers = simple_strtoul(optarg, &error);
  47. + if (error)
  48. + return errmsg("bad number of eof-markers: \"%s\"", optarg);
  49. + break;
  50. +
  51. case 'v':
  52. args.verbose = 1;
  53. break;
  54. @@ -599,6 +609,18 @@ int main(int argc, char * const argv[])
  55. printf("\n");
  56. }
  57. + if (args.eof_markers) {
  58. + verbose(args.verbose, "writing %d eof-marker blocks",
  59. + args.eof_markers);
  60. +
  61. + err = ubigen_write_eof_markers(&ui, args.ec, args.eof_markers,
  62. + args.out_fd);
  63. + if (err) {
  64. + errmsg("cannot write eof-marker blocks");
  65. + goto out_free;
  66. + }
  67. + }
  68. +
  69. verbose(args.verbose, "writing layout volume");
  70. err = ubigen_write_layout_vol(&ui, 0, 1, args.ec, args.ec, vtbl, args.out_fd);