[hackers] [sbase][PATCH] du: recurse: fix path

From: Richard Ipsum <richardipsum_AT_vx21.xyz>
Date: Wed, 3 Jun 2020 12:45:15 +0100

path is not fixed up on exit from recursive step, this leads to
incorrect paths in du's output.

% find D
D
D/E
D/E/F
D/E/F/a2
D/E/F/b2
D/E/a1
D/E/b1
D/a
D/b

% du D
4 D/E/F
8 D/E
12 D

% ~/sbase/du D
4 D/E/F/b2
8 D/E/b1
12 D
---
 libutil/recurse.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/libutil/recurse.c b/libutil/recurse.c
index e21d815..c024b3a 100644
--- a/libutil/recurse.c
+++ b/libutil/recurse.c
_AT_@ -90,6 +90,7 @@ recurse(int dirfd, const char *name, void *data, struct recursor *r)
 				r->depth--;
 			}
 		}
+		r->path[pathlen - 1] = '\0';
 		closedir(dp);
 	}
 
-- 
2.26.2
Received on Wed Jun 03 2020 - 13:45:15 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 03 2020 - 14:24:31 CEST