From: Bruno Haible <bruno@clisp.org>
To: cygwin@cygwin.com
Subject: wrong errno value set by readlinkat()
Date: Tue, 18 Apr 2023 12:21:43 +0200 [thread overview]
Message-ID: <12553230.hYdu0Ggh8K@nimes> (raw)
Hi,
When an empty path argument is passed to the readlinkat() function,
POSIX:2018 specifies that the function fails with error ENOENT:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html
"These functions shall fail if:
...
[ENOENT]
A component of path does not name an existing file or path is an empty
string."
In Cygwin 3.4.6, readlinkat() fails with error EBADF instead.
How to reproduce:
============================== foo.c ===================================
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main ()
{
char buf[80];
int ret = readlinkat (AT_FDCWD, "", buf, sizeof (buf));
int err = errno;
printf ("ret = %d, errno = %d = \"%s\"\n", ret, err, strerror (err));
return 0;
}
========================================================================
$ gcc -Wall foo.c
$ ./a.exe
Expected output:
ret = -1, errno = 2 = "No such file or directory"
Actual output:
ret = -1, errno = 9 = "Bad file descriptor"
Bruno
next reply other threads:[~2023-04-18 10:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 10:21 Bruno Haible [this message]
2023-04-18 11:56 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12553230.hYdu0Ggh8K@nimes \
--to=bruno@clisp.org \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).