From fd2876bb4e33821c6b54d34791c74b7d1a9d68fd Mon Sep 17 00:00:00 2001
From: Luis Gerhorst <luis.gerhorst@fau.de>
Date: Wed, 15 Dec 2021 10:39:21 +0100
Subject: [PATCH] du: Reuse name_user buffer for child name

---
 src/task_find.bpf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/task_find.bpf.c b/src/task_find.bpf.c
index 0b1a802..73d3cd2 100644
--- a/src/task_find.bpf.c
+++ b/src/task_find.bpf.c
@@ -46,7 +46,8 @@ static long iter_dir(uint32_t d_type, size_t namelen, bool match) {
 	}
 	int parent_dfd = dfd[depth];
 
-	void *name_user = u_iterdents64_buf + depth * PATHLEN;
+	/* void *name_user = u_iterdents64_buf + depth * PATHLEN; */
+	void *name_user = u_iterdents64_buf;
 	if (match) {
 		if (flags & PRINT_MATCHES) {
 			write(STDOUT_FILENO, name_user, namelen);
@@ -84,7 +85,8 @@ static long iter_dir(uint32_t d_type, size_t namelen, bool match) {
 	}
 
 	unsigned long child_depth = depth + 1;
-	void *child_name_user = u_iterdents64_buf + child_depth * PATHLEN;
+	/* void *child_name_user = u_iterdents64_buf + child_depth * PATHLEN; */
+	void *child_name_user = name_user;
 
 	curr_depth = child_depth;
 	dfd[curr_depth] = child_dfd;
-- 
GitLab