`open` with `O_DIRECT` succeeds on a FIFO, where Linux returns `EINVAL`
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 62/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c, linux, macos
调研方向
Start with the reproducer in the issue and find where elfuse handles open flags, especially O_DIRECT and the FIFO and /proc/self/fd/N paths. Compare against the Linux rule in do_dentry_open (fs/open.c), which returns EINVAL when the file lacks FMODE_CAN_ODIRECT. Done when both FIFO and pipe-through-procfs opens with O_DIRECT return -1 with EINVAL, matching Linux 6.12.
由索引模型根据 Issue 内容生成。
描述
Linux refuses O_DIRECT at open for a file that cannot do direct I/O: do_dentry_open (fs/open.c) returns EINVAL when the flag is set and the file lacks FMODE_CAN_ODIRECT, which a FIFO lacks. A pipe takes the flag through pipe2 and F_SETFL only. Under elfuse the open succeeds, both for a FIFO opened by name and for a pipe reopened through /proc/self/fd/N.
Reproducer:
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void)
{
const char *fifo = "/tmp/o-direct-fifo";
char link[64];
int p[2];
unlink(fifo);
mkfifo(fifo, 0600);
int rd = open(fifo, O_RDONLY | O_NONBLOCK);
errno = 0;
int wr = open(fifo, O_WRONLY | O_DIRECT);
printf("open(fifo, O_WRONLY|O_DIRECT): %s errno=%d\n",
wr >= 0 ? "an fd" : "-1", errno);
pipe(p);
snprintf(link, sizeof(link), "/proc/self/fd/%d", p[1]);
errno = 0;
int again = open(link, O_WRONLY | O_DIRECT);
printf("open(/proc/self/fd/N, O_WRONLY|O_DIRECT) on a pipe: %s errno=%d\n",
again >= 0 ? "an fd" : "-1", errno);
(void) rd;
unlink(fifo);
return 0;
}
| FIFO by name | pipe through /proc/self/fd/N |
|
|---|---|---|
elfuse b57f367 |
an fd | an fd |
| Linux 6.12 under qemu | -1, EINVAL |
-1, EINVAL |
- 主要语言
- C
- 星标
- 273
- 派生
- 29
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/elfuse 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 3 天内回复
-
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 3 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 3 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 3 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
libsdl-org/SDL#16539 ·
维护者通常 1 天内回复
-
git-workflow task-4
难度 2/5 1-3 小时 新手友好度 66/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
dosemu2/dosemu2#3178 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复