Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`open` with `O_DIRECT` succeeds on a FIFO, where Linux returns `EINVAL`

未关闭
#430 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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 内容生成。

描述

bug

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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。