[fix][dfs] 修复ramfs与tmpfs对文件名超长的处理逻辑#11624
Conversation
|
👋 感谢您对 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)
📊 Current Review Status (Last Updated: 2026-07-16 23:27 CST)
📝 Review Instructions
|
|
There was a problem hiding this comment.
Pull request overview
This PR updates DFS v2 tmpfs and ramfs to avoid silent truncation / overflow risk when handling overlong filenames, by adding explicit length checks and (for ramfs) reusing a dedicated name-parsing helper.
Changes:
- tmpfs: extend
_path_separate()to take buffer sizes and return-ENAMETOOLONGwhen parent/name buffers are insufficient; switch tort_strncpy. - ramfs: add
_ramfs_set_name()helper to validate/normalize names and return proper errors (e.g.,-ENAMETOOLONG) instead of truncating; usert_strcpyfor root name init. - PR metadata: Title prefix/format and the “BSP/.config/action” verification fields appear incomplete vs repo checklist (English: please consider aligning title prefix to
[module][subsystem]lowercase and filling verification info; 中文:建议按仓库规范调整标题前缀为小写[模块][子系统],并补充 BSP/.config/action 验证信息)。
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c | Add size-aware path splitting to reject overlong filenames; use RT-Thread string APIs. |
| components/dfs/dfs_v2/filesystems/ramfs/dfs_ramfs.c | Introduce validated name extraction to avoid truncation and reject invalid/overlong names; minor API consistency updates. |
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
tmpfs对超长文件名无保护,会导致溢出,且被截断
ramfs对超长文件名有保护,但会被截断
你的解决方案是什么 (what is your solution)
参考V1版本的实现,修复V2版本ramfs与tmpfs对文件名超长的处理逻辑
请提供验证的bsp和config (provide the config and bsp)
BSP:
.config:
action:
]
当前拉取/合并请求的状态 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