summaryrefslogtreecommitdiff
path: root/libmisc/walk_tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmisc/walk_tree.c')
-rw-r--r--libmisc/walk_tree.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c
index 47b2b25..e9a942f 100644
--- a/libmisc/walk_tree.c
+++ b/libmisc/walk_tree.c
@@ -49,6 +49,7 @@ struct walk_tree_args {
struct entry_handle *closed;
unsigned int num_dir_handles;
struct stat st;
+ dev_t dev;
};
static int walk_tree_visited(struct entry_handle *dirs, dev_t dev, ino_t ino)
@@ -81,6 +82,14 @@ static int walk_tree_rec(struct walk_tree_args *args)
if (lstat(args->path, &args->st) != 0)
return args->func(args->path, NULL, flags | WALK_TREE_FAILED,
args->arg);
+
+ if (flags & WALK_TREE_ONE_FILESYSTEM) {
+ if (args->dev == 0)
+ args->dev = args->st.st_dev;
+ else if (args->st.st_dev != args->dev)
+ return 0;
+ }
+
if (S_ISLNK(args->st.st_mode)) {
flags |= WALK_TREE_SYMLINK;
if ((flags & WALK_TREE_DEREFERENCE) ||
@@ -244,6 +253,7 @@ int walk_tree(const char *path, int walk_flags, unsigned int num,
args.func = func;
args.arg = arg;
args.depth = 0;
+ args.dev = 0;
return walk_tree_rec(&args);
}