]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: standardize PROGRAM_NAME
authorMike Frysinger <vapier@gentoo.org>
Sun, 26 Sep 2010 18:48:51 +0000 (14:48 -0400)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 27 Sep 2010 06:31:10 +0000 (09:31 +0300)
Make sure all the utils define PROGRAM_NAME and do so at the start of
the file so that sub-headers may assume it exists.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
44 files changed:
compr_zlib.c
doc_loadbios.c
docfdisk.c
flash_info.c
flash_lock.c
flash_otp_dump.c
flash_otp_info.c
flash_otp_lock.c
flash_otp_write.c
flash_unlock.c
flashcp.c
ftl_check.c
ftl_format.c
jffs2dump.c
jffs2reader.c
mkfs.jffs2.c
mkfs.ubifs/hashtable/hashtable.c
mtd_debug.c
nanddump.c
nandtest.c
nandwrite.c
nftl_format.c
nftldump.c
recv_image.c
rfddump.c
rfdformat.c
serve_image.c
sumtool.c
ubi-utils/src/libscan.c
ubi-utils/src/libubi.c
ubi-utils/src/libubigen.c
ubi-utils/src/mtdinfo.c
ubi-utils/src/ubiattach.c
ubi-utils/src/ubicrc32.c
ubi-utils/src/ubidetach.c
ubi-utils/src/ubiformat.c
ubi-utils/src/ubimkvol.c
ubi-utils/src/ubinfo.c
ubi-utils/src/ubinize.c
ubi-utils/src/ubirename.c
ubi-utils/src/ubirmvol.c
ubi-utils/src/ubirsvol.c
ubi-utils/src/ubiupdatevol.c
ubi-utils/src/ubiutils-common.c

index 0564f161510e2cb6541c1677ffd95f73de099d8d..1f946285f04bb722bbe5d9e17404af6434ba482c 100644 (file)
@@ -32,6 +32,8 @@
  * under either the RHEPL or the GPL.
  */
 
+#define PROGRAM_NAME "compr_zlib"
+
 #include <stdint.h>
 #define crc32 __zlib_crc32
 #include <zlib.h>
index 0a11fd203f6753ee7804e603f79a4f97bd13ba37..b999c73e6fd43a2497b181e05a600091d8994a62 100644 (file)
@@ -1,3 +1,5 @@
+#define PROGRAM_NAME "doc_loadbios"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
index 56fffc4d6e40c63760d7404422524d4f6e7fab93..a76afb9b5a5fdb6f45a0471cbfb534dc89220bb2 100644 (file)
@@ -16,6 +16,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#define PROGRAM_NAME "docfdisk"
+
 #define _XOPEN_SOURCE 500 /* for pread/pwrite */
 #include <unistd.h>
 #include <stdlib.h>
@@ -158,7 +160,7 @@ int main(int argc, char **argv)
                                "Usage: %s <mtddevice> [<size1> [<size2> [<size3> [<size4]]]]\n"
                                "  Sizes are in device units (run with no sizes to show unitsize and current\n"
                                "  partitions).  Last size = 0 means go to end of device.\n",
-                               argv[0]);
+                               PROGRAM_NAME);
                return 1;
        }
 
index f5ed1c6ff78023f0e27803f717a981a7062eb981..ad7b30a9ef9d003c66551e27f0c85d2c0bdb0cff 100644 (file)
@@ -2,6 +2,8 @@
  * flash_info.c -- print info about a MTD device
  */
 
+#define PROGRAM_NAME "flash_info"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -19,7 +21,7 @@ int main(int argc,char *argv[])
 
        if (1 >= argc)
        {
-               fprintf(stderr,"Usage: flash_info device\n");
+               fprintf(stderr,"Usage: %s device\n", PROGRAM_NAME);
                return 16;
        }
 
index 37f2ad3156f8413ecb61813f33a41c10ed3b92b1..ef7523464c45a7462f83cd2642e956f6072e20de 100644 (file)
@@ -5,6 +5,8 @@
  *
  */
 
+#define PROGRAM_NAME "flash_lock"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -29,7 +31,7 @@ int main(int argc, char *argv[])
         */
        if(argc != 4)
        {
-               fprintf(stderr, "USAGE: %s <mtd device> <ofs in hex> <num of sectors in decimal or -1 for all sectors>\n", argv[0]);
+               fprintf(stderr, "USAGE: %s <mtd device> <ofs in hex> <num of sectors in decimal or -1 for all sectors>\n", PROGRAM_NAME);
                exit(1);
        }
        else if(strncmp(argv[1], "/dev/mtd", 8) != 0)
index a18130d24e670b3c1b6d2703bc2661f18c15962a..f0c0fb96764eb2268e8f6d512b5d5762e00d8daf 100644 (file)
@@ -2,6 +2,8 @@
  * flash_otp_dump.c -- display One-Time-Programm data
  */
 
+#define PROGRAM_NAME "flash_otp_dump"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -17,7 +19,7 @@ int main(int argc,char *argv[])
        unsigned char buf[16];
 
        if (argc != 3 || (strcmp(argv[1], "-f") && strcmp(argv[1], "-u"))) {
-               fprintf(stderr,"Usage: %s [ -f | -u ] <device>\n", argv[0]);
+               fprintf(stderr,"Usage: %s [ -f | -u ] <device>\n", PROGRAM_NAME);
                return EINVAL;
        }
 
