kempniu / yafut

Yet Another File UTility
GNU General Public License v2.0
4 stars 3 forks source link

Fix reporting bad blocks to Yaffs code #8

Closed kempniu closed 1 year ago

kempniu commented 1 year ago

mtd_check_bad(), the function called by Yaffs code the check whether a given MTD block is bad, only returns YAFFS_FAIL (which indicates a bad block) when the MEMGETBADBLOCK ioctl returns a negative value, i.e. when an error occurs while the kernel processes the ioctl. Meanwhile, the MEMGETBADBLOCK ioctl returns 0 when a given block is good and 1 when a given block is bad. Consequently, mtd_check_bad() incorrectly reports bad blocks as good, confusing Yaffs code.

Fix by making the mtd_check_bad() function only return YAFFS_OK when a given block is good and YAFFS_FAIL in any other case (bad block or error during ioctl processing).