未验证 提交 20cd0e4f 编写于 作者: O openharmony_ci 提交者: Gitee

!951 合入monthly_20221018:添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量

Merge pull request !951 from Hongjin Li/monthly_20221018
......@@ -88,4 +88,9 @@
#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR
/* max number of open directories */
#ifndef LOSCFG_MAX_OPEN_DIRS
#define LOSCFG_MAX_OPEN_DIRS 10
#endif
#endif
......@@ -94,6 +94,7 @@ int PollQueryFd(int fd, struct PollTable *table)
#define IOV_MAX_CNT 4
UINT32 g_fsMutex;
static UINT32 g_dirNum = 0;
int VfsLock(void)
{
......@@ -666,6 +667,13 @@ static DIR *VfsOpendir(const char *path)
return NULL;
}
if (g_dirNum >= LOSCFG_MAX_OPEN_DIRS) {
VFS_ERRNO_SET(ENFILE);
VfsUnlock();
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
mp = VfsMpFind(path, &pathInMp);
if ((mp == NULL) || (pathInMp == NULL)) {
VFS_ERRNO_SET(ENOENT);
......@@ -687,6 +695,7 @@ static DIR *VfsOpendir(const char *path)
ret = (UINT32)mp->mFs->fsFops->opendir(dir, pathInMp);
if (ret == 0) {
mp->mRefs++;
g_dirNum++;
} else {
LOSCFG_FS_FREE_HOOK(dir);
dir = NULL;
......@@ -752,6 +761,7 @@ static int VfsClosedir(DIR *d)
if (ret == 0) {
mp->mRefs--;
g_dirNum--;
} else {
VFS_ERRNO_SET(EBADF);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册