From 725949af79cbbf359e90c93e88bf184c6114a502 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 28 Apr 2023 15:23:28 +0200 Subject: gensquashfs: Remove fstree_from_subdir It is only used in the glob function, so assemble the path there and jus tuse fstree_from_dir. Signed-off-by: David Oberhollenzer --- bin/gensquashfs/src/fstree_from_file.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'bin/gensquashfs/src/fstree_from_file.c') diff --git a/bin/gensquashfs/src/fstree_from_file.c b/bin/gensquashfs/src/fstree_from_file.c index d051737..34fcf83 100644 --- a/bin/gensquashfs/src/fstree_from_file.c +++ b/bin/gensquashfs/src/fstree_from_file.c @@ -232,6 +232,12 @@ static int glob_files(fstree_t *fs, const char *filename, size_t line_num, return -1; } + if (!S_ISDIR(root->mode)) { + fprintf(stderr, "%s: " PRI_SZ ": %s is not a directoy!\n", + filename, line_num, path); + return -1; + } + /* process options */ first_clear_flag = true; @@ -333,9 +339,25 @@ static int glob_files(fstree_t *fs, const char *filename, size_t line_num, &ctx, scan_flags); } } else { - ret = fstree_from_subdir(fs, root, basepath, extra, - glob_node_callback, &ctx, - scan_flags); + size_t plen = strlen(basepath); + size_t slen = strlen(extra); + char *temp = calloc(1, plen + 1 + slen + 1); + + if (temp == NULL) { + fprintf(stderr, "%s: " PRI_SZ ": allocation failure.\n", + filename, line_num); + ret = -1; + } else { + memcpy(temp, basepath, plen); + temp[plen] = '/'; + memcpy(temp + plen + 1, extra, slen); + temp[plen + 1 + slen] = '\0'; + + ret = fstree_from_dir(fs, root, temp, + glob_node_callback, &ctx, + scan_flags); + free(temp); + } } free(ctx.name_pattern); -- cgit v1.2.3