From 4eee9af668aedf1e647ec57de0670f88fe89f6de Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 19 Oct 2022 19:14:12 +0900 Subject: [PATCH] file_vopen: Retry as a directory in case of EISDIR This allows you to open() a directory without O_DIRECTORY. --- fs/vfs/fs_open.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 7b3a7544cc8..b62aaf0cffe 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -186,6 +186,11 @@ static int file_vopen(FAR struct file *filep, FAR const char *path, ret = -ENXIO; } + if (ret == -EISDIR) + { + ret = dir_allocate(filep, desc.relpath); + } + if (ret < 0) { goto errout_with_inode;