Recently, an abnormal FAT file system umount caused an exception in the mounting of the sdcard. It went to errors for processing and remount-ro.
<4>[ 7993.545483] c0 FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.<3>[ 7999.739501] c0 FAT-fs (mmcblk0p1): error, clusters badly computed (721 != 673)<3>[ 7999.739521] c0 FAT-fs (mmcblk0p1): Filesystem has been set read-only
We can see the Mount parameter "errors = remount-ro"
/dev/block/vold/179:33 /mnt/media_rw/sdcard0 vfat ro,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
Failed to mount. The error option will be processed in "kernel/fs/fat/Misc. C + 33.
The error detection is handled in "kernel/fs/fat/Misc. C + 158.
In "kernel/fs/fat/inode. C + 520", we can see the source of the warning. It should be that SBI has a problem.
----
The above is the background. Now I want to understand how to write data to a disk by opening a file and writing the file.