aboutsummaryrefslogtreecommitdiff
path: root/bin/gensquashfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'bin/gensquashfs/src')
-rw-r--r--bin/gensquashfs/src/fstree_from_dir.c44
-rw-r--r--bin/gensquashfs/src/glob.c7
-rw-r--r--bin/gensquashfs/src/mkfs.c2
-rw-r--r--bin/gensquashfs/src/mkfs.h10
4 files changed, 8 insertions, 55 deletions
diff --git a/bin/gensquashfs/src/fstree_from_dir.c b/bin/gensquashfs/src/fstree_from_dir.c
deleted file mode 100644
index 40b4061..0000000
--- a/bin/gensquashfs/src/fstree_from_dir.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * fstree_from_dir.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "mkfs.h"
-
-int fstree_from_dir(fstree_t *fs, sqfs_dir_iterator_t *dir)
-{
- for (;;) {
- sqfs_dir_entry_t *ent = NULL;
- tree_node_t *n = NULL;
- char *extra = NULL;
-
- int ret = dir->next(dir, &ent);
- if (ret > 0)
- break;
- if (ret < 0) {
- sqfs_perror("readdir", NULL, ret);
- return -1;
- }
-
- if (S_ISLNK(ent->mode)) {
- ret = dir->read_link(dir, &extra);
- if (ret) {
- sqfs_perror("readlink", ent->name, ret);
- free(ent);
- return -1;
- }
- }
-
- n = fstree_add_generic(fs, ent, extra);
- free(extra);
- free(ent);
-
- if (n == NULL) {
- perror("creating tree node");
- return -1;
- }
- }
-
- return 0;
-}
diff --git a/bin/gensquashfs/src/glob.c b/bin/gensquashfs/src/glob.c
index bc6edee..73f078b 100644
--- a/bin/gensquashfs/src/glob.c
+++ b/bin/gensquashfs/src/glob.c
@@ -64,8 +64,8 @@ static bool set_scan_flag(const char *arg, dir_tree_cfg_t *cfg)
return false;
}
-static int scan_directory(fstree_t *fs, sqfs_dir_iterator_t *dir,
- size_t prefix_len, const char *file_prefix)
+int scan_directory(fstree_t *fs, sqfs_dir_iterator_t *dir,
+ size_t prefix_len, const char *file_prefix)
{
for (;;) {
sqfs_dir_entry_t *ent = NULL;
@@ -96,7 +96,8 @@ static int scan_directory(fstree_t *fs, sqfs_dir_iterator_t *dir,
free(ent);
return -1;
}
- } else if (S_ISREG(ent->mode)) {
+ } else if (S_ISREG(ent->mode) &&
+ (prefix_len > 0 || file_prefix != NULL)) {
const char *src;
/* skip the prefix, get the name actually
diff --git a/bin/gensquashfs/src/mkfs.c b/bin/gensquashfs/src/mkfs.c
index 320e250..488d015 100644
--- a/bin/gensquashfs/src/mkfs.c
+++ b/bin/gensquashfs/src/mkfs.c
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
if (dir == NULL)
goto out;
- ret = fstree_from_dir(&sqfs.fs, dir);
+ ret = scan_directory(&sqfs.fs, dir, 0, NULL);
sqfs_drop(dir);
if (ret != 0)
goto out;
diff --git a/bin/gensquashfs/src/mkfs.h b/bin/gensquashfs/src/mkfs.h
index 437198b..a762966 100644
--- a/bin/gensquashfs/src/mkfs.h
+++ b/bin/gensquashfs/src/mkfs.h
@@ -104,15 +104,11 @@ int fstree_from_file(fstree_t *fs, const char *filename, const options_t *opt);
int fstree_from_file_stream(fstree_t *fs, sqfs_istream_t *file,
const options_t *opt);
-/*
- Recursively scan a directory to build a file system tree.
-
- Returns 0 on success, prints to stderr on failure.
- */
-int fstree_from_dir(fstree_t *fs, sqfs_dir_iterator_t *dir);
-
int fstree_sort_files(fstree_t *fs, sqfs_istream_t *sortfile);
+int scan_directory(fstree_t *fs, sqfs_dir_iterator_t *dir,
+ size_t prefix_len, const char *file_prefix);
+
int glob_files(fstree_t *fs, const char *filename, size_t line_num,
const sqfs_dir_entry_t *ent,
const char *basepath, unsigned int glob_flags,