diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-05-05 01:25:43 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-05-05 01:26:06 +0200 |
commit | 7ce4b36d517ac5fade36240d293ff784ef6a9305 (patch) | |
tree | f0c246595251d27f62010aca770b25bb5f7ea336 /lib/fstree/src/add_by_path.c | |
parent | 7a39921d7fff089c87ac183d3c0d6e42e5cbaa04 (diff) |
Internalize fstree_mknode, consolidate fstree functionality
The fstree_mknode function is only used internally, remove the
declaration from the header and internalize it. The code using it is
consolidated into fstree.c.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/src/add_by_path.c')
-rw-r--r-- | lib/fstree/src/add_by_path.c | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/fstree/src/add_by_path.c b/lib/fstree/src/add_by_path.c deleted file mode 100644 index 344b586..0000000 --- a/lib/fstree/src/add_by_path.c +++ /dev/null @@ -1,54 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * add_by_path.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" - -#include <string.h> -#include <assert.h> -#include <errno.h> - -tree_node_t *fstree_add_generic(fstree_t *fs, const char *path, - const struct stat *sb, const char *extra) -{ - tree_node_t *child, *parent; - const char *name; - - if (*path == '\0') { - child = fs->root; - assert(child != NULL); - goto out; - } - - parent = fstree_get_node_by_path(fs, fs->root, path, true, true); - if (parent == NULL) - return NULL; - - name = strrchr(path, '/'); - name = (name == NULL ? path : (name + 1)); - - child = parent->data.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->flags & FLAG_DIR_CREATED_IMPLICITLY)) { - errno = EEXIST; - return NULL; - } - - child->uid = sb->st_uid; - child->gid = sb->st_gid; - child->mode = sb->st_mode; - child->mod_time = sb->st_mtime; - child->flags &= ~FLAG_DIR_CREATED_IMPLICITLY; - return child; - } - - return fstree_mknode(parent, name, strlen(name), extra, sb); -} |