Why is error code -36 (FS_FILE_EXISTS) returned by FS_CreateDir just after memory card is removed

来源:互联网 发布:网络渗透工具 编辑:程序博客网 时间:2024/05/11 21:38
After memory card is removed, FS can't know this event immediately. Therefore, there is a gap after memory card is removed and before FS is acknowledged by driver. Any operations during this period may lead to unexpected behaviors.  
Because FS_Open will exactly return error code -101 (FS_MSDC_READ_SECTOR_ERROR), for this kind of issue, we suggest user should create folders "only if" FS_Open returns error code -9 (FS_NOT_FOUND). 
The insight is, FS_Open will try to count the space occupied by directory entries which belong to the target folder. It will lead to a memory card read sector operation. If memory card is removed, such access will get error code -101 (FS_MSDC_READ_SECTOR_ERROR) from memory card drivers. 
However, FS_CreateDir will firstly check FS buffer cache. If meta data (directory entries) of parent folder is fully cached, error code -36 (FS_FILE_EXISTS) will be returned even if memory card is removed.
In this time, FS is unaware of memory card removal because the acknowledge process is not finished yet. 
In the future, we will co-work with memory card driver to immediately update mount status of memory card for hot plug-in/plug-out case. In that day, this ambiguous error code will not happen any more.