index c9486ee54070b34f8ed5046f8b5cf10a66c4d872..206179761462f30812530eaf435e22df76f98104 100644 (file)
@@ -2,6 +2,8 @@
  * flash_otp_info.c -- print info about One-Time-Programm data
  */
 
+#define PROGRAM_NAME "flash_otp_info"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -16,7 +18,7 @@ int main(int argc,char *argv[])
        int fd, val, i, ret;
 
        if (argc != 3 || (strcmp(argv[1], "-f") && strcmp(argv[1], "-u"))) {
-               fprintf(stderr,"Usage: %s [ -f | -u ] <device>\n", argv[0]);
+               fprintf(stderr,"Usage: %s [ -f | -u ] <device>\n", PROGRAM_NAME);
                return EINVAL;
        }
 
index d0e06cdb7817e7b686355dd3c05cd442d9fd0ded..cc8759ed3d6d3824f5554f98c3d5ffd7fa4a231d 100644 (file)
@@ -2,6 +2,8 @@
  * flash_otp_lock.c -- lock area of One-Time-Program data
  */
 
+#define PROGRAM_NAME "flash_otp_lock"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -18,7 +20,7 @@ int main(int argc,char *argv[])
        char *p, buf[8];
 
        if (argc != 5 || strcmp(argv[1], "-u")) {
-               fprintf(stderr, "Usage: %s -u <device> <offset> <size>\n", argv[0]);
+               fprintf(stderr, "Usage: %s -u <device> <offset> <size>\n", PROGRAM_NAME);
                fprintf(stderr, "offset and size must match on OTP region boundaries\n");
                fprintf(stderr, "CAUTION! ONCE LOCKED, OTP REGIONS CAN'T BE UNLOCKED!\n");
                return EINVAL;
@@ -39,13 +41,13 @@ int main(int argc,char *argv[])
 
        offset = strtoul(argv[3], &p, 0);
        if (argv[3][0] == 0 || *p != 0) {
-               fprintf(stderr, "%s: bad offset value\n", argv[0]);
+               fprintf(stderr, "%s: bad offset value\n", PROGRAM_NAME);
                return ERANGE;
        }
 
        size = strtoul(argv[4], &p, 0);
        if (argv[4][0] == 0 || *p != 0) {
-               fprintf(stderr, "%s: bad size value\n", argv[0]);
+               fprintf(stderr, "%s: bad size value\n", PROGRAM_NAME);
                return ERANGE;
        }
 
index f01df514393885130a1b9d99873393d35fb57649..d407ebbf400e630dc00ee004ecb44be8af51b25d 100644 (file)
@@ -2,6 +2,8 @@
  * flash_otp_write.c -- write One-Time-Program data
  */
 
+#define PROGRAM_NAME "flash_otp_write"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -21,7 +23,7 @@ int main(int argc,char *argv[])
        char *p, buf[2048];
 
        if (argc != 4 || strcmp(argv[1], "-u")) {
-               fprintf(stderr, "Usage: %s -u <device> <offset>\n", argv[0]);
+               fprintf(stderr, "Usage: %s -u <device> <offset>\n", PROGRAM_NAME);
                fprintf(stderr, "the raw data to write should be provided on stdin\n");
                fprintf(stderr, "CAUTION! ONCE SET TO 0, OTP DATA BITS CAN'T BE ERASED!\n");
                return EINVAL;
@@ -47,7 +49,7 @@ int main(int argc,char *argv[])
 
        offset = strtoul(argv[3], &p, 0);
        if (argv[3][0] == 0 || *p != 0) {
-               fprintf(stderr, "%s: bad offset value\n", argv[0]);
+               fprintf(stderr, "%s: bad offset value\n", PROGRAM_NAME);
                return ERANGE;
        }
 
index 3969453bf5637946faf088e41f8b5e09e2948767..3d29a92fe701b8007a504db656248755a5d6abd3 100644 (file)
@@ -5,6 +5,8 @@
  *
  */
 
+#define PROGRAM_NAME "flash_unlock"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -28,7 +30,7 @@ int main(int argc, char *argv[])
         */
        if(argc < 2)
        {
-               fprintf(stderr, "USAGE: %s <mtd device> <offset in hex> <block count in decimal number>\n", argv[0]);
+               fprintf(stderr, "USAGE: %s <mtd device> <offset in hex> <block count in decimal number>\n", PROGRAM_NAME);
                exit(1);
        }
        else if(strncmp(argv[1], "/dev/mtd", 8) != 0)
index 877502218429ab0b1fbf11cd9e8fdc51f6d1c06b..d58c81bb6782e27bc9844cc4267840b3ef02c118 100644 (file)
--- a/flashcp.c
+++ b/flashcp.c
@@ -29,6 +29,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define PROGRAM_NAME "flashcp"
+
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
@@ -84,7 +86,7 @@ static void log_printf (int level,const char *fmt, ...)
        fflush (fp);
 }
 
-static void showusage (const char *progname,bool error)
+static void showusage(bool error)
 {
        int level = error ? LOG_ERROR : LOG_NORMAL;
 
@@ -92,15 +94,15 @@ static void showusage (const char *progname,bool error)
                        "\n"
                        "Flash Copy - Written by Abraham van der Merwe <abraham@2d3d.co.za>\n"
                        "\n"
-                       "usage: %s [ -v | --verbose ] <filename> <device>\n"
-                       "       %s -h | --help\n"
+                       "usage: %1$s [ -v | --verbose ] <filename> <device>\n"
+                       "       %1$s -h | --help\n"
                        "\n"
                        "   -h | --help      Show this help message\n"
                        "   -v | --verbose   Show progress reports\n"
                        "   <filename>       File which you want to copy to flash\n"
                        "   <device>         Flash device to write to (e.g. /dev/mtd0, /dev/mtd1, etc.)\n"
                        "\n",
-                       progname,progname);
+                       PROGRAM_NAME);
 
        exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
 }
