return True;
}
+/* Make sure we really need the proc filtering using (32bit) getdents,
+ which not every linux arch implements. */
+#if defined(VGO_linux) && defined(__NR_getdents)
+
/* Filter and compact dirent entries */
static SizeT filter_dirent_entries(struct vki_dirent *dirp, SizeT orig_size)
{
return new_size;
}
+#endif /* defined(VGO_linux) && defined(__NR_getdents) */
/* Filter and compact dirent64 entries */
static SizeT filter_dirent64_entries(struct vki_dirent64 *dirp, SizeT orig_size)
return new_size;
}
+/* Make sure we really need the proc filtering using (32bit) getdents,
+ which not every linux arch implements. */
+#if defined(VGO_linux) && defined(__NR_getdents)
+
/* Filter out Valgrind's internal file descriptors from getdents results with refill capability.
When entries are filtered out, attempts to read more entries to avoid empty results.
Returns filtered size on success, or -1 if retry syscall failed. */
return new_size;
}
+#endif /* defined(VGO_linux) && defined(__NR_getdents) */
/* Filter out Valgrind's internal file descriptors from getdents64 results with refill capability.
Same logic as getdents version but for 64-bit dirent structures.
if (RES > 0) {
SizeT result_size = RES;
+ /* Make sure we really need the proc filtering using (32bit) getdents,
+ which not every linux arch implements. */
+#if defined(VGO_linux) && defined(__NR_getdents)
+
/* Only filter Valgrind FDs when listing /proc/PID/fd or /proc/PID/fdinfo directories */
if (is_proc_fd_directory(ARG1)) {
SizeT filtered_size = filter_valgrind_fds_from_getdents_with_refill(ARG1, (struct vki_dirent *)ARG2, RES, ARG3, status);
if (result_size != RES)
SET_STATUS_Success(result_size);
}
+#endif /* defined(VGO_linux) && defined(__NR_getdents) */
POST_MEM_WRITE( ARG2, result_size );
}
floored.stderr.exp floored.stdout.exp floored.vgtest \
fork.stderr.exp fork.stdout.exp fork.vgtest \
fucomip.stderr.exp fucomip.vgtest \
- getdents_filter.stderr.exp getdents_filter.stdout.exp getdents_filter.vgtest \
gxx304.stderr.exp gxx304.vgtest \
ifunc.stderr.exp ifunc.stdout.exp ifunc.vgtest \
ioctl_moans.stderr.exp ioctl_moans.vgtest \
fdleak_fcntl fdleak_ipv4 fdleak_open fdleak_pipe \
fdleak_socketpair \
floored fork fucomip \
- getdents_filter \
ioctl_moans \
libvex_test \
libvexmultiarch_test \
bug498317.stderr.exp bug498317.supp bug498317.vgtest \
bug506910.stderr.exp bug506910.vgtest \
clonev.stdout.exp clonev.stderr.exp clonev.vgtest \
+ getdents_filter.stderr.exp getdents_filter.stdout.exp getdents_filter.vgtest \
membarrier.stderr.exp membarrier.vgtest \
mremap.stderr.exp mremap.stderr.exp-glibc27 mremap.stdout.exp \
mremap.vgtest \
brk-overflow2 \
bug498317 \
clonev \
+ getdents_filter \
mremap \
mremap2 \
mremap3 \
#include <sys/syscall.h>
#include <sys/types.h>
-struct linux_dirent {
- unsigned long d_ino;
- off_t d_off;
+struct linux_dirent64 {
+ ino64_t d_ino;
+ off64_t d_off;
unsigned short d_reclen;
+ unsigned char d_type;
char d_name[];
};
int fd;
char buf[SMALL_BUF_SIZE];
long nread;
- struct linux_dirent *d;
+ struct linux_dirent64 *d;
printf("retry_test_start\n");
* may return only Valgrind FDs, which will trigger the retry mechanism.
*/
for (;;) {
- nread = syscall(SYS_getdents, fd, buf, SMALL_BUF_SIZE);
+ /* Note, using getdents64 since some linux arches don't implement
+ the 32bit getdents. */
+ nread = syscall(SYS_getdents64, fd, buf, SMALL_BUF_SIZE);
if (nread == -1) {
printf("retry_test_error\n");
/* Print client FD entries found in this buffer (excluding . and ..) */
for (size_t bpos = 0; bpos < nread;) {
- d = (struct linux_dirent *)(buf + bpos);
+ d = (struct linux_dirent64 *)(buf + bpos);
if (strcmp(d->d_name, ".") != 0 && strcmp(d->d_name, "..") != 0) {
char *endptr;
long fd_num = strtol(d->d_name, &endptr, 10);