diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-01-24 10:11:16 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-01-29 16:07:39 +0100 |
commit | f47425873fad94d3e7add4c7d5c48c2f7c67dbe5 (patch) | |
tree | 6c6990e09aa1110f843b2ee2e4e3bb101a86432b /bin | |
parent | 45e0d72a6778af21174771faa08032cf76eca090 (diff) |
tar2sqfs: Backport exclude filtering logic
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin')
-rw-r--r-- | bin/tar2sqfs/process_tarball.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/tar2sqfs/process_tarball.c b/bin/tar2sqfs/process_tarball.c index c0ae5a3..51bef41 100644 --- a/bin/tar2sqfs/process_tarball.c +++ b/bin/tar2sqfs/process_tarball.c @@ -6,6 +6,16 @@ */ #include "tar2sqfs.h" +static bool is_excluded(const char *name) +{ + for (size_t i = 0; i < num_excludedirs; ++i) { + if (fnmatch(excludedirs[i], name, 0) == 0) + return true; + } + + return false; +} + static int write_file(istream_t *input_file, sqfs_writer_t *sqfs, const tar_header_decoded_t *hdr, file_info_t *fi, sqfs_u64 filesize) @@ -237,6 +247,11 @@ int process_tarball(istream_t *input_file, sqfs_writer_t *sqfs) fprintf(stderr, "skipping '%s' (invalid name)\n", hdr.name); skip = true; + } else if (is_excluded(hdr.name)) { + if (skip_entry(input_file, hdr.record_size)) + goto fail; + clear_header(&hdr); + continue; } else if (root_becomes != NULL) { if (strncmp(hdr.name, root_becomes, rootlen) == 0) { if (hdr.name[rootlen] == '\0') { |