This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
getdents64 fallback d_type support
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 15 Sep 2010 21:11:05 +0000 (UTC)
- Subject: getdents64 fallback d_type support
There is code in sysdeps/unix/sysv/linux/getdents.c to set d_type when
using the 32-bit syscall if __ASSUME_GETDENTS32_D_TYPE. There is also
code to implement getdents64 using the 32-bit syscall when the
getdents64 syscall is not available - but that copy of the code is
missing the support for setting d_type, instead always setting it to
DT_UNKNOWN. If this case arises, it breaks __get_nprocs_conf in
getsysstats.c, which relies on d_type being set by __readdir64. This
patch adds the d_type support in this case. (When getdents64 is known
at compile time to be available, this code is unreachable and will be
compiled out.)
2010-09-15 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/getdents.c (__GETDENTS): When
implementing getdents64 using getdents syscall, set d_type if
__ASSUME_GETDENTS32_D_TYPE.
diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c
index b33d178..a9170f1 100644
--- a/sysdeps/unix/sysv/linux/getdents.c
+++ b/sysdeps/unix/sysv/linux/getdents.c
@@ -285,7 +285,11 @@ __GETDENTS (int fd, char *buf, size_t nbytes)
DIRENT_SET_DP_INO(dp, kdp->d_ino);
dp->d_off = kdp->d_off;
dp->d_reclen = new_reclen;
+#ifdef __ASSUME_GETDENTS32_D_TYPE
+ dp->d_type = *((char *) kdp + kdp->d_reclen - 1);
+#else
dp->d_type = DT_UNKNOWN;
+#endif
memcpy (dp->d_name, kdp->d_name,
kdp->d_reclen - offsetof (struct kernel_dirent, d_name));
--
Joseph S. Myers
joseph@codesourcery.com