* sysdeps/unix/sysv/linux/openat.c (__atfct_seterrno): Use the same
fstat check for ENOENT that should be EBADF as for ENOTDIR, and also check for missing /proc the same way.
This commit is contained in:
parent
30c14fdb7b
commit
212ab55aaa
|
@ -1,5 +1,9 @@
|
||||||
2006-02-02 Roland McGrath <roland@redhat.com>
|
2006-02-02 Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/openat.c (__atfct_seterrno): Use the same
|
||||||
|
fstat check for ENOENT that should be EBADF as for ENOTDIR, and also
|
||||||
|
check for missing /proc the same way.
|
||||||
|
|
||||||
* include/errno.h [__cplusplus]: Avoid extra header magic for C++.
|
* include/errno.h [__cplusplus]: Avoid extra header magic for C++.
|
||||||
|
|
||||||
* manual/install.texi (Tools for Compilation): Require gcc 3.4,
|
* manual/install.texi (Tools for Compilation): Require gcc 3.4,
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#if !defined OPENAT && !defined __ASSUME_ATFCTS
|
#if !defined OPENAT && !defined __ASSUME_ATFCTS
|
||||||
# define OPENAT openat
|
# define OPENAT openat
|
||||||
|
|
||||||
|
/* Set errno after a failed call. If BUF is not null,
|
||||||
|
it is a /proc/self/fd/ path name we just tried to use. */
|
||||||
void
|
void
|
||||||
attribute_hidden
|
attribute_hidden
|
||||||
__atfct_seterrno (int errval, int fd, const char *buf)
|
__atfct_seterrno (int errval, int fd, const char *buf)
|
||||||
|
@ -39,7 +40,7 @@ __atfct_seterrno (int errval, int fd, const char *buf)
|
||||||
{
|
{
|
||||||
struct stat64 st;
|
struct stat64 st;
|
||||||
|
|
||||||
if (errval == ENOTDIR)
|
if (errval == ENOTDIR || errval == ENOENT)
|
||||||
{
|
{
|
||||||
/* 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. */
|
||||||
|
@ -48,23 +49,11 @@ __atfct_seterrno (int errval, int fd, const char *buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If /proc is not mounted there is nothing we can do. */
|
/* If /proc is not mounted there is nothing we can do. */
|
||||||
if (S_ISDIR (st.st_mode)
|
if ((errval != ENOTDIR || S_ISDIR (st.st_mode))
|
||||||
&& (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0
|
&& (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0
|
||||||
|| !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 = __lxstat64 (_STAT_VER, buf, &st);
|
|
||||||
if ((e == -1 && errno == ENOENT)
|
|
||||||
||(e == 0 && !S_ISLNK (st.st_mode)))
|
|
||||||
errval = EBADF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__set_errno (errval);
|
__set_errno (errval);
|
||||||
|
|
Loading…
Reference in New Issue