-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
sync update dfs v2. #8336
sync update dfs v2. #8336
Conversation
12e4391
to
afd8397
Compare
components/dfs/dfs_v2/src/dfs.c
Outdated
* | ||
* @return -1 on failed or the allocated file descriptor. | ||
*/ | ||
int dfs_dup_to(int oldfd, struct dfs_fdtable *fdtab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个没地方使用,不需要这部分的代码。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个原本是给uds或类似需要跨进程传递fd的时候用的,然后uds那边又自己把这个函数copy rename了一份。严格上来讲应该用这一份共用的才是吧?不然每种需要传fd的地方都需要再实现一份(例如dma-buf)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是这样,那应该对这两个API进行比较好的命名,以反应出意义。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dfs_dup_to_fdtab:将A进程的私有fd dup到fdtab中,如果fdtab没有指定则使用内核全局的fdtab.
dfs_dum_from_tdtab:进程B将进程A通过dfs_dup_to_fdtab dup得到的fd,从原fdtab中再dup一个属于自己进程的fd出来。
dfs_fdtab_drop_fd:从fdtab中释放一个fd。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int dfs_fdtab_drop_fd(int fd, struct dfs_fdtable *fdtab)
看起来并不是那么合规,包括这个文件前面还有dfs_fdtable_
类型的API。如果是dfs_fdtable_
类型的,那么这个api应该以fdtable为中心,即int dfs_fdtable_drop_fd(struct dfs_fdtable* fdt, int fd);
。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是dup,总体来说,是不是也只有一种情况:
int dfs_fdtable_dup(struct dfs_fdtable *fdt, struct dfs_fdtable *fdt_src, int fd_src);
把源fdt_src中对应的fd_src,复制到fdt中。
源fdt可以是NULL,则代表当前的进程;如果fdt_dst是NULL,则代表当前的进程。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是dup,总体来说,是不是也只有一种情况
大致原理相同,不过有点差异的考量:
原dfs_dup_to_fdtab是浅拷贝,不会正真去分配fds,只是将fds指向同一个源fd,并应用计数+1.等到dfs_dum_from_tdtab的时候才会深拷贝一次fds。
合并成一种情况来看的话,就不能使用浅拷贝了,整个传递fd的过程会分配两个fds并拷贝两次。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BernardXiong 改了,look look again.
@XYZ-20240101 也帮忙review一下。
3e70eb2
to
6726cfe
Compare
6726cfe
to
f3060ef
Compare
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 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