Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#422 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Start in sys_fcntl in src/syscall/fs.c, where the switch uses case 1024 for F_GETPIPE_SZ, and compare its command numbers with Linux's F_LINUX_SPECIFIC_BASE offsets from the issue. Compile the reproducer and run it on a pipe and a regular file. Done when F_GETPIPE_SZ returns the pipe size, F_SETLEASE on a pipe returns EINVAL, and F_SETLEASE on a file returns 0, matching the Linux row in the table.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C
Stars
275
Forks
29
Avg merge
2d 22h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/elfuse

All issues in sysprog21/elfuse

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.