@@ -165,7 +167,7 @@ static void cleanup (void)
 
 int main (int argc,char *argv[])
 {
-       const char *progname,*filename = NULL,*device = NULL;
+       const char *filename = NULL,*device = NULL;
        int i,flags = FLAG_NONE;
        ssize_t result;
        size_t size,written;
@@ -174,8 +176,6 @@ int main (int argc,char *argv[])
        struct stat filestat;
        unsigned char src[BUFSIZE],dest[BUFSIZE];
 
-       (progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]);
-
        /*********************
         * parse cmd-line
         *****************/
@@ -206,7 +206,7 @@ int main (int argc,char *argv[])
                                break;
                        default:
                                DEBUG("Unknown parameter: %s\n",argv[option_index]);
-                               showusage (progname,true);
+                               showusage(true);
                }
        }
        if (optind+2 == argc) {
@@ -219,8 +219,8 @@ int main (int argc,char *argv[])
                DEBUG("Got device: %s\n",device);
        }
 
-       if (flags & FLAG_HELP || progname == NULL || device == NULL)
-               showusage (progname,flags != FLAG_HELP);
+       if (flags & FLAG_HELP || device == NULL)
+               showusage(flags != FLAG_HELP);
 
        atexit (cleanup);
 
index 485eaa894b2e5134b1b8ba39a27982e47bdb76ba..5e75e6a3c1f9ec8a16f3b28ddc5df624ef946c07 100644 (file)
@@ -34,6 +34,8 @@
 
   ======================================================================*/
 
+#define PROGRAM_NAME "ftl_check"
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -178,9 +180,9 @@ static void check_partition(int fd)
 } /* format_partition */
 
 /* Show usage information */
-void showusage(char *pname)
+void showusage(void)
 {
-       fprintf(stderr, "usage: %s device\n", pname);
+       fprintf(stderr, "usage: %s device\n", PROGRAM_NAME);
 }
 
 /*====================================================================*/
@@ -200,7 +202,7 @@ int main(int argc, char *argv[])
                }
        }
        if (errflg || (optind != argc-1)) {
-               showusage(argv[0]);
+               showusage();
                exit(errflg > 0 ? 0 : EXIT_FAILURE);
        }
 
index ae00c994141d9a30bfbd498fc3116a507157df77..bd4203b8fb1d1b6e00e89d76f72729a4a935803c 100644 (file)
@@ -34,6 +34,8 @@
 
   ======================================================================*/
 
+#define PROGRAM_NAME "ftl_format"
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -308,7 +310,7 @@ int main(int argc, char *argv[])
        }
        if (errflg || (optind != argc-1)) {
                fprintf(stderr, "usage: %s [-q] [-i] [-s spare-blocks]"
-                               " [-r reserve-percent] [-b bootsize] device\n", argv[0]);
+                               " [-r reserve-percent] [-b bootsize] device\n", PROGRAM_NAME);
                exit(EXIT_FAILURE);
        }
 
index d282d9d6e0965792fff3e060f0f283fd9fe298b5..d093afcc9316d2ae144dd0b51542cf3e833f69aa 100644 (file)
@@ -14,6 +14,9 @@
  * Bug/ToDo:
  */
 
+#define PROGRAM_NAME "jffs2dump"
+#define VERSION "$Revision: 1.10 $"
+
 #include <errno.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -34,9 +37,6 @@
 #include <crc32.h>
 #include "summary.h"
 
-#define PROGRAM "jffs2dump"
-#define VERSION "$Revision: 1.10 $"
-
 #define PAD(x) (((x)+3)&~3)
 
 /* For outputting a byte-swapped version of the input image. */
@@ -52,7 +52,7 @@ char  *data;          // image data
 
 void display_help (void)
 {
-       printf("Usage: " PROGRAM " [OPTION]... INPUTFILE\n"
+       printf("Usage: %s [OPTION]... INPUTFILE\n"
               "Dump the contents of a binary JFFS2 image.\n\n"
               "     --help                   display this help and exit\n"
               "     --version                display version information and exit\n"
@@ -63,22 +63,24 @@ void display_help (void)
               " -r, --recalccrc              recalc name and data crc on endian conversion\n"
               " -d, --datsize=LEN            size of data chunks, when oob data in binary image (NAND only)\n"
               " -o, --oobsize=LEN            size of oob data chunk in binary image (NAND only)\n"
-              " -v, --verbose                verbose output\n");
+              " -v, --verbose                verbose output\n",
+              PROGRAM_NAME);
        exit(0);
 }
 
 void display_version (void)
 {
-       printf(PROGRAM " " VERSION "\n"
+       printf("%1$s " VERSION "\n"
                        "\n"
                        "Copyright (C) 2003 Thomas Gleixner \n"
                        "\n"
-                       PROGRAM " comes with NO WARRANTY\n"
+                       "%1$s comes with NO WARRANTY\n"
                        "to the extent permitted by law.\n"
                        "\n"
-                       "You may redistribute copies of " PROGRAM "\n"
+                       "You may redistribute copies of %1$s\n"
                        "under the terms of the GNU General Public Licence.\n"
-                       "See the file `COPYING' for more information.\n");
+                       "See the file `COPYING' for more information.\n",
+                       PROGRAM_NAME);
        exit(0);
 }
 
