diff options
Diffstat (limited to 'ubi-utils')
-rw-r--r-- | ubi-utils/Makemodule.am | 4 | ||||
-rw-r--r-- | ubi-utils/mtdinfo.c | 14 | ||||
-rw-r--r-- | ubi-utils/ubiattach.c | 25 | ||||
-rw-r--r-- | ubi-utils/ubinfo.c | 1 | ||||
-rw-r--r-- | ubi-utils/ubiscan.c | 4 |
5 files changed, 36 insertions, 12 deletions
diff --git a/ubi-utils/Makemodule.am b/ubi-utils/Makemodule.am index 7183ec3..66c0238 100644 --- a/ubi-utils/Makemodule.am +++ b/ubi-utils/Makemodule.am @@ -40,16 +40,14 @@ ubirsvol_LDADD = libmtd.a libubi.a ubiblock_SOURCES = ubi-utils/ubiblock.c ubiblock_LDADD = libmtd.a libubi.a -if WITH_GETRANDOM ubihealthd_SOURCES = ubi-utils/ubihealthd.c ubihealthd_LDADD = libmtd.a libubi.a -endif sbin_PROGRAMS += \ ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \ ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock ubiscan -if WITH_GETRANDOM +if WITH_UBIHEALTHD sbin_PROGRAMS += ubihealthd endif diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c index 8bd0fc8..7dff0de 100644 --- a/ubi-utils/mtdinfo.c +++ b/ubi-utils/mtdinfo.c @@ -30,6 +30,7 @@ #include <string.h> #include <unistd.h> #include <mtd/mtd-user.h> +#include <mtd/ubi-media.h> #include <libubigen.h> #include <libmtd.h> @@ -54,7 +55,7 @@ static void display_help(void) printf( "%1$s version %2$s - a tool to print MTD information.\n" "\n" - "Usage: %1$s <MTD node file path> [--map | -M] [--ubi-info | -u]\n" + "Usage: %1$s <mtd device> [--map | -M] [--ubi-info | -u]\n" " %1$s --all [--ubi-info | -u]\n" " %1$s [--help | --version]\n" "\n" @@ -68,6 +69,8 @@ static void display_help(void) "-h, --help print help message\n" "-V, --version print program version\n" "\n" + "<mtd device> MTD device node or 'mtd:<name>'\n" + "\n" "Examples:\n" " %1$s /dev/mtd0 print information MTD device /dev/mtd0\n" " %1$s /dev/mtd0 -u print information MTD device /dev/mtd0\n" @@ -124,10 +127,13 @@ static int parse_opt(int argc, char * const argv[]) } } - if (optind == argc - 1) - args.node = argv[optind]; - else if (optind < argc) + if (optind == argc - 1) { + args.node = mtd_find_dev_node(argv[optind]); + if (!args.node) + return errmsg("Failed to find MTD device %s", argv[optind]); + } else if (optind < argc) { return errmsg("more then one MTD device specified (use -h for help)"); + } if (args.all && args.node) args.node = NULL; diff --git a/ubi-utils/ubiattach.c b/ubi-utils/ubiattach.c index 09f85af..e758dab 100644 --- a/ubi-utils/ubiattach.c +++ b/ubi-utils/ubiattach.c @@ -42,6 +42,8 @@ struct args { const char *node; const char *dev; int max_beb_per1024; + bool disable_fm; + bool need_resv_pool; }; static struct args args = { @@ -51,6 +53,8 @@ static struct args args = { .node = NULL, .dev = NULL, .max_beb_per1024 = 0, + .disable_fm = false, + .need_resv_pool = false, }; static const char doc[] = PROGRAM_NAME " version " VERSION @@ -67,6 +71,11 @@ static const char optionsstr[] = "-b, --max-beb-per1024 maximum expected bad block number per 1024 eraseblock.\n" " The default value is correct for most NAND devices.\n" " Allowed range is 0-768, 0 means the default kernel value.\n" +"-f, --disable-fastmap don't create new fastmap and do full scanning (existed\n" +" fastmap will be destroyed) for the given ubi device.\n" +"-r, --reserve-pool Slow down the frequency of updating fastmap by reserving\n" +" pebs for filling pool/wl_pool, which can prolong flash\n" +" service life.\n" "-h, --help print help message\n" "-V, --version print program version"; @@ -74,7 +83,7 @@ static const char usage[] = "Usage: " PROGRAM_NAME " [<UBI control device node file name>]\n" "\t[-m <MTD device number>] [-d <UBI device number>] [-p <path to device>]\n" "\t[--mtdn=<MTD device number>] [--devn=<UBI device number>]\n" -"\t[--dev-path=<path to device>]\n" +"\t[--dev-path=<path to device>] [-f] [--disable-fastmap] [-r] [--reserve-pool]\n" "\t[--max-beb-per1024=<maximum bad block number per 1024 blocks>]\n" "UBI control device defaults to " DEFAULT_CTRL_DEV " if not supplied.\n" "Example 1: " PROGRAM_NAME " -p /dev/mtd0 - attach /dev/mtd0 to UBI\n" @@ -93,6 +102,8 @@ static const struct option long_options[] = { { .name = "mtdn", .has_arg = 1, .flag = NULL, .val = 'm' }, { .name = "vid-hdr-offset", .has_arg = 1, .flag = NULL, .val = 'O' }, { .name = "max-beb-per1024", .has_arg = 1, .flag = NULL, .val = 'b' }, + { .name = "disable-fastmap", .has_arg = 0, .flag = NULL, .val = 'f' }, + { .name = "reserve-pool", .has_arg = 0, .flag = NULL, .val = 'r' }, { .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' }, { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' }, { NULL, 0, NULL, 0}, @@ -103,7 +114,7 @@ static int parse_opt(int argc, char * const argv[]) while (1) { int key, error = 0; - key = getopt_long(argc, argv, "p:m:d:O:b:hV", long_options, NULL); + key = getopt_long(argc, argv, "p:m:d:O:b:frhV", long_options, NULL); if (key == -1) break; @@ -143,6 +154,14 @@ static int parse_opt(int argc, char * const argv[]) break; + case 'f': + args.disable_fm = true; + break; + + case 'r': + args.need_resv_pool = true; + break; + case 'h': printf("%s\n\n", doc); printf("%s\n\n", usage); @@ -213,6 +232,8 @@ int main(int argc, char * const argv[]) req.vid_hdr_offset = args.vidoffs; req.mtd_dev_node = args.dev; req.max_beb_per1024 = args.max_beb_per1024; + req.disable_fm = args.disable_fm; + req.need_resv_pool = args.need_resv_pool; err = ubi_attach(libubi, args.node, &req); if (err < 0) { diff --git a/ubi-utils/ubinfo.c b/ubi-utils/ubinfo.c index 53519cc..6c5b19e 100644 --- a/ubi-utils/ubinfo.c +++ b/ubi-utils/ubinfo.c @@ -427,7 +427,6 @@ int main(int argc, char * const argv[]) if (err) goto out_libubi; -out: libubi_close(libubi); return 0; diff --git a/ubi-utils/ubiscan.c b/ubi-utils/ubiscan.c index e040bab..66af12a 100644 --- a/ubi-utils/ubiscan.c +++ b/ubi-utils/ubiscan.c @@ -264,10 +264,10 @@ int main(int argc, char * const argv[]) int from = (j == 0) ? 0 : args.bin_thresholds[j - 1]; if (j == args.nbins - 1) - printf("%-8d .. inf: %8d %8d %8llu %8d\n", + printf("%-8d .. inf: %8d %8d %8" PRIu64 " %8d\n", from, bins[j].cnt, bins[j].min, bins[j].mean, bins[j].max); else - printf("%-8d .. %8d: %8d %8d %8llu %8d\n", + printf("%-8d .. %8d: %8d %8d %8" PRIu64 " %8d\n", from, args.bin_thresholds[j] - 1, bins[j].cnt, bins[j].min, bins[j].mean, bins[j].max); } |