This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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  <>

	* sysdeps/unix/sysv/linux/getdents.c (__GETDENTS): When
	implementing getdents64 using getdents syscall, set d_type if

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;
+	dp->d_type = *((char *) kdp + kdp->d_reclen - 1);
 	dp->d_type = DT_UNKNOWN;
 	memcpy (dp->d_name, kdp->d_name,
 		kdp->d_reclen - offsetof (struct kernel_dirent, d_name));

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]