RT-Thread Version
master
Hardware Type/Architectures
stm32和07
Develop Toolchain
Other
Describe the bug
- 多次使用cat进行open/close同一个文件
- 使用list fs观察 计数情况
- 发现ref一直在增加,这样就算没有使用这个文件了,这个malloc一直存在
msh /flash/log>list fd
fd type ref magic path
-- ------ --- ----- ------
3 file 3 fdfd /log/flash_sys.log
4 file 1 fdfd /log/motion.log
-
原因.dfs_file_close中没有对vnode->ref_count进行减一操作.
-
发现vnode->ref_count--操作在fdt_fd_release函数调用.该函数在close中有调用...
-
查看DFSV2代码逻辑,应该也有这么问题
-
解决方案:
- 要么把dfs_file_close的调用都检查一遍都加入fdt_fd_release.或者替换为close函数
- 要么dfs_file_close中加入
vnode->ref_count--操作,fdt_fd_release函数中不执行这个逻辑
Other additional context
No response