summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/bftw.c b/bftw.c
index b7e2577..8c8e12e 100644
--- a/bftw.c
+++ b/bftw.c
@@ -363,8 +363,13 @@ static int dircache_entry_open(struct dircache *cache, struct dircache_entry *en
// Handle ENAMETOOLONG by manually traversing the path component-by-component
- size_t offset = base ? base->depth : 0;
- size_t levels = entry->depth - offset;
+ size_t levels = entry->depth;
+ if (base) {
+ levels -= base->depth;
+ } else {
+ // The command-line root has depth == 0, but we need to include it
+ levels += 1;
+ }
if (levels < 2) {
return fd;
}