diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-28 15:23:28 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-29 00:26:32 +0200 |
commit | 725949af79cbbf359e90c93e88bf184c6114a502 (patch) | |
tree | 9275b5c0032e7be8d51731bc64777e06614092a3 /bin/gensquashfs/src/fstree_from_file.c | |
parent | 11e36726f61e8615bb873c2d322d85dafcd73e7b (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/src/fstree_from_file.c')
-rw-r--r-- | bin/gensquashfs/src/fstree_from_file.c | 28 |
1 files changed, 25 insertions, 3 deletions
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); |