Waldemar Brodkorb dixit:

>It is needed for Netgear, which has one more partition, so that
>mtdblock5 is not the data partition.

+       datanr=$(awk -F : '/data/ { print $1 }' /proc/mtd |sed "s#mtd##")

Why not like fwcf?

part=/dev/mtd/$(fgrep '"fwcf"' /proc/mtd 2>&- | sed 's/^mtd\([^:]*\):.*$/\1/')ro

This would effectively mean

+       datanr=$(fgrep '"data"' /proc/mtd 2>&- | sed 's/^mtd\([^:]*\):.*$/\1/')

if I got the line above correctly, _and_ is more easy to unserstand.

Alternatively, to save fork() and exec() time, you could do something like

+       while read line; do
+               [[ $line = *\"data\"* ]] || continue
+               line=${line#mtd}
+               datanr=${line%%:*}
+       done </proc/mtd

but I don't know if ash groks this (mksh does). In all THREE cases,
error handling if /proc isn't mounted, /proc/mtd can't be read, and
there is no "data" partition, could be added.

Please test the lines above to see if the result is correct.

bye,
//mirabile
-- 
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy them.
If you don't believe in God, just consider God as Nature if you won't deny
existence.              -- Coywolf Qi Hunt
_______________________________________________
freewrt-developers mailing list
[email protected]
https://www.freewrt.org/lists/listinfo/freewrt-developers

Reply via email to