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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. static struct args args = {
  27. @@ -116,7 +120,7 @@ static int parse_opt(int argc, char * co
  28. int key, error = 0;
  29. unsigned long int image_seq;
  30. - key = getopt_long(argc, argv, "o:p:m:s:O:e:x:Q:vhV", long_options, NULL);
  31. + key = getopt_long(argc, argv, "o:p:m:s:O:e:x:Q:E:vhV", long_options, NULL);
  32. if (key == -1)
  33. break;
  34. @@ -176,6 +180,12 @@ static int parse_opt(int argc, char * co
  35. args.image_seq = image_seq;
  36. break;
  37. + case 'E':
  38. + args.eof_markers = simple_strtoul(optarg, &error);
  39. + if (error)
  40. + return errmsg("bad number of eof-markers: \"%s\"", optarg);
  41. + break;
  42. +
  43. case 'v':
  44. args.verbose = 1;
  45. break;
  46. @@ -559,6 +569,18 @@ int main(int argc, char * const argv[])
  47. printf("\n");
  48. }
  49. + if (args.eof_markers) {
  50. + verbose(args.verbose, "writing %d eof-marker blocks",
  51. + args.eof_markers);
  52. +
  53. + err = ubigen_write_eof_markers(&ui, args.ec, args.eof_markers,
  54. + args.out_fd);
  55. + if (err) {
  56. + errmsg("cannot write eof-marker blocks");
  57. + goto out_free;
  58. + }
  59. + }
  60. +
  61. verbose(args.verbose, "writing layout volume");
  62. err = ubigen_write_layout_vol(&ui, 0, 1, args.ec, args.ec, vtbl, args.out_fd);