diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-07-08 20:00:47 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-07-08 20:00:47 -0400 |
commit | 9c0a5630795690492dd1d372d69d06430e138fac (patch) | |
tree | 37b5b08ccf05d665c2876591eeaadeea0d86afc8 /bftw.c | |
parent | e991bc786af40623ae118eab9d400d6cd391d8c6 (diff) | |
download | bfs-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.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; } |