Skip to content

Commit

Permalink
Fix logic bug: Must lstatxat if either lstats or if might recurse &
Browse files Browse the repository at this point in the history
do not yet know the i-node special type.
  • Loading branch information
c-blake committed Feb 20, 2024
1 parent 5df16ce commit 0781e36
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cligen/dents.nim
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ template forPath*(root: string; maxDepth: int; lstats, follow, xdev, eof0: bool;
copyMem path[nmAt].addr, d.d_name[0].addr, m + 1
let mayRec = maxDepth == 0 or depth + 1 < maxDepth
lst.stx_nlink = 0 # Mark Stat invalid
if mayRec and (lstats or d.d_type == DT_UNKNOWN) and
if (lstats or (mayRec and d.d_type == DT_UNKNOWN)) and
lstatxat(dfd, cast[cstring](d.d_name[0].addr), lst, 0.cint) == 0:
d.d_type = stat2dtype(lst.stx_mode) # Get d_type from Statx
dt = d.d_type
Expand Down Expand Up @@ -249,7 +249,7 @@ template forPath*(root: string; maxDepth: int; lstats, follow, xdev, eof0: bool;
copyMem path[nmAt].addr, d.d_name[0].addr, m + 1
let mayRec = maxDepth == 0 or depth + 1 < maxDepth
lst.stx_nlink = 0 # Mark Stat invalid
if mayRec and (lstats or d.d_type == DT_UNKNOWN) and
if (lstats or (mayRec and d.d_type == DT_UNKNOWN)) and
lstatxat(dfd, cast[cstring](d.d_name[0].addr), lst, 0.cint) == 0:
d.d_type = stat2dtype(lst.stx_mode) # Get d_type from Statx
dt = d.d_type
Expand Down

0 comments on commit 0781e36

Please sign in to comment.