index 0ad7207fd0dcc9712d187c8c6d9adbcbd68c573c..0cdff195a18e0412a4710f7977de4e55cda2d2d8 100644 (file)
@@ -62,6 +62,7 @@ BUGS:
 - Doesn't check CRC checksums.
  */
 
+#define PROGRAM_NAME "jffs2reader"
 
 #include <errno.h>
 #include <stdint.h>
@@ -817,8 +818,8 @@ void lsdir(char *o, size_t size, char *path, int recurse)
 
        if (ino == 0 ||
                        (dd == NULL && ino == 0) || (dd != NULL && dd->type != DT_DIR)) {
-               fprintf(stderr, "jffs2reader: %s: No such file or directory\n",
-                               path);
+               fprintf(stderr, "%s: %s: No such file or directory\n",
+                               PROGRAM_NAME, path);
                exit(EXIT_FAILURE);
        }
 
@@ -888,7 +889,8 @@ int main(int argc, char **argv)
                                break;
                        default:
                                fprintf(stderr,
-                                               "Usage: jffs2reader <image> [-d|-f] < path > \n");
+                                               "Usage: %s <image> [-d|-f] < path >\n",
+                                               PROGRAM_NAME);
                                exit(EXIT_FAILURE);
                }
        }
index c83b725f1b1aa133d1e53d206f2f4298559cc16f..1abe09c2dbca2378abce91faf8e5947d04417215 100644 (file)
@@ -47,6 +47,8 @@
  *  -Erik, November 2002
  */
 
+#define PROGRAM_NAME "mkfs.jffs2"
+
 #define _GNU_SOURCE
 #include <sys/types.h>
 #include <stdio.h>
@@ -108,7 +110,6 @@ static int squash_uids = 0;
 static int squash_perms = 0;
 static int fake_times = 0;
 int target_endian = __BYTE_ORDER;
-static const char *const app_name = "mkfs.jffs2";
 static const char *const memory_exhausted = "memory exhausted";
 
 uint32_t find_hardlink(struct filesystem_entry *e)
@@ -141,7 +142,7 @@ uint32_t find_hardlink(struct filesystem_entry *e)
 static void verror_msg(const char *s, va_list p)
 {
        fflush(stdout);
-       fprintf(stderr, "%s: ", app_name);
+       fprintf(stderr, "%s: ", PROGRAM_NAME);
        vfprintf(stderr, s, p);
 }
 static void error_msg(const char *s, ...)
@@ -247,7 +248,7 @@ extern char *xreadlink(const char *path)
                buf = xrealloc(buf, bufsize += GROWBY);
                readsize = readlink(path, buf, bufsize); /* 1st try */
                if (readsize == -1) {
-                       perror_msg("%s:%s", app_name, path);
+                       perror_msg("%s:%s", PROGRAM_NAME, path);
                        return NULL;
                }
        }
index b751c62ee621674ce5aec6ecf5632f9e5d734825..8aa273c27656bb55a5acad87fb33d4d389eb2130 100644 (file)
@@ -1,5 +1,7 @@
 /* Copyright (C) 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
 
+#define PROGRAM_NAME "hashtable"
+
 #include "common.h"
 #include "hashtable.h"
 #include "hashtable_private.h"
index 928cb5a70c2b094d567fe7b1bf9fd3f58992fe32..b82dabe47adafe00ab3fb59ea8f988a4e1014e38 100644 (file)
@@ -27,6 +27,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define PROGRAM_NAME "mtd_debug"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -347,17 +349,14 @@ int showinfo (int fd)
        return (0);
 }
 
-void showusage (const char *progname)
+void showusage(void)
 {
        fprintf (stderr,
-                       "usage: %s info <device>\n"
-                       "       %s read <device> <offset> <len> <dest-filename>\n"
-                       "       %s write <device> <offset> <len> <source-filename>\n"
-                       "       %s erase <device> <offset> <len>\n",
-                       progname,
-                       progname,
-                       progname,
-                       progname);
+                       "usage: %1$s info <device>\n"
+                       "       %1$s read <device> <offset> <len> <dest-filename>\n"
+                       "       %1$s write <device> <offset> <len> <source-filename>\n"
+                       "       %1$s erase <device> <offset> <len>\n",
+                       PROGRAM_NAME);
        exit (1);
 }
 
@@ -368,10 +367,8 @@ void showusage (const char *progname)
 
 int main (int argc,char *argv[])
 {
-       const char *progname;
        int err = 0,fd,option = OPT_INFO;
        int open_flag;
-       (progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]);
 
        /* parse command-line options */
        if (argc == 3 && !strcmp (argv[1],"info"))
@@ -383,7 +380,7 @@ int main (int argc,char *argv[])
        else if (argc == 5 && !strcmp (argv[1],"erase"))
                option = OPT_ERASE;
        else
-               showusage (progname);
+               showusage();
 
        /* open device */
        open_flag = (option==OPT_INFO || option==OPT_READ) ? O_RDONLY : O_RDWR;
index 709b2dbc2c352e679d19d8e418449f0cf62a83d6..358993182de354ad05da993b7eed2cd373c4f722 100644 (file)
@@ -13,6 +13,9 @@
  *   chips contained in DoC devices.
  */
 
+#define PROGRAM_NAME "nanddump"
+#define VERSION "$Revision: 1.29 $"
+
 #define _GNU_SOURCE
 #include <ctype.h>
 #include <errno.h>
