diff options
Diffstat (limited to 'lib/fstree/fstree_from_dir.c')
-rw-r--r-- | lib/fstree/fstree_from_dir.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c index 0c56148..7301d91 100644 --- a/lib/fstree/fstree_from_dir.c +++ b/lib/fstree/fstree_from_dir.c @@ -52,7 +52,8 @@ fail: return NULL; } -static int populate_dir(fstree_t *fs, tree_node_t *root, unsigned int flags) +static int populate_dir(fstree_t *fs, tree_node_t *root, dev_t devstart, + unsigned int flags) { char *extra = NULL; struct dirent *ent; @@ -86,6 +87,9 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, unsigned int flags) goto fail; } + if ((flags & DIR_SCAN_ONE_FILESYSTEM) && sb.st_dev != devstart) + continue; + if (S_ISLNK(sb.st_mode)) { extra = calloc(1, sb.st_size + 1); if (extra == NULL) @@ -122,7 +126,7 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, unsigned int flags) if (pushd(n->name)) return -1; - if (populate_dir(fs, n, flags)) + if (populate_dir(fs, n, devstart, flags)) return -1; if (popd()) @@ -141,12 +145,18 @@ fail: int fstree_from_dir(fstree_t *fs, const char *path, unsigned int flags) { + struct stat sb; int ret; + if (stat(path, &sb)) { + perror(path); + return -1; + } + if (pushd(path)) return -1; - ret = populate_dir(fs, fs->root, flags); + ret = populate_dir(fs, fs->root, sb.st_dev, flags); if (popd()) ret = -1; |