diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-04-30 01:24:16 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-04-30 01:31:32 +0200 |
commit | fa7f378bf627ddcfd7a93a000149e4d8c3810bf5 (patch) | |
tree | e431943a22bc73395c4cb6a639b4243fc45f7deb /mkfs/mksquashfs.c |
Initial commit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/mksquashfs.c')
-rw-r--r-- | mkfs/mksquashfs.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/mkfs/mksquashfs.c b/mkfs/mksquashfs.c new file mode 100644 index 0000000..bc2a215 --- /dev/null +++ b/mkfs/mksquashfs.c @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +#include "squashfs.h" +#include "options.h" +#include "fstree.h" + +#include <sys/sysmacros.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <stdio.h> +#include <ctype.h> + +static void print_tree(int level, tree_node_t *node) +{ + tree_node_t *n; + int i; + + for (i = 1; i < level; ++i) { + fputs("| ", stdout); + } + + if (level) + fputs("+- ", stdout); + + if (S_ISDIR(node->mode)) { + fprintf(stdout, "%s/ (%u, %u, 0%o)\n", node->name, + node->uid, node->gid, node->mode & 07777); + + for (n = node->data.dir->children; n != NULL; n = n->next) { + print_tree(level + 1, n); + } + + if (node->data.dir->children != NULL) { + for (i = 0; i < level; ++i) + fputs("| ", stdout); + + if (level) + fputc('\n', stdout); + } + } else { + fprintf(stdout, "%s (%u, %u, 0%o)\n", node->name, + node->uid, node->gid, node->mode & 07777); + } +} + + +int main(int argc, char **argv) +{ + options_t opt; + fstree_t fs; + + process_command_line(&opt, argc, argv); + + if (fstree_init(&fs, opt.blksz, opt.def_mtime, opt.def_mode, + opt.def_uid, opt.def_gid)) { + return EXIT_FAILURE; + } + + if (fstree_from_file(&fs, opt.infile)) { + fstree_cleanup(&fs); + return EXIT_FAILURE; + } + + fstree_sort(&fs); + + print_tree(0, fs.root); + + fstree_cleanup(&fs); + return EXIT_SUCCESS; +} |