From 9d8751b3f5c6358b6167c38899f1e41498d24a45 Mon Sep 17 00:00:00 2001 From: Richard Genoud Date: Wed, 22 Aug 2012 18:04:37 +0200 Subject: ubiattach: fail if kernel ignores max_beb_per1024 If the kernel doesn't know the max_beb_per1024 parameter in the attach ioctl, but the call still succeeded ubi_attach and ubi_attach_mtd will return 1 instead of 0. In this case, the ubiattach command will detach the device and fail with an error message. Signed-off-by: Richard Genoud Signed-off-by: Artem Bityutskiy --- ubi-utils/ubiattach.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ubi-utils/ubiattach.c') diff --git a/ubi-utils/ubiattach.c b/ubi-utils/ubiattach.c index 8dd0bf6..a7c62d0 100644 --- a/ubi-utils/ubiattach.c +++ b/ubi-utils/ubiattach.c @@ -216,12 +216,18 @@ int main(int argc, char * const argv[]) req.max_beb_per1024 = args.max_beb_per1024; err = ubi_attach(libubi, args.node, &req); - if (err) { + if (err < 0) { if (args.dev) sys_errmsg("cannot attach \"%s\"", args.dev); else sys_errmsg("cannot attach mtd%d", args.mtdn); goto out_libubi; + } else if (err == 1) { + /* The kernel did not support the 'max_beb_per1024' parameter */ + warnmsg("the --max-beb-per1024=%d parameter was ignored", args.max_beb_per1024); + normsg("the UBI kernel driver does not support does not allow changing the reserved PEBs count"); + normsg("the support was added in kernel version 3.7, probably you are running older kernel?"); + goto out_libubi; } /* Print some information about the new UBI device */ -- cgit v1.2.3