From 9c0a5630795690492dd1d372d69d06430e138fac Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 8 Jul 2017 20:00:47 -0400 Subject: bftw: Fix ENAMETOOLONG handling when the root is closed The root has depth == 0, but we still need to include it in the components array. --- bftw.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bftw.c') 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; } -- cgit v1.2.3