Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#430 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, linux, macos

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
C
Stelle
273
Fork
29
Merge medio
2g 17h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sysprog21/elfuse

Tutte le issue di sysprog21/elfuse

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.