]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: move more stuff to sort-me-out
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 18 Jan 2008 14:51:29 +0000 (16:51 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 18 Jan 2008 14:51:29 +0000 (16:51 +0200)
Also remove error messages stuff from pfi2bin

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/Makefile
ubi-utils/sort-me-out/README
ubi-utils/sort-me-out/error.c [moved from ubi-utils/src/error.c with 100% similarity]
ubi-utils/sort-me-out/error.h [moved from ubi-utils/src/error.h with 100% similarity]
ubi-utils/sort-me-out/libpfiflash.c [moved from ubi-utils/src/libpfiflash.c with 100% similarity]
ubi-utils/sort-me-out/libubimirror.c [moved from ubi-utils/src/libubimirror.c with 100% similarity]
ubi-utils/sort-me-out/ubimirror.c [moved from ubi-utils/src/ubimirror.c with 100% similarity]
ubi-utils/sort-me-out/ubimirror.h [moved from ubi-utils/src/ubimirror.h with 100% similarity]
ubi-utils/src/pfi2bin.c

index 4fbdedc05fd6fe9ccd89a89ffb163a45bb0cd7f4..a6062a286b5955d59f450685137607ebda8a3d93 100644 (file)
@@ -14,8 +14,8 @@ CFLAGS := -I./inc -I./src -I$(KERNELHDR) $(OPTFLAGS) -Werror \
        -Wwrite-strings -W -std=gnu99 -DPACKAGE_VERSION=\"1.0\"
 
 PERLPROGS = mkpfi
-TARGETS = ubiupdate ubimkvol ubirmvol ubimirror unubi pfi2bin ubicrc32 ubinfo \
-         ubiattach ubidetach
+TARGETS = ubiupdate ubimkvol ubirmvol ubicrc32 ubinfo ubiattach ubidetach \
+         unubi pfi2bin
 
 vpath   %.c ./src
 
@@ -57,14 +57,10 @@ ubirmvol: ubirmvol.o common.o libubi.o
 ubicrc32: ubicrc32.o crc32.o
        $(CC) $(LDFLAGS) -o $@ $^
 
-ubimirror: ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \
-               libubi.o crc32.o
-       $(CC) $(LDFLAGS) -o $@ $^
-
 unubi: unubi.o crc32.o unubi_analyze.o eb_chain.o
        $(CC) $(LDFLAGS) -o $@ $^
 
-pfi2bin: pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o \
+pfi2bin: pfi2bin.o common.o peb.o list.o crc32.o libubigen.o bootenv.o \
                hashmap.o reader.o pfi.o
        $(CC) $(LDFLAGS) -o $@ $^
 
index ddeee73bf576215ad2a6a97c078b0ebf457aa43b..fa09c966607f4f22d263e2fe27589dbf6d9e5e9b 100644 (file)
@@ -58,3 +58,8 @@ This directory contains various stuff that has to be cleaned up and sorted out.
   better.
 
 * pddcustomize: not sure what is this for, seems to be IBM-specific.
+
+* ubimirror: not exactly sure what is this for - if it is neede, it should be
+  cleaned-up and moved to src/
+
+* error.[ch]: strange and rather IBM-specific error messages output infrastructure.
index 7f31938d6cd48829b4fab19cdd62eb0b133acb04..14744824266e5c93b693daf1e57f7d66d7d57df2 100644 (file)
 
 #include <ubigen.h>
 #include <mtd/ubi-header.h>
-
-#include "config.h"
+#include "common.h"
 #include "list.h"
-#include "error.h"
 #include "reader.h"
 #include "peb.h"
 #include "crc32.h"
 
-#define PROGRAM_VERSION "1.4"
+#define PROGRAM_VERSION "1.5"
+#define PROGRAM_NAME    "pfi2bin"
 
 #define MAX_FNAME 255
 #define DEFAULT_ERASE_COUNT  0 /* Hmmm.... Perhaps */
@@ -155,8 +154,6 @@ parse_opt(int argc, char **argv, myargs *args)
                                printf("pfi2bin [OPTION...] pfifile\n");
                                printf("%s", doc);
                                printf("%s", optionsstr);
-                               printf("\nReport bugs to %s\n",
-                                      PACKAGE_BUGREPORT);
                                exit(0);
                                break;
 
@@ -449,15 +446,15 @@ write_remaining_raw_ebs(pdd_data_t pdd, list_t raw_blocks, size_t *ebs_written,
                }
 
                if (peb->num < *ebs_written) {
-                       err_msg("eb_num: %d\n", peb->num);
-                       err_msg("Bug: This should never happen. %d %s",
+                       errmsg("eb_num: %d\n", peb->num);
+                       errmsg("Bug: This should never happen. %d %s",
                                __LINE__, __FILE__);
                        goto err;
                }
 
                delta = peb->num - *ebs_written;
                if (((delta + *ebs_written) * pdd->eb_size) > pdd->flash_size) {
-                       err_msg("RAW block outside of flash_size.");
+                       errmsg("RAW block outside of flash_size.");
                        goto err;
                }
                for (j = 0; j < delta; j++) {
@@ -518,23 +515,21 @@ create_raw(io_t io)
 
        rc = init_vol_tab (&vol_tab, &vol_tab_size);
        if (rc != 0) {
-               err_msg("Cannot initialize volume table.");
+               errmsg("cannot initialize volume table");
                goto err;
        }
 
        rc = read_pdd_data(io->fp_pdd, &pdd,
                        err_buf, ERR_BUF_SIZE);
        if (rc != 0) {
-               err_msg("Cannot read necessary pdd_data: %s rc: %d",
-                               err_buf, rc);
+               errmsg("cannot read necessary pdd_data: %s rc: %d", err_buf, rc);
                goto err;
        }
 
        rc = read_pfi_headers(&pfi_raws, &pfi_ubis, io->fp_pfi,
                        err_buf, ERR_BUF_SIZE);
        if (rc != 0) {
-               err_msg("Cannot read pfi header: %s rc: %d",
-                               err_buf, rc);
+               errmsg("cannot read pfi header: %s rc: %d", err_buf, rc);
                goto err;
        }
 
@@ -543,8 +538,7 @@ create_raw(io_t io)
                rc = memorize_raw_eb(pfi_raw, pdd, &raw_pebs,
                        io);
                if (rc != 0) {
-                       err_msg("Cannot create raw_block in mem. rc: %d\n",
-                               rc);
+                       errmsg("cannot create raw_block in mem. rc: %d\n", rc);
                        goto err;
                }
        }
@@ -554,7 +548,7 @@ create_raw(io_t io)
                rc = convert_ubi_volume(pfi_ubi, pdd, raw_pebs,
                                        vol_tab, &ebs_written, io);
                if (rc != 0) {
-                       err_msg("Cannot convert UBI volume. rc: %d\n", rc);
+                       errmsg("cannot convert UBI volume. rc: %d\n", rc);
                        goto err;
                }
        }
@@ -562,7 +556,7 @@ create_raw(io_t io)
        rc = write_ubi_volume_table(pdd, raw_pebs, vol_tab, vol_tab_size,
                        &ebs_written, io);
        if (rc != 0) {
-               err_msg("Cannot write UBI volume table. rc: %d\n", rc);
+               errmsg("cannot write UBI volume table. rc: %d\n", rc);
                goto err;
        }
 
@@ -571,7 +565,7 @@ create_raw(io_t io)
                goto err;
 
        if (io->fp_out != stdout)
-               info_msg("Physical eraseblocks written: %8d\n", ebs_written);
+               printf("Physical eraseblocks written: %8d\n", ebs_written);
 err:
        free(vol_tab);
        pfi_raws = remove_all((free_func_t)&free_pfi_raw, pfi_raws);
@@ -589,13 +583,13 @@ open_io_handle(myargs *args, io_t io)
        /* set PDD input */
        io->fp_pdd = fopen(args->f_in_pdd, "r");
        if (io->fp_pdd == NULL) {
-               err_sys("Cannot open: %s", args->f_in_pdd);
+               errmsg("cannot open: %s", args->f_in_pdd);
        }
 
        /* set PFI input */
        io->fp_pfi = fopen(args->f_in_pfi, "r");
        if (io->fp_pfi == NULL) {
-               err_sys("Cannot open PFI input file: %s", args->f_in_pfi);
+               errmsg("cannot open PFI input file: %s", args->f_in_pfi);
        }
 
        /* set output prefix */
@@ -604,7 +598,7 @@ open_io_handle(myargs *args, io_t io)
        else {
                io->fp_out = fopen(args->f_out, "wb");
                if (io->fp_out == NULL) {
-                       err_sys("Cannot open output file: %s", args->f_out);
+                       errmsg("cannot open output file: %s", args->f_out);
                }
        }
 }
