mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
(__atfct_seterrno): Correcty return EBADF for non-existing file descriptors.
This commit is contained in:
@ -35,11 +35,14 @@ void
|
|||||||
attribute_hidden
|
attribute_hidden
|
||||||
__atfct_seterrno (int errval, int fd, const char *buf)
|
__atfct_seterrno (int errval, int fd, const char *buf)
|
||||||
{
|
{
|
||||||
if (buf != NULL && errval == ENOTDIR)
|
if (buf != NULL)
|
||||||
|
{
|
||||||
|
struct stat64 st;
|
||||||
|
|
||||||
|
if (errval == ENOTDIR)
|
||||||
{
|
{
|
||||||
/* This can mean either the file descriptor is invalid or
|
/* This can mean either the file descriptor is invalid or
|
||||||
/proc is not mounted. */
|
/proc is not mounted. */
|
||||||
struct stat64 st;
|
|
||||||
if (__fxstat64 (_STAT_VER, fd, &st) != 0)
|
if (__fxstat64 (_STAT_VER, fd, &st) != 0)
|
||||||
/* errno is already set correctly. */
|
/* errno is already set correctly. */
|
||||||
return;
|
return;
|
||||||
@ -50,6 +53,19 @@ __atfct_seterrno (int errval, int fd, const char *buf)
|
|||||||
|| !S_ISDIR (st.st_mode)))
|
|| !S_ISDIR (st.st_mode)))
|
||||||
errval = ENOSYS;
|
errval = ENOSYS;
|
||||||
}
|
}
|
||||||
|
else if (errval == ENOENT)
|
||||||
|
{
|
||||||
|
/* This could mean the file descriptor is not valid. We
|
||||||
|
reuse BUF for the stat call. Find the slash after the
|
||||||
|
file descriptor number. */
|
||||||
|
*(char *) strchr (buf + sizeof "/proc/self/fd", '/') = '\0';
|
||||||
|
|
||||||
|
int e = __xstat64 (_STAT_VER, buf, &st);
|
||||||
|
if ((e == -1 && errno == ENOENT)
|
||||||
|
||(e == 0 && !S_ISLNK (st.st_mode)))
|
||||||
|
errval = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
__set_errno (errval);
|
__set_errno (errval);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user