summaryrefslogtreecommitdiff
path: root/lib/fstree/add_by_path.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-25 14:23:58 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-25 14:35:39 +0100
commitb0b88d26c9df6d336167f87ce926bba9b56f6af0 (patch)
tree39733ee0a0127380bc7b4c93cd67f6a15afc74e4 /lib/fstree/add_by_path.c
parentbd87f7c8a46cabe6d4c71d9cea74329898da31a7 (diff)
libfstree: Allow / as argument for "glob" and "dir" commands
This allows putting globbed files & directories into the filesystem root, as well as explicitly setting attributes of the root directory from the file lisiting. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/add_by_path.c')
-rw-r--r--lib/fstree/add_by_path.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/fstree/add_by_path.c b/lib/fstree/add_by_path.c
index 7c9063e..8918efc 100644
--- a/lib/fstree/add_by_path.c
+++ b/lib/fstree/add_by_path.c
@@ -17,6 +17,11 @@ tree_node_t *fstree_add_generic(fstree_t *fs, const char *path,
tree_node_t *child, *parent;
const char *name;
+ if (*path == '\0') {
+ child = fs->root;
+ goto out;
+ }
+
parent = fstree_get_node_by_path(fs, fs->root, path, true, true);
if (parent == NULL)
return NULL;
@@ -27,7 +32,7 @@ tree_node_t *fstree_add_generic(fstree_t *fs, const char *path,
child = parent->data.dir.children;
while (child != NULL && strcmp(child->name, name) != 0)
child = child->next;
-
+out:
if (child != NULL) {
if (!S_ISDIR(child->mode) || !S_ISDIR(sb->st_mode) ||
!child->data.dir.created_implicitly) {