diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-03 18:50:33 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-03 18:50:33 +0200 |
commit | da7eb3445cab5936455b8a119cb656113ca3d402 (patch) | |
tree | f3ab70532f0587788df8e691be0ec3b15db3db6c /unpack | |
parent | e981f2e460092e5ae6ad58a60869b78d7f50ec10 (diff) |
cleanup: move tree node from path function to libfstree.a
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack')
-rw-r--r-- | unpack/rdsquashfs.c | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c index 42bddff..4a0f12b 100644 --- a/unpack/rdsquashfs.c +++ b/unpack/rdsquashfs.c @@ -1,39 +1,6 @@ /* SPDX-License-Identifier: GPL-3.0-or-later */ #include "rdsquashfs.h" -static tree_node_t *find_node(tree_node_t *n, const char *path) -{ - const char *end; - size_t len; - - while (path != NULL && *path != '\0') { - if (!S_ISDIR(n->mode)) { - errno = ENOTDIR; - return NULL; - } - - end = strchrnul(path, '/'); - len = end - path; - - for (n = n->data.dir->children; n != NULL; n = n->next) { - if (strncmp(path, n->name, len) != 0) - continue; - if (n->name[len] != '\0') - continue; - break; - } - - if (n == NULL) { - errno = ENOENT; - return NULL; - } - - path = *end ? (end + 1) : end; - } - - return n; -} - int main(int argc, char **argv) { int status = EXIT_FAILURE; @@ -76,7 +43,7 @@ int main(int argc, char **argv) goto out_cmp; if (opt.cmdpath != NULL) { - n = find_node(fs.root, opt.cmdpath); + n = fstree_node_from_path(&fs, opt.cmdpath); if (n == NULL) { perror(opt.cmdpath); goto out_fs; |