aboutsummaryrefslogtreecommitdiff
path: root/sys/libn/fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/libn/fs.c')
-rw-r--r--sys/libn/fs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/libn/fs.c b/sys/libn/fs.c
index 5d06997..10cd93e 100644
--- a/sys/libn/fs.c
+++ b/sys/libn/fs.c
@@ -6,7 +6,6 @@
/*
* path history
*/
-
struct Key
{
ino_t ino;
@@ -151,9 +150,14 @@ fs·walk(fs·Walker *fs)
return;
}
- /* operate on directory if preorder traversal */
- if (fs->flags & fs·preorder)
- fs->func(fs->data, fs->base, fs->path, &cwd);
+ /*
+ * operate on directory first if preorder traversal
+ * truncate recursion if callback returns an error code
+ */
+ if (fs->flags & fs·preorder) {
+ if (fs->func(fs->data, fs->base, fs->path, &cwd))
+ return;
+ }
/* open directory */
if(!fs->max || fs->lev + 1 < fs->max) {