Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[posix][dfs] move dfs_posix dfs_poll dfs_select.c to posix folder #5212

Merged
merged 1 commit into from
Oct 26, 2021
Merged

[posix][dfs] move dfs_posix dfs_poll dfs_select.c to posix folder #5212

merged 1 commit into from
Oct 26, 2021

Conversation

mysterywolf
Copy link
Member

@mysterywolf mysterywolf commented Oct 21, 2021

拉取/合并请求描述:(PR description)

[

在4.0.4整理libc的时候,我就已经察觉到来自dfs这边的阻力了,这里暗流涌动:

  1. 对于dfs来说,实现dfs_file_open这一层就已经完成任务了,增加dfs_posix实际上已经超出了dfs的责任范围,完全是为了兼容posix准备的。
  2. 一个非常奇怪的设定:开启RT_USING_DFS会包含dfs_posix.c 而实际开启RT_USING_POSIX却是在包含dfs_select.c 和 dfs_poll.c ?? 好歹(最起码)开启RT_USING_POSIX应该是包含dfs_posix.c吧。所以一直以来,对于社区小伙伴一直有一个困惑就是RT_USING_DFS和RT_USING_POSIX这两个宏的责任范围到底是怎么划分的?
  3. 在整理libc的时候,我就发现,libc这边的事情,比如<sys/select.h>,其实际的函数却是在十万八千里之外的dfs文件夹内实现的,这并不合理。
  4. RT_USING_LIBC RT_USING_POSIX RT_USING_DFS 三个层级相互交织在一起. 看起来可以运行,不会报错,但是实际上处于一种精妙的平衡当中,没有一个清晰的界限。对于社区小伙伴来说更是一头雾水。我已经接到了多次这样的反馈,到底应该开哪个宏?

因此,本pr将会重新整理dfs,拎清RT_USING_POSIX和RT_USING_DFS的责任范围:

  1. dfs_posix.c dfs_select.c dfs_poll.c 这三个函数是为了兼容posix而设立的,已经超出了dfs的责任范围,因此将其移除dfs文件夹,放在libc/posix文件夹的src文件夹内(posix/src文件夹存放posix的核心.c文件)
  2. 将posix下的文件其Group名改为POSIX

更改之后的RT_USING_LIBC、RT_USING_POSIX、RT_USING_DFS负责范围和界限变得非常的清晰

  1. RT_USING_DFS负责统一各个文件系统的接口,但是不对posix兼容性负责,到dfs_file_open这一层为止
  2. RT_USING_POSIX负责将dfs_file_open这一层兼容到posix,开始支持open read write close等posix接口
  3. RT_USING_LIBC开启时,会自动选定RT_USING_DFS和RT_USING_POSIX,这个行为和unix是一致的,在fread fwrite这些函数实际上是基于posix的read和write函数封装的

修改之后层级关系是这样的

层级
RT_USING_LIBC 最上层,fread fwrite printf puts等函数
RT_USING_POSIX 中间层,oepn read write close select poll等函数
RT_USING_DFS 最底层, dfs_file_write dfs_file_read dfs_file_open 等函数

在此之前,三个层级相互交织在一起,经过本次PR的修改,给出了一个清晰的层级关系。
同时,本PR为郭老师后续POSIX的完善做好了铺垫。

参考资料:

7c1423301ec949d1962e5cad3f0fa04

a832b0748e6c1d5ff144d1888d50b9b

]

以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in the submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use a web browser to visit PR, and check items one by one, and ticked them if no problem.

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 本拉取/合并请求代码是高质量的 Code in this PR is of high quality
  • 本拉取/合并使用formatting等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

@mysterywolf mysterywolf added in progress PR/issue in progress. v4.0.5 important and removed in progress PR/issue in progress. labels Oct 21, 2021
@Guozhanxin Guozhanxin added the +1 Agree +1 label Oct 25, 2021
@Guozhanxin Guozhanxin merged commit 50bb6e3 into RT-Thread:master Oct 26, 2021
@mysterywolf mysterywolf deleted the posix branch October 26, 2021 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants