Repository navigation
[dfs][posix] Report open failures with positive errno - #12067
Conversation
Distinguish a full descriptor table from allocation failure. Preserve native negative DFS errors and publish positive errno at the POSIX open boundary.
Return -1 when a descriptor cannot be allocated, including when the table is full. A genuine fd 0 remains valid.
Check errno on failed opens and reopen the file after releasing the descriptors held by the test.
Select the current DFS and POSIX UTEST symbols and use the block device registered by qemu-vexpress-a9.
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: workflowReviewers: @Rbb666 @kurisaW @supperthomas Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-11-19 08:55 CST)
📝 Review Instructions
|
BernardXiong
left a comment
There was a problem hiding this comment.
Review / 审查 — 014db463
结论 / Conclusion: COMMENT — 未发现阻塞性问题。
open() 两条 DFS 路径的 errno 传递是一致的:fd_slot_expand()/_fdt_slot_expand() 现在返回 -EMFILE/-ENOMEM,fdt_fd_new() 在解锁后用 rt_set_errno(-idx) 发布正值,open() 在 dfs_file_open() 失败时用 rt_set_errno(-result);v2 的 fd_new() 失败不再返回 0(原先把 RT_NULL 当成功)。新增用例覆盖缺文件 ENOENT 与满表 EMFILE。
非阻塞 / Non-blocking
- 同一 API 族中仍有负值 errno 写入:v2
openat()的rt_set_errno(-EBADF)/(-ENOMEM)(dfs_posix.c:114、dfs_posix.c:127、dfs_posix.c:134),v1openat()同样(dfs_posix.c:100),以及 v2dfs_dup()(dfs.c:786)。rt_set_errno()原样保存,newlib 的__errno()直接返回_rt_errno(),这些路径会让errno变成负值,与本 PR 建立的正值语义不一致,建议作为后续统一修正。 dfs_dup()/dfs_dup_to()在描述符分配失败时仍只返回-1而未设置 errno,POSIXdup()无法区分EMFILE/ENOMEM;可作为后续改进。
CI:作者为首次贡献者,已静态核对全部 6 个改动文件(未涉及 workflow、构建脚本、依赖或外部下载),并批准本 head 的 8 个 action_required 工作流;结果返回并通过前不给出 APPROVE。
|
拉取/合并请求描述:(PR description)
Related to #10558.
Why
On
6fdfe70062ec, opening a missing file on a mounted filesystem returns-1with negativeerrnoin both DFS versions. When the descriptor table is full, DFS v1 reports-ENOMEMinerrno. DFS v2 returns0, which callers treat as an open descriptor. An RT-Smart process on ARM also receives that false success from the raw syscall and from musl.Changes
EMFILEat the descriptor limit andENOMEMwhen table growth or file-object allocation fails. The shared descriptor allocator publishes the error after unlocking. Existing public descriptor and duplication failure return values are preserved.-1from POSIXopen()on allocation failure. Whendfs_file_open()returns a negative error, release the descriptor and publish the corresponding positiveerrno. A successful open can still return descriptor zero.sddevice so the native and POSIX suites actually run.Verification
BSP
bsp/qemu-vexpress-a9, QEMU 7.2.22, Intel macOS host with a Linux build container.DFS_FD_MAX=12-1/ENOENT. A full table yields-1/EMFILE. Injected failure of each of the two allocator operations yields-1/ENOMEM. An independent thread retains its sentinel errno.DFS_STDIO_OFFSET=0, POSIX stdio and termios disabled-ENOENTand-EMFILE, and libc-1with positiveerrno. Closing stdin and opening a file returns a working fd 0.The corresponding single-core RT-Smart configuration with context assertions enabled stops in
rt_aspace_fault_try_fixbefore usermain()on both revisions. Picolibc and non-MMU LWP received source review only. Scope is the DFSopen()path and the allocation errors it consumes.The table above reports local QEMU runs. GitHub Actions also built
bsp/qemu-vexpress-a9withCONFIG_RT_USING_DFS_V2=yat014db4634def. Passing ARM build on the PR branch.当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up