diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-04-30 12:26:09 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-05-02 12:40:06 +0200 |
commit | 02232ffdbd7b927b71a9f38f4b78bbf99c675ec5 (patch) | |
tree | 228e5c749ce767f33b67f51cdc41c726cd1bb696 /mkfs/mksquashfs.c | |
parent | 0e3c3e7f8dc80c37a80d14942621206c0c4f7de3 (diff) |
Add super block and padding functions
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/mksquashfs.c')
-rw-r--r-- | mkfs/mksquashfs.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/mkfs/mksquashfs.c b/mkfs/mksquashfs.c index bc2a215..17de4ed 100644 --- a/mkfs/mksquashfs.c +++ b/mkfs/mksquashfs.c @@ -1,14 +1,5 @@ /* 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> +#include "mksquashfs.h" static void print_tree(int level, tree_node_t *node) { @@ -43,28 +34,49 @@ static void print_tree(int level, tree_node_t *node) } } - int main(int argc, char **argv) { + int outfd, status = EXIT_FAILURE; + sqfs_super_t super; 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)) { + if (sqfs_super_init(&super, &opt) != 0) return EXIT_FAILURE; - } - if (fstree_from_file(&fs, opt.infile)) { - fstree_cleanup(&fs); + outfd = open(opt.outfile, opt.outmode, 0644); + if (outfd < 0) { + perror(opt.outfile); return EXIT_FAILURE; } + if (sqfs_super_write(&super, outfd)) + goto out_outfd; + + if (fstree_init(&fs, opt.blksz, opt.def_mtime, opt.def_mode, + opt.def_uid, opt.def_gid)) { + goto out_outfd; + } + + if (fstree_from_file(&fs, opt.infile)) + goto out_fstree; + fstree_sort(&fs); print_tree(0, fs.root); + if (sqfs_super_write(&super, outfd)) + goto out_outfd; + + if (sqfs_padd_file(&super, &opt, outfd)) + goto out_fstree; + + status = EXIT_SUCCESS; +out_fstree: fstree_cleanup(&fs); - return EXIT_SUCCESS; +out_outfd: + close(outfd); + return status; } |