From b4b45994a9ba02d575625e3b1076c337be7d4861 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 13 Nov 2023 17:48:11 +0800 Subject: ubiattach: introduce disable_fm in UBI_IOCATT The ioctl UBI_IOCATT has been extended with disable_fm parameter after [1]. This parameter is used for disabling fastmap for target ubi device. If 'disable_fm' is set, ubi doesn't create new fastmap even the module param 'fm_autoconvert' is set, and existed old fastmap will be destroyed after attaching process. A simple test case in [2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=669d204469c46e91d99da24914130f78277a71d3 [2] https://bugzilla.kernel.org/show_bug.cgi?id=216278 Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubi-utils/ubiattach.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ubi-utils') diff --git a/ubi-utils/ubiattach.c b/ubi-utils/ubiattach.c index 09f85af..527a735 100644 --- a/ubi-utils/ubiattach.c +++ b/ubi-utils/ubiattach.c @@ -42,6 +42,7 @@ struct args { const char *node; const char *dev; int max_beb_per1024; + bool disable_fm; }; static struct args args = { @@ -51,6 +52,7 @@ static struct args args = { .node = NULL, .dev = NULL, .max_beb_per1024 = 0, + .disable_fm = false, }; static const char doc[] = PROGRAM_NAME " version " VERSION @@ -67,6 +69,8 @@ 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" "-h, --help print help message\n" "-V, --version print program version"; @@ -74,7 +78,7 @@ static const char usage[] = "Usage: " PROGRAM_NAME " []\n" "\t[-m ] [-d ] [-p ]\n" "\t[--mtdn=] [--devn=]\n" -"\t[--dev-path=]\n" +"\t[--dev-path=] [-f] [--disable-fastmap]\n" "\t[--max-beb-per1024=]\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 +97,7 @@ 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 = "help", .has_arg = 0, .flag = NULL, .val = 'h' }, { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' }, { NULL, 0, NULL, 0}, @@ -103,7 +108,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:fhV", long_options, NULL); if (key == -1) break; @@ -143,6 +148,10 @@ static int parse_opt(int argc, char * const argv[]) break; + case 'f': + args.disable_fm = true; + break; + case 'h': printf("%s\n\n", doc); printf("%s\n\n", usage); @@ -213,6 +222,7 @@ 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; err = ubi_attach(libubi, args.node, &req); if (err < 0) { -- cgit v1.2.3