@@ -30,9 +33,6 @@
 #include <asm/types.h>
 #include <mtd/mtd-user.h>
 
-#define PROGRAM "nanddump"
-#define VERSION "$Revision: 1.29 $"
-
 static struct nand_oobinfo none_oobinfo = {
        .useecc = MTD_NANDECC_OFF,
 };
@@ -40,7 +40,7 @@ static struct nand_oobinfo none_oobinfo = {
 static void display_help (void)
 {
        printf(
-"Usage: nanddump [OPTIONS] MTD-device\n"
+"Usage: %s [OPTIONS] MTD-device\n"
 "Dumps the contents of a nand mtd partition.\n"
 "\n"
 "           --help               Display this help and exit\n"
@@ -55,21 +55,22 @@ static void display_help (void)
 "-b         --omitbad            Omit bad blocks from the dump\n"
 "-p         --prettyprint        Print nice (hexdump)\n"
 "-q         --quiet              Don't display progress and status messages\n"
-"-s addr    --startaddress=addr  Start address\n"
-       );
+"-s addr    --startaddress=addr  Start address\n",
+       PROGRAM_NAME);
        exit(EXIT_SUCCESS);
 }
 
 static void display_version (void)
 {
-       printf(PROGRAM " " VERSION "\n"
+       printf("%1$s " VERSION "\n"
                        "\n"
-                       PROGRAM " comes with NO WARRANTY\n"
+                       "%1$s comes with NO WARRANTY\n"
                        "to the extent permitted by law.\n"
                        "\n"
-                       "You may redistribute copies of " PROGRAM "\n"
+                       "You may redistribute copies of %1$s\n"
                        "under the terms of the GNU General Public Licence.\n"
-                       "See the file `COPYING' for more information.\n");
+                       "See the file `COPYING' for more information.\n",
+                       PROGRAM_NAME);
        exit(EXIT_SUCCESS);
 }
 
index 4d90159f0bd18230681dbbebd7a5a29b0f21ae20..93f01ca1a7a04641441a89102e521a8bc69d92c6 100644 (file)
@@ -1,3 +1,5 @@
+#define PROGRAM_NAME "nandtest"
+
 #define _GNU_SOURCE
 #include <ctype.h>
 #include <errno.h>
 
 void usage(void)
 {
-       fprintf(stderr, "usage: nandtest [OPTIONS] <device>\n\n"
+       fprintf(stderr, "usage: %s [OPTIONS] <device>\n\n"
                "  -h, --help           Display this help output\n"
                "  -m, --markbad        Mark blocks bad if they appear so\n"
                "  -s, --seed           Supply random seed\n"
                "  -p, --passes         Number of passes\n"
                "  -o, --offset         Start offset on flash\n"
                "  -l, --length         Length of flash to test\n"
-               "  -k, --keep           Restore existing contents after test\n");
+               "  -k, --keep           Restore existing contents after test\n",
+               PROGRAM_NAME);
        exit(1);
 }
 
index 9eb200430d55dd2c503d4aee551e58bc058c7488..3520c629922fb685a3798f4c321179c8ce8e0ede 100644 (file)
@@ -19,6 +19,9 @@
  * Bug/ToDo:
  */
 
+#define PROGRAM_NAME "nandwrite"
+#define VERSION "$Revision: 1.32 $"
+
 #define _GNU_SOURCE
 #include <ctype.h>
 #include <errno.h>
@@ -39,9 +42,6 @@
 #include <asm/types.h>
 #include "mtd/mtd-user.h"
 
-#define PROGRAM "nandwrite"
-#define VERSION "$Revision: 1.32 $"
-
 #define MAX_PAGE_SIZE  4096
 #define MAX_OOB_SIZE   128
 
@@ -94,16 +94,17 @@ static void display_help (void)
 
 static void display_version (void)
 {
-       printf(PROGRAM " " VERSION "\n"
+       printf("%1$s " VERSION "\n"
                        "\n"
                        "Copyright (C) 2003 Thomas Gleixner \n"
                        "\n"
-                       PROGRAM " comes with NO WARRANTY\n"
+                       "%1$s comes with NO WARRANTY\n"
                        "to the extent permitted by law.\n"
                        "\n"
-                       "You may redistribute copies of " PROGRAM "\n"
+                       "You may redistribute copies of %1$s\n"
                        "under the terms of the GNU General Public Licence.\n"
-                       "See the file `COPYING' for more information.\n");
+                       "See the file `COPYING' for more information.\n",
+                       PROGRAM_NAME);
        exit (EXIT_SUCCESS);
 }
 
index 167098a6c7cb1507ef9833c72a0b36f20c660492..1fc3b36243d2a75e1612f94050530c1e60006c62 100644 (file)
@@ -20,6 +20,8 @@
  *     2. test, test, and test !!!
  */
 
+#define PROGRAM_NAME "nftl_format"
+
 #define _XOPEN_SOURCE 500 /* for pread/pwrite */
 #include <unistd.h>
 #include <stdlib.h>
@@ -171,7 +173,7 @@ static int checkbbt(void)
        int i, addr;
 
        if (pread(fd, bbt, 512, 0x800) < 0) {
-               printf("nftl_format: failed to read BBT, errno=%d\n", errno);
+               printf("%s: failed to read BBT, errno=%d\n", PROGRAM_NAME, errno);
                return (-1);
        }
 
