int main(int argc, char* argv[]) { char kernelfile[PATH_MAX]; char rootfsfile[PATH_MAX]; int o, rc; image_info_t im; memset(&im, 0, sizeof(im)); memset(kernelfile, 0, sizeof(kernelfile)); memset(rootfsfile, 0, sizeof(rootfsfile)); strcpy(im.outputfile, DEFAULT_OUTPUT_FILE); strcpy(im.version, DEFAULT_VERSION); while ((o = getopt(argc, argv, OPTIONS)) != -1) { switch (o) { case 'v': if (optarg) strncpy(im.version, optarg, sizeof(im.version)); break; case 'o': if (optarg) strncpy(im.outputfile, optarg, sizeof(im.outputfile)); break; case 'h': usage(argv[0]); return -1; case 'k': if (optarg) strncpy(kernelfile, optarg, sizeof(kernelfile)); break; case 'r': if (optarg) strncpy(rootfsfile, optarg, sizeof(rootfsfile)); break; case 's': if (optarg) #undef partition_startaddr #define partition_startaddr (optarg) break; } } if (strlen(kernelfile) == 0) { ERROR("Kernel file is not specified, cannot continue\n"); usage(argv[0]); return -2; } if (strlen(rootfsfile) == 0) { ERROR("Root FS file is not specified, cannot continue\n"); usage(argv[0]); return -2; } if ((rc = create_image_layout(kernelfile, rootfsfile, &im)) != 0) { ERROR("Failed creating firmware layout description - error code: %d\n", rc); return -3; } if ((rc = validate_image_layout(&im)) != 0) { ERROR("Failed validating firmware layout - error code: %d\n", rc); return -4; } print_image_info(&im); if ((rc = build_image(&im)) != 0) { ERROR("Failed building image file '%s' - error code: %d\n", im.outputfile, rc); return -5; } return 0; }
int main(int argc, char* argv[]) { char inputfile[PATH_MAX]; int o, rc; image_info_t im; memset(&im, 0, sizeof(im)); memset(inputfile, 0, sizeof(inputfile)); strcpy(im.outputfile, DEFAULT_OUTPUT_FILE); strcpy(im.version, DEFAULT_VERSION); while ((o = getopt(argc, argv, OPTIONS)) != -1) { switch (o) { case 'v': if (optarg) strncpy(im.version, optarg, sizeof(im.version)); break; case 'o': if (optarg) strncpy(im.outputfile, optarg, sizeof(im.outputfile)); break; case 'i': if (optarg) strncpy(inputfile, optarg, sizeof(inputfile)); break; case 'h': usage(argv[0]); return -1; } } if (strlen(inputfile) == 0) { ERROR("Input file is not specified, cannot continue\n"); usage(argv[0]); return -2; } if ((rc = parse_image_layout(inputfile, &im)) != 0) { ERROR("Failed parsing firmware layout file '%s' - error code: %d\n", inputfile, rc); return -3; } if ((rc = validate_image_layout(&im)) != 0) { ERROR("Failed validating firmware layout - error code: %d\n", rc); return -4; } print_image_info(&im); if ((rc = build_image(&im)) != 0) { ERROR("Failed building image file '%s' - error code: %d\n", im.outputfile, rc); return -5; } return 0; }