summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-07-08 20:00:47 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-07-08 20:00:47 -0400
commit9c0a5630795690492dd1d372d69d06430e138fac (patch)
tree37b5b08ccf05d665c2876591eeaadeea0d86afc8 /bftw.c
parente991bc786af40623ae118eab9d400d6cd391d8c6 (diff)
downloadbfs-9c0a5630795690492dd1d372d69d06430e138fac.tar.xz
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.
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;
}