* [PATCH 02/02] force module loaded with partitions set
@ 2011-03-14 1:51 Yang Ruirui
2011-03-14 8:43 ` Artem Bityutskiy
0 siblings, 1 reply; 9+ messages in thread
From: Yang Ruirui @ 2011-03-14 1:51 UTC (permalink / raw)
To: dwmw2, linux-mtd, Artem.Bityutskiy, ext-jani.1.nikula,
ext-phil.2.carmody, ruirui.r.yang
From: Yang Ruirui<ruirui.r.yang@tieto.com>
partitions can not be set after module loaded, the moduel param mode is 0444.
this patch force module loaded with param partitions set, if user does not
set partitions then give out a warning and return -EINVAL
Signed-off-by: Yang Ruirui<ruirui.r.yang@tieto.com>
Tested-by: Shao Yanqing<yanqing.shao@tieto.com>
Tested-by: Xiao Yang<yang.xiao@tieto.com>
---
drivers/mtd/mtdswap.c | 6 ++++++
1 file changed, 6 insertions(+)
--- mtd-2.6-fc2ff59.orig/drivers/mtd/mtdswap.c 2011-03-14 09:36:09.283329099 +0800
+++ mtd-2.6-fc2ff59/drivers/mtd/mtdswap.c 2011-03-14 09:46:30.229993534 +0800
@@ -1569,6 +1569,12 @@ static struct mtd_blktrans_ops mtdswap_o
static int __init mtdswap_modinit(void)
{
+ if (!partitions[0]) {
+ printk(KERN_WARNING
+ "Please load mtdswap with correct partitions param\n");
+ return -EINVAL;
+ }
+
return register_mtd_blktrans(&mtdswap_ops);
}
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-14 1:51 [PATCH 02/02] force module loaded with partitions set Yang Ruirui
@ 2011-03-14 8:43 ` Artem Bityutskiy
2011-03-14 8:57 ` Yang Rui Rui
0 siblings, 1 reply; 9+ messages in thread
From: Artem Bityutskiy @ 2011-03-14 8:43 UTC (permalink / raw)
To: Yang Ruirui
Cc: linux-mtd, ext-phil.2.carmody, dwmw2, ruirui.r.yang,
ext-jani.1.nikula
On Mon, 2011-03-14 at 09:51 +0800, Yang Ruirui wrote:
> From: Yang Ruirui<ruirui.r.yang@tieto.com>
>
> partitions can not be set after module loaded, the moduel param mode is 0444.
>
> this patch force module loaded with param partitions set, if user does not
> set partitions then give out a warning and return -EINVAL
>
> Signed-off-by: Yang Ruirui<ruirui.r.yang@tieto.com>
> Tested-by: Shao Yanqing<yanqing.shao@tieto.com>
> Tested-by: Xiao Yang<yang.xiao@tieto.com>
> ---
> drivers/mtd/mtdswap.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> --- mtd-2.6-fc2ff59.orig/drivers/mtd/mtdswap.c 2011-03-14 09:36:09.283329099 +0800
> +++ mtd-2.6-fc2ff59/drivers/mtd/mtdswap.c 2011-03-14 09:46:30.229993534 +0800
> @@ -1569,6 +1569,12 @@ static struct mtd_blktrans_ops mtdswap_o
>
> static int __init mtdswap_modinit(void)
> {
> + if (!partitions[0]) {
> + printk(KERN_WARNING
> + "Please load mtdswap with correct partitions param\n");
> + return -EINVAL;
> + }
I think a similar check is done in mtdswap_add_mtd() ?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-14 8:43 ` Artem Bityutskiy
@ 2011-03-14 8:57 ` Yang Rui Rui
2011-03-14 8:53 ` Artem Bityutskiy
0 siblings, 1 reply; 9+ messages in thread
From: Yang Rui Rui @ 2011-03-14 8:57 UTC (permalink / raw)
To: Artem.Bityutskiy@nokia.com
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On 03/14/2011 04:43 PM, Artem Bityutskiy wrote:
> On Mon, 2011-03-14 at 09:51 +0800, Yang Ruirui wrote:
>> From: Yang Ruirui<ruirui.r.yang@tieto.com>
>>
>> partitions can not be set after module loaded, the moduel param mode is 0444.
>>
>> this patch force module loaded with param partitions set, if user does not
>> set partitions then give out a warning and return -EINVAL
>>
>> Signed-off-by: Yang Ruirui<ruirui.r.yang@tieto.com>
>> Tested-by: Shao Yanqing<yanqing.shao@tieto.com>
>> Tested-by: Xiao Yang<yang.xiao@tieto.com>
>> ---
>> drivers/mtd/mtdswap.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> --- mtd-2.6-fc2ff59.orig/drivers/mtd/mtdswap.c 2011-03-14 09:36:09.283329099 +0800
>> +++ mtd-2.6-fc2ff59/drivers/mtd/mtdswap.c 2011-03-14 09:46:30.229993534 +0800
>> @@ -1569,6 +1569,12 @@ static struct mtd_blktrans_ops mtdswap_o
>>
>> static int __init mtdswap_modinit(void)
>> {
>> + if (!partitions[0]) {
>> + printk(KERN_WARNING
>> + "Please load mtdswap with correct partitions param\n");
>> + return -EINVAL;
>> + }
>
> I think a similar check is done in mtdswap_add_mtd() ?
>
>
Yes, that one should be removed if this is ok. This module just waste memory without partitions set. And there's no chance to pass in the params.
--
Thanks
Yang Ruirui
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-14 8:57 ` Yang Rui Rui
@ 2011-03-14 8:53 ` Artem Bityutskiy
2011-03-14 9:12 ` Yang Rui Rui
0 siblings, 1 reply; 9+ messages in thread
From: Artem Bityutskiy @ 2011-03-14 8:53 UTC (permalink / raw)
To: Yang Rui Rui
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On Mon, 2011-03-14 at 16:57 +0800, Yang Rui Rui wrote:
> On 03/14/2011 04:43 PM, Artem Bityutskiy wrote:
> > On Mon, 2011-03-14 at 09:51 +0800, Yang Ruirui wrote:
> >> From: Yang Ruirui<ruirui.r.yang@tieto.com>
> >>
> >> partitions can not be set after module loaded, the moduel param
> mode is 0444.
> >>
> >> this patch force module loaded with param partitions set, if user
> does not
> >> set partitions then give out a warning and return -EINVAL
> >>
> >> Signed-off-by: Yang Ruirui<ruirui.r.yang@tieto.com>
> >> Tested-by: Shao Yanqing<yanqing.shao@tieto.com>
> >> Tested-by: Xiao Yang<yang.xiao@tieto.com>
> >> ---
> >> drivers/mtd/mtdswap.c | 6 ++++++
> >> 1 file changed, 6 insertions(+)
> >>
> >> --- mtd-2.6-fc2ff59.orig/drivers/mtd/mtdswap.c 2011-03-14
> 09:36:09.283329099 +0800
> >> +++ mtd-2.6-fc2ff59/drivers/mtd/mtdswap.c 2011-03-14
> 09:46:30.229993534 +0800
> >> @@ -1569,6 +1569,12 @@ static struct mtd_blktrans_ops mtdswap_o
> >>
> >> static int __init mtdswap_modinit(void)
> >> {
> >> + if (!partitions[0]) {
> >> + printk(KERN_WARNING
> >> + "Please load mtdswap with correct partitions param\n");
> >> + return -EINVAL;
> >> + }
> >
> > I think a similar check is done in mtdswap_add_mtd() ?
> >
> >
>
> Yes, that one should be removed if this is ok. This module just waste
> memory without partitions set. And there's no chance to pass in the
> params.
I agree that the problem you are solving exist. But I think I do not
agree with the solution. There are many other ways to end up with
mtdswap module loaded but not functioning, e.g., users passes incorrect
module parameters. Basically, any failed check in 'mtdswap_add_mtd()'.
IOW, you are solving just one of many similar issues.
I think you should rather re-work the framework a bit and make the
"->add_mtd()" call-back return an integer error code. Then we could just
return errors on error and prevent the module from being loaded.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-14 8:53 ` Artem Bityutskiy
@ 2011-03-14 9:12 ` Yang Rui Rui
2011-03-14 9:33 ` Artem Bityutskiy
0 siblings, 1 reply; 9+ messages in thread
From: Yang Rui Rui @ 2011-03-14 9:12 UTC (permalink / raw)
To: Artem.Bityutskiy@nokia.com
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On 03/14/2011 04:53 PM, Artem Bityutskiy wrote:
> On Mon, 2011-03-14 at 16:57 +0800, Yang Rui Rui wrote:
>> On 03/14/2011 04:43 PM, Artem Bityutskiy wrote:
>>> On Mon, 2011-03-14 at 09:51 +0800, Yang Ruirui wrote:
>>>> From: Yang Ruirui<ruirui.r.yang@tieto.com>
>>>>
>>>> partitions can not be set after module loaded, the moduel param
>> mode is 0444.
>>>>
>>>> this patch force module loaded with param partitions set, if user
>> does not
>>>> set partitions then give out a warning and return -EINVAL
>>>>
>>>> Signed-off-by: Yang Ruirui<ruirui.r.yang@tieto.com>
>>>> Tested-by: Shao Yanqing<yanqing.shao@tieto.com>
>>>> Tested-by: Xiao Yang<yang.xiao@tieto.com>
>>>> ---
>>>> drivers/mtd/mtdswap.c | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>>
>>>> --- mtd-2.6-fc2ff59.orig/drivers/mtd/mtdswap.c 2011-03-14
>> 09:36:09.283329099 +0800
>>>> +++ mtd-2.6-fc2ff59/drivers/mtd/mtdswap.c 2011-03-14
>> 09:46:30.229993534 +0800
>>>> @@ -1569,6 +1569,12 @@ static struct mtd_blktrans_ops mtdswap_o
>>>>
>>>> static int __init mtdswap_modinit(void)
>>>> {
>>>> + if (!partitions[0]) {
>>>> + printk(KERN_WARNING
>>>> + "Please load mtdswap with correct partitions param\n");
>>>> + return -EINVAL;
>>>> + }
>>>
>>> I think a similar check is done in mtdswap_add_mtd() ?
>>>
>>>
>>
>> Yes, that one should be removed if this is ok. This module just waste
>> memory without partitions set. And there's no chance to pass in the
>> params.
>
> I agree that the problem you are solving exist. But I think I do not
> agree with the solution. There are many other ways to end up with
> mtdswap module loaded but not functioning, e.g., users passes incorrect
> module parameters. Basically, any failed check in 'mtdswap_add_mtd()'.
>
> IOW, you are solving just one of many similar issues.
Right, agree.
>
> I think you should rather re-work the framework a bit and make the
> "->add_mtd()" call-back return an integer error code. Then we could just
> return errors on error and prevent the module from being loaded.
>
I'm thinking is it possible to pass partitions param later? ie. use sysfs attribute?
Anyway, I will check the code again to see if can change as your suggestion.
--
Thanks
Yang Ruirui
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-14 9:12 ` Yang Rui Rui
@ 2011-03-14 9:33 ` Artem Bityutskiy
2011-03-17 8:50 ` Yang Rui Rui
0 siblings, 1 reply; 9+ messages in thread
From: Artem Bityutskiy @ 2011-03-14 9:33 UTC (permalink / raw)
To: Yang Rui Rui
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On Mon, 2011-03-14 at 17:12 +0800, Yang Rui Rui wrote:
> > I think you should rather re-work the framework a bit and make the
> > "->add_mtd()" call-back return an integer error code. Then we could just
> > return errors on error and prevent the module from being loaded.
> >
>
> I'm thinking is it possible to pass partitions param later? ie. use sysfs attribute?
It may be possible, but would probably require some work.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-14 9:33 ` Artem Bityutskiy
@ 2011-03-17 8:50 ` Yang Rui Rui
2011-03-17 8:51 ` Artem Bityutskiy
0 siblings, 1 reply; 9+ messages in thread
From: Yang Rui Rui @ 2011-03-17 8:50 UTC (permalink / raw)
To: Artem.Bityutskiy@nokia.com
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On 03/14/2011 05:33 PM, Artem Bityutskiy wrote:
> On Mon, 2011-03-14 at 17:12 +0800, Yang Rui Rui wrote:
>>> I think you should rather re-work the framework a bit and make the
>>> "->add_mtd()" call-back return an integer error code. Then we could just
>>> return errors on error and prevent the module from being loaded.
>>>
>>
>> I'm thinking is it possible to pass partitions param later? ie. use sysfs attribute?
>
> It may be possible, but would probably require some work.
>
mainline mtd & mtd_blkdev changes a lot since 2.6.32, but there's no
way for me to test with linux-mtd tree due to lack real hardware.
work on this with 2.6.32 seems not so necessary,
So I think I will give up, sorry about that.
--
Thanks
Yang Ruirui
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-17 8:50 ` Yang Rui Rui
@ 2011-03-17 8:51 ` Artem Bityutskiy
2011-03-17 9:24 ` Yang Rui Rui
0 siblings, 1 reply; 9+ messages in thread
From: Artem Bityutskiy @ 2011-03-17 8:51 UTC (permalink / raw)
To: Yang Rui Rui
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On Thu, 2011-03-17 at 16:50 +0800, Yang Rui Rui wrote:
> On 03/14/2011 05:33 PM, Artem Bityutskiy wrote:
> > On Mon, 2011-03-14 at 17:12 +0800, Yang Rui Rui wrote:
> >>> I think you should rather re-work the framework a bit and make the
> >>> "->add_mtd()" call-back return an integer error code. Then we could just
> >>> return errors on error and prevent the module from being loaded.
> >>>
> >>
> >> I'm thinking is it possible to pass partitions param later? ie. use sysfs attribute?
> >
> > It may be possible, but would probably require some work.
> >
>
> mainline mtd & mtd_blkdev changes a lot since 2.6.32, but there's no
> way for me to test with linux-mtd tree due to lack real hardware.
>
> work on this with 2.6.32 seems not so necessary,
> So I think I will give up, sorry about that.
No problem, but as a side note, you can always test on a PC with
nandsim. Here is some UBI-related doc, but it gives the idea:
http://www.linux-mtd.infradead.org/faq/ubi.html#L_how_debug
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 02/02] force module loaded with partitions set
2011-03-17 8:51 ` Artem Bityutskiy
@ 2011-03-17 9:24 ` Yang Rui Rui
0 siblings, 0 replies; 9+ messages in thread
From: Yang Rui Rui @ 2011-03-17 9:24 UTC (permalink / raw)
To: Artem.Bityutskiy@nokia.com
Cc: Yang Ruirui R, ext-phil.2.carmody@nokia.com, dwmw2@infradead.org,
linux-mtd@lists.infradead.org, ext-jani.1.nikula@nokia.com
On 03/17/2011 04:51 PM, Artem Bityutskiy wrote:
> On Thu, 2011-03-17 at 16:50 +0800, Yang Rui Rui wrote:
>> On 03/14/2011 05:33 PM, Artem Bityutskiy wrote:
>>> On Mon, 2011-03-14 at 17:12 +0800, Yang Rui Rui wrote:
>>>>> I think you should rather re-work the framework a bit and make the
>>>>> "->add_mtd()" call-back return an integer error code. Then we could just
>>>>> return errors on error and prevent the module from being loaded.
>>>>>
>>>>
>>>> I'm thinking is it possible to pass partitions param later? ie. use sysfs attribute?
>>>
>>> It may be possible, but would probably require some work.
>>>
>>
>> mainline mtd& mtd_blkdev changes a lot since 2.6.32, but there's no
>> way for me to test with linux-mtd tree due to lack real hardware.
>>
>> work on this with 2.6.32 seems not so necessary,
>> So I think I will give up, sorry about that.
>
> No problem, but as a side note, you can always test on a PC with
> nandsim. Here is some UBI-related doc, but it gives the idea:
>
> http://www.linux-mtd.infradead.org/faq/ubi.html#L_how_debug
>
very useful for playing with mtd, thank you.
--
Thanks
Yang Ruirui
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-03-17 9:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-14 1:51 [PATCH 02/02] force module loaded with partitions set Yang Ruirui
2011-03-14 8:43 ` Artem Bityutskiy
2011-03-14 8:57 ` Yang Rui Rui
2011-03-14 8:53 ` Artem Bityutskiy
2011-03-14 9:12 ` Yang Rui Rui
2011-03-14 9:33 ` Artem Bityutskiy
2011-03-17 8:50 ` Yang Rui Rui
2011-03-17 8:51 ` Artem Bityutskiy
2011-03-17 9:24 ` Yang Rui Rui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox