Opened 3 months ago

Last modified 3 months ago

#19058 closed bug

renameat() does not fail with EBADF when it should — at Version 1

Reported by: bhaible Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/POSIX Version: R1/beta5
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by bhaible)

POSIX https://pubs.opengroup.org/onlinepubs/9799919799/functions/rename.html specifies that the renameat() function "shall fail" with error code EBADF if "The old argument does not specify an absolute path and the oldfd argument is neither AT_FDCWD nor a valid file descriptor open for reading or searching, or the new argument does not specify an absolute path and the newfd argument is neither AT_FDCWD nor a valid file descriptor open for reading or searching."

This does not work in Haiku hrev57823 (from 2024-07-15): in one case, it behaves as if AT_FDCWD had been specified; in the other case, it fails with error code ENOENT instead.

How to reproduce: Compile and run the attached test program.

gcc -Wall foo.c
./a.out

Expected output:

ret = -1, errno == EBADF
ret = -1, errno == EBADF
OK

Actual output if a file 'foo' does not exist in the current directory:

ret = -1, errno == No such file or directory
ret = -1, errno == No such file or directory
a.out: foo.c:41:main: !fail
Kill Thread

Actual output if a file 'foo' does exist in the current directory:

ret = 0
ret = -1, errno == No such file or directory
a.out: foo.c:41:main: !fail
Kill Thread

Change History (2)

by bhaible, 3 months ago

Attachment: foo.c added

test case foo.c

comment:1 by bhaible, 3 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.