kempniu / yafut

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

Prevent modifying the file system when -r is used #3

Closed kempniu closed 1 year ago

kempniu commented 1 year ago

When Yaffs code detects problems (e.g. ECC errors) while mounting an MTD partition, it may attempt to rectify them by altering the data stored on the MTD. This operation may break valid Yaffs file systems (e.g. due to OOB layout differences). While writing a file to an MTD is inherently risky as it requires modifying the file system, reading a file from an MTD should not be considered a dangerous operation. Meanwhile, init_mtd_context() always opens the MTD character device in read-write mode, so the file system may be modified even when -r is used. That should not be the case as it breaks user expectations.

Fix by opening the character device in read-only mode when -r is used.