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

`F_GETPIPE_SZ` returns `EINVAL`, and `F_SETLEASE` returns 65536

未关闭 适合新手
#422 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c

调研方向

从 src/syscall/fs.c 中的 sys_fcntl 开始,其中 switch 使用 case 1024 对应 F_GETPIPE_SZ,并将其命令编号与 issue 中 Linux 的 F_LINUX_SPECIFIC_BASE 偏移量进行比较。编译 reproducer,并分别在管道和普通文件上运行。完成的标准是:F_GETPIPE_SZ 返回管道大小,管道上的 F_SETLEASE 返回 EINVAL,文件上的 F_SETLEASE 返回 0,与表格中的 Linux 行一致。

由索引模型根据 Issue 内容生成。

描述

bug

sys_fcntl (src/syscall/fs.c) answers F_GETPIPE_SZ under case 1024. Linux counts these commands from F_LINUX_SPECIFIC_BASE, which is 1024: F_SETLEASE is 1024, F_GETLEASE is 1025, F_SETPIPE_SZ is 1031 and F_GETPIPE_SZ is 1032. The real F_GETPIPE_SZ therefore reaches the default arm and returns EINVAL, and F_SETLEASE returns 65536 on any fd, which its caller reads as success.

Reproducer:

#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
    int p[2];
    pipe(p);
    int file = open("/tmp/lease-file", O_CREAT | O_RDONLY, 0600);

    errno = 0;
    printf("F_GETPIPE_SZ on a pipe: %d errno=%d\n", fcntl(p[0], F_GETPIPE_SZ),
           errno);
    errno = 0;
    printf("F_SETLEASE on a pipe:   %d errno=%d\n",
           fcntl(p[0], F_SETLEASE, F_RDLCK), errno);
    errno = 0;
    printf("F_SETLEASE on a file:   %d errno=%d\n",
           fcntl(file, F_SETLEASE, F_RDLCK), errno);
    unlink("/tmp/lease-file");
    return 0;
}
F_GETPIPE_SZ on a pipe F_SETLEASE on a pipe F_SETLEASE on a file
elfuse b57f367 -1, EINVAL 65536 65536
Linux 6.12 under qemu 65536 -1, EINVAL 0

F_SETPIPE_SZ is under the right number. It returns its argument and leaves the host pipe as it is, which the comment beside it says.

主要语言
C
星标
275
派生
29
平均合并
2 天 8 小时
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 摘要。