From 25c8b07357a9428a30bfd02ab8d1145cc25a23c6 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Fri, 18 Jan 2008 16:05:46 +0200 Subject: ubi-utils: move mkbootenv to sort-me-out Signed-off-by: Artem Bityutskiy --- ubi-utils/Makefile | 5 +- ubi-utils/sort-me-out/README | 3 + ubi-utils/sort-me-out/mkbootenv.c | 168 ++++++++++++++++++++++++++++++++++++++ ubi-utils/src/mkbootenv.c | 168 -------------------------------------- 4 files changed, 172 insertions(+), 172 deletions(-) create mode 100644 ubi-utils/sort-me-out/mkbootenv.c delete mode 100644 ubi-utils/src/mkbootenv.c (limited to 'ubi-utils') diff --git a/ubi-utils/Makefile b/ubi-utils/Makefile index e425d6a..517c8ec 100644 --- a/ubi-utils/Makefile +++ b/ubi-utils/Makefile @@ -15,7 +15,7 @@ CFLAGS := -I./inc -I./src -I$(KERNELHDR) $(OPTFLAGS) -Werror \ PERLPROGS = mkpfi ubicrc32.pl TARGETS = ubiupdate ubimkvol ubirmvol pfiflash pddcustomize ubimirror \ - mkbootenv unubi pfi2bin ubicrc32 ubinfo \ + unubi pfi2bin ubicrc32 ubinfo \ ubiattach ubidetach vpath %.c ./src @@ -70,9 +70,6 @@ ubimirror: ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \ libubi.o crc32.o $(CC) $(LDFLAGS) -o $@ $^ -mkbootenv: mkbootenv.o bootenv.o hashmap.o error.o crc32.o - $(CC) $(LDFLAGS) -o $@ $^ - unubi: unubi.o crc32.o unubi_analyze.o eb_chain.o $(CC) $(LDFLAGS) -o $@ $^ diff --git a/ubi-utils/sort-me-out/README b/ubi-utils/sort-me-out/README index 4018567..6a24555 100644 --- a/ubi-utils/sort-me-out/README +++ b/ubi-utils/sort-me-out/README @@ -48,3 +48,6 @@ This directory contains various stuff that has to be cleaned up and sorted out. * nandecc.c, nandecc.h: needed to compile nand2bin and bin2nand * nandcorr.c: seems to be unused + +* mkbootenv.c: no idea what is this about. Looks like something specific to IBM + guys's setup. diff --git a/ubi-utils/sort-me-out/mkbootenv.c b/ubi-utils/sort-me-out/mkbootenv.c new file mode 100644 index 0000000..952f651 --- /dev/null +++ b/ubi-utils/sort-me-out/mkbootenv.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) International Business Machines Corp., 2006 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Oliver Lohmann + * + * Create boot-parameter/pdd data from an ASCII-text input file. + * + * 1.2 Removed argp because we want to use uClibc. + * 1.3 Minor cleanup + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "bootenv.h" +#include "error.h" + +#define PROGRAM_VERSION "1.3" + +static char doc[] = "\nVersion: " PROGRAM_VERSION "\n" + "mkbootenv - processes bootenv text files and convertes " + "them into a binary format.\n"; + +static const char copyright [] __attribute__((unused)) = + "Copyright (c) International Business Machines Corp., 2006"; + +static const char *optionsstr = +" -c, --copyright Print copyright informatoin.\n" +" -o, --output= Write the output data to instead of\n" +" stdout.\n" +" -?, --help Give this help list\n" +" --usage Give a short usage message\n" +" -V, --version Print program version\n"; + +static const char *usage = +"Usage: mkbootenv [-c?V] [-o ] [--copyright] [--output=]\n" +" [--help] [--usage] [--version] [bootenv-txt-file]\n"; + +struct option long_options[] = { + { .name = "copyright", .has_arg = 0, .flag = NULL, .val = 'c' }, + { .name = "output", .has_arg = 1, .flag = NULL, .val = 'o' }, + { .name = "help", .has_arg = 0, .flag = NULL, .val = '?' }, + { .name = "usage", .has_arg = 0, .flag = NULL, .val = 0 }, + { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' }, + { NULL, 0, NULL, 0} +}; + +typedef struct myargs { + FILE* fp_in; + FILE* fp_out; + + char *arg1; + char **options; /* [STRING...] */ +} myargs; + +static int +parse_opt(int argc, char **argv, myargs *args) +{ + while (1) { + int key; + + key = getopt_long(argc, argv, "co:?V", long_options, NULL); + if (key == -1) + break; + + switch (key) { + case 'c': + fprintf(stderr, "%s\n", copyright); + exit(0); + break; + case 'o': + args->fp_out = fopen(optarg, "wb"); + if ((args->fp_out) == NULL) { + fprintf(stderr, "Cannot open file %s " + "for output\n", optarg); + exit(1); + } + break; + case '?': /* help */ + printf("%s", doc); + printf("%s", optionsstr); + printf("\nReport bugs to %s\n", + PACKAGE_BUGREPORT); + exit(0); + break; + case 'V': + printf("%s\n", PROGRAM_VERSION); + exit(0); + break; + default: + printf("%s", usage); + exit(-1); + } + } + + if (optind < argc) { + args->fp_in = fopen(argv[optind++], "rb"); + if ((args->fp_in) == NULL) { + fprintf(stderr, "Cannot open file %s for input\n", + argv[optind]); + exit(1); + } + } + + return 0; +} + +int +main(int argc, char **argv) { + int rc = 0; + bootenv_t env; + + myargs args = { + .fp_in = stdin, + .fp_out = stdout, + .arg1 = NULL, + .options = NULL, + }; + + parse_opt(argc, argv, &args); + + rc = bootenv_create(&env); + if (rc != 0) { + err_msg("Cannot create bootenv handle."); + goto err; + } + rc = bootenv_read_txt(args.fp_in, env); + if (rc != 0) { + err_msg("Cannot read bootenv from input file."); + goto err; + } + rc = bootenv_write(args.fp_out, env); + if (rc != 0) { + err_msg("Cannot write bootenv to output file."); + goto err; + } + + if (args.fp_in != stdin) { + fclose(args.fp_in); + } + if (args.fp_out != stdout) { + fclose(args.fp_out); + } + +err: + bootenv_destroy(&env); + return rc; +} diff --git a/ubi-utils/src/mkbootenv.c b/ubi-utils/src/mkbootenv.c deleted file mode 100644 index 952f651..0000000 --- a/ubi-utils/src/mkbootenv.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) International Business Machines Corp., 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Oliver Lohmann - * - * Create boot-parameter/pdd data from an ASCII-text input file. - * - * 1.2 Removed argp because we want to use uClibc. - * 1.3 Minor cleanup - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "bootenv.h" -#include "error.h" - -#define PROGRAM_VERSION "1.3" - -static char doc[] = "\nVersion: " PROGRAM_VERSION "\n" - "mkbootenv - processes bootenv text files and convertes " - "them into a binary format.\n"; - -static const char copyright [] __attribute__((unused)) = - "Copyright (c) International Business Machines Corp., 2006"; - -static const char *optionsstr = -" -c, --copyright Print copyright informatoin.\n" -" -o, --output= Write the output data to instead of\n" -" stdout.\n" -" -?, --help Give this help list\n" -" --usage Give a short usage message\n" -" -V, --version Print program version\n"; - -static const char *usage = -"Usage: mkbootenv [-c?V] [-o ] [--copyright] [--output=]\n" -" [--help] [--usage] [--version] [bootenv-txt-file]\n"; - -struct option long_options[] = { - { .name = "copyright", .has_arg = 0, .flag = NULL, .val = 'c' }, - { .name = "output", .has_arg = 1, .flag = NULL, .val = 'o' }, - { .name = "help", .has_arg = 0, .flag = NULL, .val = '?' }, - { .name = "usage", .has_arg = 0, .flag = NULL, .val = 0 }, - { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' }, - { NULL, 0, NULL, 0} -}; - -typedef struct myargs { - FILE* fp_in; - FILE* fp_out; - - char *arg1; - char **options; /* [STRING...] */ -} myargs; - -static int -parse_opt(int argc, char **argv, myargs *args) -{ - while (1) { - int key; - - key = getopt_long(argc, argv, "co:?V", long_options, NULL); - if (key == -1) - break; - - switch (key) { - case 'c': - fprintf(stderr, "%s\n", copyright); - exit(0); - break; - case 'o': - args->fp_out = fopen(optarg, "wb"); - if ((args->fp_out) == NULL) { - fprintf(stderr, "Cannot open file %s " - "for output\n", optarg); - exit(1); - } - break; - case '?': /* help */ - printf("%s", doc); - printf("%s", optionsstr); - printf("\nReport bugs to %s\n", - PACKAGE_BUGREPORT); - exit(0); - break; - case 'V': - printf("%s\n", PROGRAM_VERSION); - exit(0); - break; - default: - printf("%s", usage); - exit(-1); - } - } - - if (optind < argc) { - args->fp_in = fopen(argv[optind++], "rb"); - if ((args->fp_in) == NULL) { - fprintf(stderr, "Cannot open file %s for input\n", - argv[optind]); - exit(1); - } - } - - return 0; -} - -int -main(int argc, char **argv) { - int rc = 0; - bootenv_t env; - - myargs args = { - .fp_in = stdin, - .fp_out = stdout, - .arg1 = NULL, - .options = NULL, - }; - - parse_opt(argc, argv, &args); - - rc = bootenv_create(&env); - if (rc != 0) { - err_msg("Cannot create bootenv handle."); - goto err; - } - rc = bootenv_read_txt(args.fp_in, env); - if (rc != 0) { - err_msg("Cannot read bootenv from input file."); - goto err; - } - rc = bootenv_write(args.fp_out, env); - if (rc != 0) { - err_msg("Cannot write bootenv to output file."); - goto err; - } - - if (args.fp_in != stdin) { - fclose(args.fp_in); - } - if (args.fp_out != stdout) { - fclose(args.fp_out); - } - -err: - bootenv_destroy(&env); - return rc; -} -- cgit v1.2.3