瀏覽代碼

fix open directory but without O_DIRECTORY flag issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1313 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong@gmail.com 14 年之前
父節點
當前提交
a0cce584a8
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      components/dfs/filesystems/romfs/dfs_romfs.c

+ 4 - 0
components/dfs/filesystems/romfs/dfs_romfs.c

@@ -146,6 +146,10 @@ int dfs_romfs_open(struct dfs_fd* file)
 	dirent = dfs_romfs_lookup(root_dirent, file->path, &size);
 	if (dirent == RT_NULL) return -DFS_STATUS_ENOENT;
 
+	/* is a directory but not with O_DIRECTORY flag */
+	if ((dirent->type == ROMFS_DIRENT_DIR) && !(file->flags & DFS_O_DIRECTORY))
+		return -DFS_STATUS_ENOENT;
+
 	file->data = dirent;
 	file->size = size;
 	file->pos = 0;