2 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
4 * This tool was based on:
5 * TP-Link WR941 V2 firmware checksum fixing tool.
6 * Copyright (C) 2008,2009 Wang Jian <lark@linux.net.cn>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
18 #include <unistd.h> /* for unlink() */
20 #include <getopt.h> /* for getopt() */
25 #include <arpa/inet.h>
26 #include <netinet/in.h>
30 #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
32 #define HEADER_VERSION_V1 0x01000000
33 #define HWID_TL_MR3020_V1 0x30200001
34 #define HWID_TL_MR3220_V1 0x32200001
35 #define HWID_TL_MR3220_V2 0x32200002
36 #define HWID_TL_MR3420_V1 0x34200001
37 #define HWID_TL_WA701N_V1 0x07010001
38 #define HWID_TL_WA7510N_V1 0x75100001
39 #define HWID_TL_WA801ND_V1 0x08010001
40 #define HWID_TL_WA901ND_V1 0x09010001
41 #define HWID_TL_WA901ND_V2 0x09010002
42 #define HWID_TL_WDR4900_V1 0x49000001
43 #define HWID_TL_WR703N_V1 0x07030101
44 #define HWID_TL_WR741ND_V1 0x07410001
45 #define HWID_TL_WR741ND_V4 0x07410004
46 #define HWID_TL_WR740N_V1 0x07400001
47 #define HWID_TL_WR740N_V3 0x07400003
48 #define HWID_TL_WR743ND_V1 0x07430001
49 #define HWID_TL_WR743ND_V2 0x07430002
50 #define HWID_TL_WR841N_V1_5 0x08410002
51 #define HWID_TL_WR841ND_V3 0x08410003
52 #define HWID_TL_WR841ND_V5 0x08410005
53 #define HWID_TL_WR841ND_V7 0x08410007
54 #define HWID_TL_WR941ND_V2 0x09410002
55 #define HWID_TL_WR941ND_V4 0x09410004
56 #define HWID_TL_WR1043ND_V1 0x10430001
57 #define HWID_TL_WR1041N_V2 0x10410002
58 #define HWID_TL_WR2543N_V1 0x25430001
63 char *file_name; /* name of the file */
64 uint32_t file_size; /* length of the file */
68 uint32_t version; /* header version */
71 uint32_t hw_id; /* hardware id */
72 uint32_t hw_rev; /* hardware revision */
74 uint8_t md5sum1[MD5SUM_LEN];
76 uint8_t md5sum2[MD5SUM_LEN];
78 uint32_t kernel_la; /* kernel load address */
79 uint32_t kernel_ep; /* kernel entry point */
80 uint32_t fw_length; /* total length of the firmware */
81 uint32_t kernel_ofs; /* kernel data offset */
82 uint32_t kernel_len; /* kernel data length */
83 uint32_t rootfs_ofs; /* rootfs data offset */
84 uint32_t rootfs_len; /* rootfs data length */
85 uint32_t boot_ofs; /* bootloader data offset */
86 uint32_t boot_len; /* bootloader data length */
91 } __attribute__ ((packed));
112 static char *progname;
113 static char *vendor = "TP-LINK Technologies";
114 static char *version = "ver. 1.0";
115 static char *fw_ver = "0.0.0";
117 static char *board_id;
118 static struct board_info *board;
119 static char *layout_id;
120 static struct flash_layout *layout;
121 static char *opt_hw_id;
122 static uint32_t hw_id;
123 static char *opt_hw_rev;
124 static uint32_t hw_rev;
125 static int fw_ver_lo;
126 static int fw_ver_mid;
127 static int fw_ver_hi;
128 static struct file_info kernel_info;
129 static uint32_t kernel_la = 0;
130 static uint32_t kernel_ep = 0;
131 static uint32_t kernel_len = 0;
132 static struct file_info rootfs_info;
133 static uint32_t rootfs_ofs = 0;
134 static uint32_t rootfs_align;
135 static struct file_info boot_info;
137 static int strip_padding;
138 static int add_jffs2_eof;
139 static unsigned char jffs2_eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};
141 static struct file_info inspect_info;
142 static int extract = 0;
144 char md5salt_normal[MD5SUM_LEN] = {
145 0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
146 0xdd, 0xf9, 0xe7, 0xf4, 0x0e, 0xae, 0x47, 0x38,
149 char md5salt_boot[MD5SUM_LEN] = {
150 0x8c, 0xef, 0x33, 0x5b, 0xd5, 0xc5, 0xce, 0xfa,
151 0xa7, 0x9c, 0x28, 0xda, 0xb2, 0xe9, 0x0f, 0x42,
154 static struct flash_layout layouts[] = {
157 .fw_max_len = 0x3c0000,
158 .kernel_la = 0x80060000,
159 .kernel_ep = 0x80060000,
160 .rootfs_ofs = 0x140000,
163 .fw_max_len = 0x3c0000,
164 .kernel_la = 0x80060000,
165 .kernel_ep = 0x80060000,
166 .rootfs_ofs = 0x100000,
169 .fw_max_len = 0x7c0000,
170 .kernel_la = 0x80060000,
171 .kernel_ep = 0x80060000,
172 .rootfs_ofs = 0x140000,
175 .fw_max_len = 0x7c0000,
176 .kernel_la = 0x80060000,
177 .kernel_ep = 0x80060000,
178 .rootfs_ofs = 0x100000,
181 .fw_max_len = 0xf80000,
182 .kernel_la = 0x00000000,
183 .kernel_ep = 0xc0000000,
184 .rootfs_ofs = 0x2a0000,
186 /* terminating entry */
190 static struct board_info boards[] = {
193 .hw_id = HWID_TL_MR3020_V1,
195 .layout_id = "4Mlzma",
198 .hw_id = HWID_TL_MR3220_V1,
203 .hw_id = HWID_TL_MR3220_V2,
205 .layout_id = "4Mlzma",
208 .hw_id = HWID_TL_MR3420_V1,
213 .hw_id = HWID_TL_WA701N_V1,
218 .hw_id = HWID_TL_WA7510N_V1,
222 .id = "TL-WA801NDv1",
223 .hw_id = HWID_TL_WA801ND_V1,
227 .id = "TL-WA901NDv1",
228 .hw_id = HWID_TL_WA901ND_V1,
232 .id = "TL-WA901NDv2",
233 .hw_id = HWID_TL_WA901ND_V2,
237 .id = "TL-WDR4900v1",
238 .hw_id = HWID_TL_WDR4900_V1,
240 .layout_id = "16Mppc",
242 .id = "TL-WR741NDv1",
243 .hw_id = HWID_TL_WR741ND_V1,
247 .id = "TL-WR741NDv4",
248 .hw_id = HWID_TL_WR741ND_V4,
250 .layout_id = "4Mlzma",
253 .hw_id = HWID_TL_WR740N_V1,
258 .hw_id = HWID_TL_WR740N_V3,
262 .id = "TL-WR743NDv1",
263 .hw_id = HWID_TL_WR743ND_V1,
267 .id = "TL-WR743NDv2",
268 .hw_id = HWID_TL_WR743ND_V2,
270 .layout_id = "4Mlzma",
272 .id = "TL-WR841Nv1.5",
273 .hw_id = HWID_TL_WR841N_V1_5,
277 .id = "TL-WR841NDv3",
278 .hw_id = HWID_TL_WR841ND_V3,
282 .id = "TL-WR841NDv5",
283 .hw_id = HWID_TL_WR841ND_V5,
287 .id = "TL-WR841NDv7",
288 .hw_id = HWID_TL_WR841ND_V7,
292 .id = "TL-WR941NDv2",
293 .hw_id = HWID_TL_WR941ND_V2,
297 .id = "TL-WR941NDv4",
298 .hw_id = HWID_TL_WR941ND_V4,
302 .id = "TL-WR1041Nv2",
303 .hw_id = HWID_TL_WR1041N_V2,
305 .layout_id = "4Mlzma",
307 .id = "TL-WR1043NDv1",
308 .hw_id = HWID_TL_WR1043ND_V1,
312 .id = "TL-WR2543Nv1",
313 .hw_id = HWID_TL_WR2543N_V1,
315 .layout_id = "8Mlzma",
318 .hw_id = HWID_TL_WR703N_V1,
320 .layout_id = "4Mlzma",
322 /* terminating entry */
329 #define ERR(fmt, ...) do { \
331 fprintf(stderr, "[%s] *** error: " fmt "\n", \
332 progname, ## __VA_ARGS__ ); \
335 #define ERRS(fmt, ...) do { \
338 fprintf(stderr, "[%s] *** error: " fmt "\n", \
339 progname, ## __VA_ARGS__, strerror(save)); \
342 #define DBG(fmt, ...) do { \
343 fprintf(stderr, "[%s] " fmt "\n", progname, ## __VA_ARGS__ ); \
346 static struct board_info *find_board(char *id)
348 struct board_info *ret;
349 struct board_info *board;
352 for (board = boards; board->id != NULL; board++){
353 if (strcasecmp(id, board->id) == 0) {
362 static struct board_info *find_board_by_hwid(uint32_t hw_id)
364 struct board_info *board;
366 for (board = boards; board->id != NULL; board++) {
367 if (hw_id == board->hw_id)
374 static struct flash_layout *find_layout(char *id)
376 struct flash_layout *ret;
377 struct flash_layout *l;
380 for (l = layouts; l->id != NULL; l++){
381 if (strcasecmp(id, l->id) == 0) {
390 static void usage(int status)
392 FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
393 struct board_info *board;
395 fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
399 " -B <board> create image for the board specified with <board>\n"
400 " -c use combined kernel image\n"
401 " -E <ep> overwrite kernel entry point with <ep> (hexval prefixed with 0x)\n"
402 " -L <la> overwrite kernel load address with <la> (hexval prefixed with 0x)\n"
403 " -H <hwid> use hardware id specified with <hwid>\n"
404 " -F <id> use flash layout specified with <id>\n"
405 " -k <file> read kernel image from the file <file>\n"
406 " -r <file> read rootfs image from the file <file>\n"
407 " -a <align> align the rootfs start on an <align> bytes boundary\n"
408 " -R <offset> overwrite rootfs offset with <offset> (hexval prefixed with 0x)\n"
409 " -o <file> write output to the file <file>\n"
410 " -s strip padding from the end of the image\n"
411 " -j add jffs2 end-of-filesystem markers\n"
412 " -N <vendor> set image vendor to <vendor>\n"
413 " -V <version> set image version to <version>\n"
414 " -v <version> set firmware version to <version>\n"
415 " -i <file> inspect given firmware file <file>\n"
416 " -x extract kernel and rootfs while inspecting (requires -i)\n"
417 " -h show this screen\n"
423 static int get_md5(char *data, int size, char *md5)
428 MD5_Update(&ctx, data, size);
429 MD5_Final(md5, &ctx);
432 static int get_file_stat(struct file_info *fdata)
437 if (fdata->file_name == NULL)
440 res = stat(fdata->file_name, &st);
442 ERRS("stat failed on %s", fdata->file_name);
446 fdata->file_size = st.st_size;
450 static int read_to_buf(struct file_info *fdata, char *buf)
453 int ret = EXIT_FAILURE;
455 f = fopen(fdata->file_name, "r");
457 ERRS("could not open \"%s\" for reading", fdata->file_name);
462 fread(buf, fdata->file_size, 1, f);
464 ERRS("unable to read from file \"%s\"", fdata->file_name);
476 static int check_options(void)
480 if (inspect_info.file_name) {
481 ret = get_file_stat(&inspect_info);
486 } else if (extract) {
487 ERR("no firmware for inspection specified");
491 if (board_id == NULL && opt_hw_id == NULL) {
492 ERR("either board or hardware id must be specified");
497 board = find_board(board_id);
499 ERR("unknown/unsupported board id \"%s\"", board_id);
502 if (layout_id == NULL)
503 layout_id = board->layout_id;
505 hw_id = board->hw_id;
506 hw_rev = board->hw_rev;
508 if (layout_id == NULL) {
509 ERR("flash layout is not specified");
512 hw_id = strtoul(opt_hw_id, NULL, 0);
515 hw_rev = strtoul(opt_hw_rev, NULL, 0);
520 layout = find_layout(layout_id);
521 if (layout == NULL) {
522 ERR("unknown flash layout \"%s\"", layout_id);
527 kernel_la = layout->kernel_la;
529 kernel_ep = layout->kernel_ep;
531 rootfs_ofs = layout->rootfs_ofs;
533 if (kernel_info.file_name == NULL) {
534 ERR("no kernel image specified");
538 ret = get_file_stat(&kernel_info);
542 kernel_len = kernel_info.file_size;
545 if (kernel_info.file_size >
546 layout->fw_max_len - sizeof(struct fw_header)) {
547 ERR("kernel image is too big");
551 if (rootfs_info.file_name == NULL) {
552 ERR("no rootfs image specified");
556 ret = get_file_stat(&rootfs_info);
561 kernel_len += sizeof(struct fw_header);
562 kernel_len = ALIGN(kernel_len, rootfs_align);
563 kernel_len -= sizeof(struct fw_header);
565 DBG("kernel length aligned to %u", kernel_len);
567 if (kernel_len + rootfs_info.file_size >
568 layout->fw_max_len - sizeof(struct fw_header)) {
569 ERR("images are too big");
573 if (kernel_info.file_size >
574 rootfs_ofs - sizeof(struct fw_header)) {
575 ERR("kernel image is too big");
579 if (rootfs_info.file_size >
580 (layout->fw_max_len - rootfs_ofs)) {
581 ERR("rootfs image is too big");
587 if (ofname == NULL) {
588 ERR("no output file specified");
592 ret = sscanf(fw_ver, "%d.%d.%d", &fw_ver_hi, &fw_ver_mid, &fw_ver_lo);
594 ERR("invalid firmware version '%s'", fw_ver);
601 static void fill_header(char *buf, int len)
603 struct fw_header *hdr = (struct fw_header *)buf;
605 memset(hdr, 0, sizeof(struct fw_header));
607 hdr->version = htonl(HEADER_VERSION_V1);
608 strncpy(hdr->vendor_name, vendor, sizeof(hdr->vendor_name));
609 strncpy(hdr->fw_version, version, sizeof(hdr->fw_version));
610 hdr->hw_id = htonl(hw_id);
611 hdr->hw_rev = htonl(hw_rev);
613 if (boot_info.file_size == 0)
614 memcpy(hdr->md5sum1, md5salt_normal, sizeof(hdr->md5sum1));
616 memcpy(hdr->md5sum1, md5salt_boot, sizeof(hdr->md5sum1));
618 hdr->kernel_la = htonl(kernel_la);
619 hdr->kernel_ep = htonl(kernel_ep);
620 hdr->fw_length = htonl(layout->fw_max_len);
621 hdr->kernel_ofs = htonl(sizeof(struct fw_header));
622 hdr->kernel_len = htonl(kernel_len);
624 hdr->rootfs_ofs = htonl(rootfs_ofs);
625 hdr->rootfs_len = htonl(rootfs_info.file_size);
628 hdr->ver_hi = htons(fw_ver_hi);
629 hdr->ver_mid = htons(fw_ver_mid);
630 hdr->ver_lo = htons(fw_ver_lo);
632 get_md5(buf, len, hdr->md5sum1);
635 static int pad_jffs2(char *buf, int currlen)
641 pad_mask = (64 * 1024);
642 while ((len < layout->fw_max_len) && (pad_mask != 0)) {
646 for (i = 10; i < 32; i++) {
652 len = ALIGN(len, mask);
654 for (i = 10; i < 32; i++) {
656 if ((len & (mask - 1)) == 0)
660 for (i = 0; i < sizeof(jffs2_eof_mark); i++)
661 buf[len + i] = jffs2_eof_mark[i];
663 len += sizeof(jffs2_eof_mark);
669 static int write_fw(char *data, int len)
672 int ret = EXIT_FAILURE;
674 f = fopen(ofname, "w");
676 ERRS("could not open \"%s\" for writing", ofname);
681 fwrite(data, len, 1, f);
683 ERRS("unable to write output file");
687 DBG("firmware file \"%s\" completed", ofname);
694 if (ret != EXIT_SUCCESS) {
701 static int build_fw(void)
706 int ret = EXIT_FAILURE;
709 buflen = layout->fw_max_len;
711 buf = malloc(buflen);
713 ERR("no memory for buffer\n");
717 memset(buf, 0xff, buflen);
718 p = buf + sizeof(struct fw_header);
719 ret = read_to_buf(&kernel_info, p);
723 writelen = sizeof(struct fw_header) + kernel_len;
729 p = buf + rootfs_ofs;
731 ret = read_to_buf(&rootfs_info, p);
736 writelen += rootfs_info.file_size;
738 writelen = rootfs_ofs + rootfs_info.file_size;
741 writelen = pad_jffs2(buf, writelen);
747 fill_header(buf, writelen);
748 ret = write_fw(buf, writelen);
760 /* Helper functions to inspect_fw() representing different output formats */
761 static inline void inspect_fw_pstr(char *label, char *str)
763 printf("%-23s: %s\n", label, str);
766 static inline void inspect_fw_phex(char *label, uint32_t val)
768 printf("%-23s: 0x%08x\n", label, val);
771 static inline void inspect_fw_phexpost(char *label,
772 uint32_t val, char *post)
774 printf("%-23s: 0x%08x (%s)\n", label, val, post);
777 static inline void inspect_fw_phexdef(char *label,
778 uint32_t val, uint32_t defval)
780 printf("%-23s: 0x%08x ", label, val);
783 printf("(== OpenWrt default)\n");
785 printf("(OpenWrt default: 0x%08x)\n", defval);
788 static inline void inspect_fw_phexexp(char *label,
789 uint32_t val, uint32_t expval)
791 printf("%-23s: 0x%08x ", label, val);
796 printf("(expected: 0x%08x)\n", expval);
799 static inline void inspect_fw_phexdec(char *label, uint32_t val)
801 printf("%-23s: 0x%08x / %8u bytes\n", label, val, val);
804 static inline void inspect_fw_phexdecdef(char *label,
805 uint32_t val, uint32_t defval)
807 printf("%-23s: 0x%08x / %8u bytes ", label, val, val);
810 printf("(== OpenWrt default)\n");
812 printf("(OpenWrt default: 0x%08x)\n", defval);
815 static inline void inspect_fw_pmd5sum(char *label, uint8_t *val, char *text)
819 printf("%-23s:", label);
820 for (i=0; i<MD5SUM_LEN; i++)
821 printf(" %02x", val[i]);
822 printf(" %s\n", text);
825 static int inspect_fw(void)
828 struct fw_header *hdr;
829 uint8_t md5sum[MD5SUM_LEN];
830 struct board_info *board;
831 int ret = EXIT_FAILURE;
833 buf = malloc(inspect_info.file_size);
835 ERR("no memory for buffer!\n");
839 ret = read_to_buf(&inspect_info, buf);
842 hdr = (struct fw_header *)buf;
844 inspect_fw_pstr("File name", inspect_info.file_name);
845 inspect_fw_phexdec("File size", inspect_info.file_size);
847 if (ntohl(hdr->version) != HEADER_VERSION_V1) {
848 ERR("file does not seem to have V1 header!\n");
852 inspect_fw_phexdec("Version 1 Header size", sizeof(struct fw_header));
854 if (ntohl(hdr->unk1) != 0)
855 inspect_fw_phexdec("Unknown value 1", hdr->unk1);
857 memcpy(md5sum, hdr->md5sum1, sizeof(md5sum));
858 if (ntohl(hdr->boot_len) == 0)
859 memcpy(hdr->md5sum1, md5salt_normal, sizeof(md5sum));
861 memcpy(hdr->md5sum1, md5salt_boot, sizeof(md5sum));
862 get_md5(buf, inspect_info.file_size, hdr->md5sum1);
864 if (memcmp(md5sum, hdr->md5sum1, sizeof(md5sum))) {
865 inspect_fw_pmd5sum("Header MD5Sum1", md5sum, "(*ERROR*)");
866 inspect_fw_pmd5sum(" --> expected", hdr->md5sum1, "");
868 inspect_fw_pmd5sum("Header MD5Sum1", md5sum, "(ok)");
870 if (ntohl(hdr->unk2) != 0)
871 inspect_fw_phexdec("Unknown value 2", hdr->unk2);
872 inspect_fw_pmd5sum("Header MD5Sum2", hdr->md5sum2,
873 "(purpose yet unknown, unchecked here)");
874 if (ntohl(hdr->unk3) != 0)
875 inspect_fw_phexdec("Unknown value 3", hdr->unk3);
879 inspect_fw_pstr("Vendor name", hdr->vendor_name);
880 inspect_fw_pstr("Firmware version", hdr->fw_version);
881 board = find_board_by_hwid(ntohl(hdr->hw_id));
883 layout = find_layout(board->layout_id);
884 inspect_fw_phexpost("Hardware ID",
885 ntohl(hdr->hw_id), board->id);
886 inspect_fw_phexexp("Hardware Revision",
887 ntohl(hdr->hw_rev), board->hw_rev);
889 inspect_fw_phexpost("Hardware ID",
890 ntohl(hdr->hw_id), "unknown");
891 inspect_fw_phex("Hardware Revision",
897 inspect_fw_phexdec("Kernel data offset",
898 ntohl(hdr->kernel_ofs));
899 inspect_fw_phexdec("Kernel data length",
900 ntohl(hdr->kernel_len));
902 inspect_fw_phexdef("Kernel load address",
903 ntohl(hdr->kernel_la),
904 layout ? layout->kernel_la : 0xffffffff);
905 inspect_fw_phexdef("Kernel entry point",
906 ntohl(hdr->kernel_ep),
907 layout ? layout->kernel_ep : 0xffffffff);
908 inspect_fw_phexdecdef("Rootfs data offset",
909 ntohl(hdr->rootfs_ofs),
910 layout ? layout->rootfs_ofs : 0xffffffff);
912 inspect_fw_phex("Kernel load address",
913 ntohl(hdr->kernel_la));
914 inspect_fw_phex("Kernel entry point",
915 ntohl(hdr->kernel_ep));
916 inspect_fw_phexdec("Rootfs data offset",
917 ntohl(hdr->rootfs_ofs));
919 inspect_fw_phexdec("Rootfs data length",
920 ntohl(hdr->rootfs_len));
921 inspect_fw_phexdec("Boot loader data offset",
922 ntohl(hdr->boot_ofs));
923 inspect_fw_phexdec("Boot loader data length",
924 ntohl(hdr->boot_len));
925 inspect_fw_phexdec("Total firmware length",
926 ntohl(hdr->fw_length));
934 filename = malloc(strlen(inspect_info.file_name) + 8);
935 sprintf(filename, "%s-kernel", inspect_info.file_name);
936 printf("Extracting kernel to \"%s\"...\n", filename);
937 fp = fopen(filename, "w");
939 if (!fwrite(buf + ntohl(hdr->kernel_ofs),
940 ntohl(hdr->kernel_len), 1, fp)) {
941 ERR("error in fwrite(): %s", strerror(errno));
945 ERR("error in fopen(): %s", strerror(errno));
949 filename = malloc(strlen(inspect_info.file_name) + 8);
950 sprintf(filename, "%s-rootfs", inspect_info.file_name);
951 printf("Extracting rootfs to \"%s\"...\n", filename);
952 fp = fopen(filename, "w");
954 if (!fwrite(buf + ntohl(hdr->rootfs_ofs),
955 ntohl(hdr->rootfs_len), 1, fp)) {
956 ERR("error in fwrite(): %s", strerror(errno));
960 ERR("error in fopen(): %s", strerror(errno));
971 int main(int argc, char *argv[])
973 int ret = EXIT_FAILURE;
978 progname = basename(argv[0]);
983 c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xhsjv:");
989 sscanf(optarg, "0x%x", &rootfs_align);
998 sscanf(optarg, "0x%x", &kernel_ep);
1004 opt_hw_rev = optarg;
1007 sscanf(optarg, "0x%x", &kernel_la);
1022 kernel_info.file_name = optarg;
1025 rootfs_info.file_name = optarg;
1028 sscanf(optarg, "0x%x", &rootfs_ofs);
1037 inspect_info.file_name = optarg;
1046 usage(EXIT_SUCCESS);
1049 usage(EXIT_FAILURE);
1054 ret = check_options();
1058 if (!inspect_info.file_name)