mirror of
https://github.com/pine64/bl_iot_sdk.git
synced 2024-10-06 06:50:19 +00:00
vfs: Fix counting in inode_avail_count
As seen in `inode_del` (and `inode_alloc`), a free (`NOT_INIT`) node can be found anywhere in `g_vfs_dev_nodes`; it’s a “sparse” list. So when checking for free nodes, the iterating index variable (`e`) shall be used, not the counter (`count`). The code got that wrong. For instance, if the first node is not available (type is not `VFS_TYPE_NOT_INIT`), then the function previously returned 0, no matter what, and was iterating the node list in vain.
This commit is contained in:
parent
bc112954be
commit
c546054984
@ -131,7 +131,7 @@ int inode_avail_count(void)
|
|||||||
int e = 0;
|
int e = 0;
|
||||||
|
|
||||||
for (; e < AOS_CONFIG_VFS_DEV_NODES; e++) {
|
for (; e < AOS_CONFIG_VFS_DEV_NODES; e++) {
|
||||||
if (g_vfs_dev_nodes[count].type == VFS_TYPE_NOT_INIT) {
|
if (g_vfs_dev_nodes[e].type == VFS_TYPE_NOT_INIT) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user