@@ -613,14 +607,14 @@ static void
 close_io_handle(io_t io)
 {
        if (fclose(io->fp_pdd) != 0) {
-               err_sys("Cannot close PDD file.");
+               errmsg("cannot close PDD file");
        }
        if (fclose(io->fp_pfi) != 0) {
-               err_sys("Cannot close PFI file.");
+               errmsg("cannot close PFI file");
        }
        if (io->fp_out != stdout) {
                if (fclose(io->fp_out) != 0) {
-                       err_sys("Cannot close output file.");
+                       errmsg("cannot close output file");
                }
        }
 
@@ -629,8 +623,7 @@ close_io_handle(io_t io)
        io->fp_out = NULL;
 }
 
-int
-main(int argc, char *argv[])
+int main(int argc, char *argv[])
 {
        int rc = 0;
 
@@ -655,19 +648,21 @@ main(int argc, char *argv[])
        parse_opt(argc, argv, &args);
 
        if (strcmp(args.f_in_pfi, "") == 0) {
-               err_quit("No PFI input file specified!");
+               errmsg("no PFI input file specified");
+               exit(EXIT_FAILURE);
        }
 
        if (strcmp(args.f_in_pdd, "") == 0) {
-               err_quit("No PDD input file specified!");
+               errmsg("no PDD input file specified");
+               exit(EXIT_FAILURE);
        }
 
        open_io_handle(&args, &io);
 
-       info_msg("[ Creating RAW...");
+       printf("Creating RAW...");
        rc = create_raw(&io);
        if (rc != 0) {
-               err_msg("Creating RAW failed.");
+               errmsg("creating RAW failed");
                goto err;
        }