summaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-11 00:44:05 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-11 00:45:34 +0200
commitb54d026f982a9f6c62d3276908a3fbc3cc628a9d (patch)
tree922c28b4aa43f0248ccce7f092943e1ab30227e4 /lib/fstree
parenteb01ccca21a9a2e1693b28871f65934e8931e3bf (diff)
Add --one-file-system option to gensquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/fstree_from_dir.c16
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;