Possible bug in /proc/mtd ?
I've just started to bring up MTD in a uC-linux derived system.
I've found what I believe is a problem in the code for /proc/mtd.
Does anyone else get some sort of strange behavior if they run:
dd if=/proc/mtd of=/dev/tty bs=1
The strange behavior on my system is a hang; it may be an oops or panic of some sort on a system with a mmu.
If you see this problem, I think it should go away with this patch:
------------------------------------------------------------
mtdcore.c +1 -1
@@ -289,21 +289,21 @@ }#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,2 ,0 ) *eof =1 ;#endif done:up (&mtd_table_mutex);if (off >= len+begin)return 0 ; - *start = page + (begin-off); + *start = page + (off-begin);return ((count < begin+len-off) ? count : begin+len-off); }#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,2 ,0 )struct proc_dir_entry mtd_proc_entry = {0 ,/* low_ino: the inode -- dynamic */ 3 ,"mtd" ,/* len of name and name */ S_IFREG |S_IRUGO ,/* mode */ 1 ,0 ,0 ,/* nlinks, owner, group */ 0, NULL, /* size - unused; operations -- use default */
------------------------------------------------------------
Thanks for looking,
--> Steve Wahl
Hi!
mtdcore.c line 299
Quoted 11 lines
Does anyone else get some sort of strange behavior if they run:
dd if=/proc/mtd of=/dev/tty bs=1
The strange behavior on my system is a hang; it may be an oops or panic of some sort on a system with a mmu.
[...]
mtdcore.c +1
-1- *start = page + (begin-off); + *start = page + (off-begin);
Pretty obvious. You must be the first one to ever try that. :-)
David, is it ok, if I apply?
Jörn
Signature · 2 lines
When in doubt, use brute force. -- Ken Thompson