/* * We take copies first, because a failed apply can trash * both the base blob and the overlay
*/
tmpo = xmalloc(fdt_totalsize(overlay));
do {
tmp = xrealloc(tmp, *buf_len);
ret = fdt_open_into(base, tmp, *buf_len); if (ret) {
fprintf(stderr, "\nFailed to make temporary copy: %s\n",
fdt_strerror(ret)); goto fail;
}
memcpy(tmpo, overlay, fdt_totalsize(overlay));
ret = fdt_overlay_apply(tmp, tmpo); if (ret == -FDT_ERR_NOSPACE) {
*buf_len += BUF_INCREMENT;
}
} while (ret == -FDT_ERR_NOSPACE);
if (ret) {
fprintf(stderr, "\nFailed to apply '%s': %s\n",
name, fdt_strerror(ret)); goto fail;
}
free(base);
free(tmpo); return tmp;
fail:
free(tmpo); if (tmp)
free(tmp);
return NULL;
} staticint do_fdtoverlay(constchar *input_filename, constchar *output_filename, int argc, char *argv[])
{ char *blob = NULL; char **ovblob = NULL;
size_t buf_len; int i, ret = -1;
blob = utilfdt_read(input_filename, &buf_len); if (!blob) {
fprintf(stderr, "\nFailed to read '%s'\n", input_filename); goto out_err;
} if (fdt_totalsize(blob) > buf_len) {
fprintf(stderr, "\nBase blob is incomplete (%lu / %" PRIu32 " bytes read)\n",
(unsignedlong)buf_len, fdt_totalsize(blob)); goto out_err;
}
if (!output_filename)
usage("missing output file");
argv += optind;
argc -= optind;
if (argc <= 0)
usage("missing overlay file(s)");
if (verbose) {
printf("input = %s\n", input_filename);
printf("output = %s\n", output_filename); for (i = 0; i < argc; i++)
printf("overlay[%d] = %s\n", i, argv[i]);
}
if (do_fdtoverlay(input_filename, output_filename, argc, argv)) return 1;
return 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.