This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
getdents() is failed on kernel 2.2.x
- From: GOTO Masanori <gotom at debian dot or dot jp>
- To: libc-alpha at sources dot redhat dot com
- Cc: gotom at debian dot org
- Date: Wed, 25 Dec 2002 00:18:34 +0900
- Subject: getdents() is failed on kernel 2.2.x
The current libc getdents() fails with "function not implemented"
message, only on kernel 2.2.x, due to getdents() returning value
check bug.
Kernel 2.2.x does not have getdents64(), so kernel returns ENOSYS,
then glibc should fall back to try getdents() system call, but
currently it fails. Kernel 2.4.x has getdents64(), so no problem.
The problem is occured recently by below change.
2002-12-01 Roland McGrath <roland@redhat.com>
* sysdeps/unix/sysv/linux/getdents.c (__GETDENTS): Fix condition
testing getdents64 return value.
--- sysdeps/unix/sysv/linux/getdents.c 3 Nov 2002 03:47:49 -0000 1.19
+++ sysdeps/unix/sysv/linux/getdents.c 2 Dec 2002 21:01:50 -0000 1.20
@@ -126,7 +126,7 @@
retval = INLINE_SYSCALL (getdents64, 3, fd, CHECK_N(kbuf, kbytes),
kbytes);
# ifndef __ASSUME_GETDENTS64_SYSCALL
- if (retval != -1 && errno != -EINVAL)
+ if (retval != -1 || errno != EINVAL)
# endif
{
const size_t size_diff = (offsetof (struct kernel_dirent64, d_name)
This patch fixes getdents() error checking bug, on the contrary if
retval == -1 && errno == ENOSYS (on kernel 2.2), then this function
returns error.
Below patch fixes the problem, please apply it.
2002-12-24 GOTO Masanori <gotom@debian.or.jp>
* sysdeps/unix/sysv/linux/getdents.c (__GETDENTS): Fix condition
checking of return value ENOSYS from getdents64.
--- sysdeps/unix/sysv/linux/getdents.c.org 2002-12-14 02:09:29.000000000 +0900
+++ sysdeps/unix/sysv/linux/getdents.c 2002-12-23 02:15:12.000000000 +0900
@@ -126,7 +126,7 @@
retval = INLINE_SYSCALL (getdents64, 3, fd, CHECK_N(kbuf, kbytes),
kbytes);
# ifndef __ASSUME_GETDENTS64_SYSCALL
- if (retval != -1 || errno != EINVAL)
+ if (retval != -1 || (errno != EINVAL && errno != ENOSYS))
# endif
{
const size_t size_diff = (offsetof (struct kernel_dirent64, d_name)
Regards,
-- gotom