[PATCH MTD-UTILS 5/5] ubiattach: introduce max_beb_per1024 in UBI_IOCATT

Artem Bityutskiy dedekind1 at gmail.com
Wed Aug 22 07:30:15 EDT 2012


On Wed, 2012-08-22 at 13:17 +0200, Richard Genoud wrote:
> 2012/8/22 Artem Bityutskiy <dedekind1 at gmail.com>:
> > If the feature is not supported (the kernel is old), the tool will just
> > return success and the kernel will just ignore max-beb-per1024, which is
> > not very nice.
> >
> > It would be better if ubiattach complained like this instead:
> >
> > ubiattach error: your UBI driver does not allow changing the reserved
> >                  PEBs count, probably you run old kernel? The support
> >                  was added in kernel version 3.7.
> yes, you're right, I'll change that.
> Thanks,

I see 2 ways.

1. Add a 'get device property' ioctl, similar to the 'set volume
property' ioctl we have. And use this ioctl to query the current bad
PEBs limit.

2. Just call the 'attach' ioctl with an insane max_beb_per1024 value
(say, -1) first. If it succeeded, than the driver does not support
max_beb_per1024 at all, and you may exit with a warning that you have
attached it, but the max_beb_per1024 was ignored because the kernel is
old.

If it fails with -EINVAL, this means the kernel checked the value and
the feature is supported, so you can call it for the second time with
the right max_beb_per1024.

The first approach is more complex but probably cleaner. The second is
easier to implement.

-- 
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120822/1ce7ad4a/attachment.sig>


More information about the linux-mtd mailing list