@@ -189,7 +191,7 @@ static int checkbbt(void)
 
 void usage(int rc)
 {
-       fprintf(stderr, "Usage: nftl_format [-ib] <mtddevice> [<start offset> [<size>]]\n");
+       fprintf(stderr, "Usage: %s [-ib] <mtddevice> [<start offset> [<size>]]\n", PROGRAM_NAME);
        exit(rc);
 }
 
index 6d72acd7bef1dc1eb6e59040d3471c35f82a9976..90ea072581ce5572094b1ace1f7b36fd53e0a50b 100644 (file)
@@ -20,6 +20,8 @@
  *     2. test, test, and test !!!
  */
 
+#define PROGRAM_NAME "nftldump"
+
 #define _XOPEN_SOURCE 500 /* For pread */
 
 #include <unistd.h>
@@ -249,7 +251,7 @@ static void dump_virtual_units(void)
 int main(int argc, char **argv)
 {
        if (argc < 2) {
-               printf("Usage: %s <device> [<outfile>]\n", argv[0]);
+               printf("Usage: %s <device> [<outfile>]\n", PROGRAM_NAME);
                exit(1);
        }
        fd = open(argv[1], O_RDONLY);
index 6d27f3bdfccc93eaae6dbf85ac92f301913211c7..fb8e8b3259a52c40d00748a221c2f8df5350072e 100644 (file)
@@ -1,4 +1,5 @@
 
+#define PROGRAM_NAME "recv_image"
 #define _XOPEN_SOURCE 500
 
 #include <errno.h>
@@ -63,7 +64,7 @@ int main(int argc, char **argv)
 
        if (argc != 4) {
                fprintf(stderr, "usage: %s <host> <port> <mtddev>\n",
-                       (strrchr(argv[0], '/')?:argv[0]-1)+1);
+                       PROGRAM_NAME);
                exit(1);
        }
        /* Open the device */
index 73b0ecab81493725dc15ca7fa323c0892d19013f..1934d93754dd608f4d6990ed0acc5595a3019d0a 100644 (file)
--- a/rfddump.c
+++ b/rfddump.c
@@ -9,6 +9,9 @@
  *  (at your option) any later version.
  */
 
+#define PROGRAM_NAME "rfddump"
+#define VERSION "$Revision 1.0 $"
+
 #define _XOPEN_SOURCE 500 /* For pread */
 
 #include <stdio.h>
@@ -51,27 +54,26 @@ struct rfd {
        int verbose;
 };
 
-#define PROGRAM "rfddump"
-#define VERSION "$Revision 1.0 $"
-
 void display_help(void)
 {
-       printf("Usage: " PROGRAM " [OPTIONS] MTD-device filename\n"
+       printf("Usage: %s [OPTIONS] MTD-device filename\n"
                        "Dumps the contents of a resident flash disk\n"
                        "\n"
                        "-h         --help               display this help and exit\n"
                        "-V         --version            output version information and exit\n"
                        "-v         --verbose           Be verbose\n"
-                       "-b size    --blocksize          Block size (defaults to erase unit)\n");
+                       "-b size    --blocksize          Block size (defaults to erase unit)\n",
+                       PROGRAM_NAME);
        exit(0);
 }
 
 void display_version(void)
 {
-       printf(PROGRAM " " VERSION "\n"
+       printf("%s " VERSION "\n"
                        "\n"
                        "This is free software; see the source for copying conditions.  There is NO\n"
-                       "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+                       "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
+                       PROGRAM_NAME);
 
        exit(0);
 }
@@ -248,13 +250,13 @@ int main(int argc, char *argv[])
 
        rfd.header = malloc(rfd.header_size);
        if (!rfd.header) {
-               perror(PROGRAM);
+               perror(PROGRAM_NAME);
                close(fd);
                return 2;
        }
        rfd.sector_map = malloc(rfd.sector_count * sizeof(int));
        if (!rfd.sector_map) {
-               perror(PROGRAM);
+               perror(PROGRAM_NAME);
                close(fd);
                free(rfd.sector_map);
                return 2;
index d2637a1cb853eb5c105c45a85baef515d29e8c87..17d9d2d4099e0aa4e1183360c0a618fbee8cc3aa 100644 (file)
@@ -12,6 +12,9 @@
  * the beginning of each block.
  */
 
+#define PROGRAM_NAME "rfdformat"
+#define VERSION "$Revision 1.0 $"
+
 #define _XOPEN_SOURCE 500 /* For pread/pwrite */
 
 #include <stdio.h>
 #include <mtd/mtd-user.h>
 #include <linux/types.h>
 
-#define PROGRAM "rfdformat"
-#define VERSION "$Revision 1.0 $"
-
 void display_help(void)
 {
-       printf("Usage: " PROGRAM " [OPTIONS] MTD-device\n"
+       printf("Usage: %s [OPTIONS] MTD-device\n"
                        "Formats NOR flash for resident flash disk\n"
                        "\n"
                        "-h         --help               display this help and exit\n"
-                       "-V         --version            output version information and exit\n");
+                       "-V         --version            output version information and exit\n",
+                       PROGRAM_NAME);
        exit(0);
 }
 
 void display_version(void)
 {
-       printf(PROGRAM " " VERSION "\n"
+       printf("%s " VERSION "\n"
                        "\n"
                        "This is free software; see the source for copying conditions.  There is NO\n"
-                       "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+                       "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
+                       PROGRAM_NAME);
 
        exit(0);
 }
index 4b5dba9f7f85e82f3f5022eea807e5ae640ce72f..f8f28a10184578215c903f26c4fa1293e4c1331a 100644 (file)
@@ -1,3 +1,4 @@
+#define PROGRAM_NAME "serve_image"
 #define _POSIX_C_SOURCE 199309
 
 #include <time.h>
@@ -59,7 +60,7 @@ int main(int argc, char **argv)
        }
        if (argc != 5) {
                fprintf(stderr, "usage: %s <host> <port> <image> <erasesize> [<tx_rate>]\n",
-                       (strrchr(argv[0], '/')?:argv[0]-1)+1);
+                       PROGRAM_NAME);
                exit(1);
        }
        pkt_delay = (sizeof(pktbuf) * 1000000) / tx_rate;
index 2e2098c1a7710ba7afb7cc72de5763e08717478e..d0e2a7b78b69b47ccd3fc7fa59f88aa5c401c226 100644 (file)
--- a/sumtool.c
+++ b/sumtool.c
@@ -26,6 +26,8 @@
  *
  */
 
+#define PROGRAM_NAME "sumtool"
+
 #include <errno.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -49,8 +51,6 @@
 
 #define PAD(x) (((x)+3)&~3)
 
-static const char *const app_name = "sumtool";
-
 static struct jffs2_summary *sum_collected = NULL;
 
 static int verbose = 0;
@@ -122,7 +122,7 @@ static unsigned char ffbuf[16] = {
 static void verror_msg(const char *s, va_list p)
 {
        fflush(stdout);
-       fprintf(stderr, "%s: ", app_name);
+       fprintf(stderr, "%s: ", PROGRAM_NAME);
        vfprintf(stderr, s, p);
 }
 
index 6c6990f0773f2fe3ab061605471d69527c889d7f..dc47a898896fc82415b6f445975c6ba7b7276178 100644 (file)
@@ -20,6 +20,8 @@
  * UBI scanning library.
  */
 
+#define PROGRAM_NAME "libscan"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdint.h>
@@ -35,8 +37,6 @@
 #include <crc32.h>
 #include "common.h"
 
-#define PROGRAM_NAME "libscan"
-
 static int all_ff(const void *buf, int len)
 {
        int i;
index 2eab3bae4e58643e4dcc74e4bd1001e7995de0c5..4d5f316118670c66633790819830e6d590d510ed 100644 (file)
@@ -20,6 +20,8 @@
  * UBI (Unsorted Block Images) library.
  */
 
+#define PROGRAM_NAME "libubi"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,8 +36,6 @@
 #include "libubi_int.h"
 #include "common.h"
 
-#define PROGRAM_NAME "libubi"
-
 /**
  * mkpath - compose full path from 2 given components.
  * @path: the first component
index 710aa974dfea3025b41610d5625abb967bf2327e..9eaa7f56c625afc22b5ed35fcfa4d42e7b0c1219 100644 (file)
@@ -24,6 +24,8 @@
  *          Artem Bityutskiy
  */
 
+#define PROGRAM_NAME "libubigen"
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <unistd.h>
@@ -35,8 +37,6 @@
 #include <crc32.h>
 #include "common.h"
 
-#define PROGRAM_NAME "libubigen"
-
 void ubigen_info_init(struct ubigen_info *ui, int peb_size, int min_io_size,
                      int subpage_size, int vid_hdr_offs, int ubi_ver,
                      uint32_t image_seq)
index b39ed5f7ca59cd1f08c3c7f8640a78ab08a2999a..a2d7547b8d763564bc3d58309fd0bbad5f7d98a3 100644 (file)
@@ -21,6 +21,9 @@
  * Author: Artem Bityutskiy
  */
 
+#define PROGRAM_VERSION "1.0"
+#define PROGRAM_NAME    "mtdinfo"
+
 #include <stdint.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -33,9 +36,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME    "mtdinfo"
-
 /* The variables below are set by command line arguments */
 struct args {
        int mtdn;
index 5a7d2cf1b25997a56cfdaaa285b2078ece2fe56b..51a0cfb0d2ee03e88cc6f7761e1cee4f088db893 100644 (file)
@@ -21,6 +21,9 @@
  * Author: Artem Bityutskiy
  */
 
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME    "ubiattach"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <getopt.h>
@@ -31,8 +34,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.1"
-#define PROGRAM_NAME    "ubiattach"
 #define DEFAULT_CTRL_DEV "/dev/ubi_ctrl"
 
 /* The variables below are set by command line arguments */
index becd6049bcf9dc125b94d22332764391696857c1..ec108584a40e5f058fddbf6a158b6ca7ff7555e6 100644 (file)
@@ -22,6 +22,9 @@
  * Author: Oliver Lohmann
  */
 
+#define PROGRAM_VERSION "1.0"
+#define PROGRAM_NAME    "ubicrc32"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -34,9 +37,6 @@
 
 #define BUFSIZE 4096
 
-#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME    "ubicrc32"
-
 static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
                         " - a tool to calculate CRC32 with UBI start value (0xFFFFFFFF)";
 
index e0bc0505bf29babec0b785af1debf182cc5460b9..59e478bf3380feb87de640e2ff93c6d3949d86e2 100644 (file)
@@ -21,6 +21,9 @@
  * Author: Artem Bityutskiy
  */
 
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME    "ubidetach"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <getopt.h>
@@ -30,8 +33,6 @@
 #include <libubi.h>
 #include "common.h"
 
-#define PROGRAM_VERSION "1.1"
-#define PROGRAM_NAME    "ubidetach"
 #define DEFAULT_CTRL_DEV "/dev/ubi_ctrl"
 
 /* The variables below are set by command line arguments */
index 8559f61a22b6447499707fb7294ce6284644aa92..7cea8a95b005f07f0b0407c105a250ce2b33bbe8 100644 (file)
@@ -29,6 +29,9 @@
  */
 #define MAX_CONSECUTIVE_BAD_BLOCKS 4
 
+#define PROGRAM_VERSION "1.5"
+#define PROGRAM_NAME    "ubiformat"
+
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdint.h>
@@ -45,9 +48,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.5"
-#define PROGRAM_NAME    "ubiformat"
-
 /* The variables below are set by command line arguments */
 struct args {
        unsigned int yes:1;
index c867c441a852305c9f0a983ea9f2cbd4b7bccc3b..cc8cd558348140763c12fe7ee63267c718f68028 100644 (file)
@@ -23,6 +23,9 @@
  *          Frank Haverkamp <haver@vnet.ibm.com>
  */
 
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME    "ubimkvol"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <getopt.h>
@@ -33,9 +36,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.1"
-#define PROGRAM_NAME    "ubimkvol"
-
 /* The variables below are set by command line arguments */
 struct args {
        int vol_id;
index cecab43fccffa8b46383e22a1ad334326a469de8..44f6fb025b433957c86e8f3e9108418656619340 100644 (file)
@@ -21,6 +21,9 @@
  * Author: Artem Bityutskiy
  */
 
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME    "ubinfo"
+
 #include <stdint.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -31,9 +34,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.1"
-#define PROGRAM_NAME    "ubinfo"
-
 /* The variables below are set by command line arguments */
 struct args {
        int devn;
index 2ff4e29c42159fe3bd46724bff3f1130f0704566..5cee5aa62f191cf59f04c092685fc338c6319a1d 100644 (file)
@@ -24,6 +24,9 @@
  *          Oliver Lohmann
  */
 
+#define PROGRAM_VERSION "1.2"
+#define PROGRAM_NAME    "ubinize"
+
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <getopt.h>
@@ -36,9 +39,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.2"
-#define PROGRAM_NAME    "ubinize"
-
 static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
 " - a tool to generate UBI images. An UBI image may contain one or more UBI "
 "volumes which have to be defined in the input configuration ini-file. The "
index 00c53e4fd95b498ea0213bcbbf6864cc9f8153bf..295bfc7ae1236b999113751a2a0c199519ea9db3 100644 (file)
@@ -21,6 +21,9 @@
  * Author: Richard Titmuss
  */
 
+#define PROGRAM_VERSION "1.0"
+#define PROGRAM_NAME    "ubirename"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <getopt.h>
@@ -30,9 +33,6 @@
 #include <libubi.h>
 #include "common.h"
 
-#define PROGRAM_VERSION "1.0"
-#define PROGRAM_NAME    "ubirename"
-
 static const char *usage =
 "Usage: " PROGRAM_NAME " <UBI device node file name> [<old name> <new name>|...]\n\n"
 "Example: " PROGRAM_NAME "/dev/ubi0 A B C D - rename volume A to B, and C to D\n\n"
index 4fbe73a27aac9311c70f7e66e2c32544b01c0557..334bb3830d211524c81ce2ecf90f69e0f9a45675 100644 (file)
@@ -23,6 +23,9 @@
  *          Frank Haverkamp <haver@vnet.ibm.com>
  */
 
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME    "ubirmvol"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <getopt.h>
@@ -32,9 +35,6 @@
 #include <libubi.h>
 #include "common.h"
 
-#define PROGRAM_VERSION "1.1"
-#define PROGRAM_NAME    "ubirmvol"
-
 /* The variables below are set by command line arguments */
 struct args {
        int vol_id;
index 683e606e82c5801abc2768f4d3a5cac643512966..a622ea6200612a96763665c1016c21dba46864e4 100644 (file)
@@ -23,6 +23,9 @@
  *          Frank Haverkamp <haver@vnet.ibm.com>
  */
 
+#define PROGRAM_VERSION "1.1"
+#define PROGRAM_NAME    "ubirsvol"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <getopt.h>
@@ -33,9 +36,6 @@
 #include "common.h"
 #include "ubiutils-common.h"
 
-#define PROGRAM_VERSION "1.1"
-#define PROGRAM_NAME    "ubirsvol"
-
 /* The variables below are set by command line arguments */
 struct args {
        int vol_id;
index b314b58adbcc183fc6d8b2f63f6b77cdd09cb784..4521138194adfab1104daf81fd44d2347d5f2dcf 100644 (file)
@@ -24,6 +24,9 @@
  *          Artem Bityutskiy
  */
 
+#define PROGRAM_VERSION "1.2"
+#define PROGRAM_NAME    "ubiupdatevol"
+
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdint.h>
@@ -37,9 +40,6 @@
 #include <libubi.h>
 #include "common.h"
 
-#define PROGRAM_VERSION "1.2"
-#define PROGRAM_NAME    "ubiupdatevol"
-
 struct args {
        int truncate;
        const char *node;
index da5156dd94ce0f4462ee6648a6c9338df7c673e9..6609a6b4649d0d4b24fa1b92ebccea5fb967cfaf 100644 (file)
@@ -23,6 +23,8 @@
  *          Adrian Hunter
  */
 
+#define PROGRAM_NAME "ubiutils"
+
 #include <sys/time.h>
 #include <sys/types.h>
 #include <stdio.h>