summaryrefslogtreecommitdiff
path: root/mkfs/mkfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-11 12:56:22 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-11 13:00:25 +0200
commit99b153177dbac8689b2e58fc29530727fa7e00fc (patch)
treef6e7c0fd060c51c7e25fe76138ceb5abfbe002a2 /mkfs/mkfs.c
parent223dcc487cb0115d3ccb0dd6464d20346253a43e (diff)
cleanup: remove rest of sqfs_info_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/mkfs.c')
-rw-r--r--mkfs/mkfs.c93
1 files changed, 45 insertions, 48 deletions
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 50e2ce5..86172e3 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -2,16 +2,16 @@
#include "mkfs.h"
#include "util.h"
-static int padd_file(sqfs_info_t *info)
+static int padd_file(int outfd, sqfs_super_t *super, options_t *opt)
{
- size_t padd_sz = info->super.bytes_used % info->opt.devblksz;
+ size_t padd_sz = super->bytes_used % opt->devblksz;
uint8_t *buffer;
ssize_t ret;
if (padd_sz == 0)
return 0;
- padd_sz = info->opt.devblksz - padd_sz;
+ padd_sz = opt->devblksz - padd_sz;
buffer = calloc(1, padd_sz);
if (buffer == NULL) {
@@ -19,7 +19,7 @@ static int padd_file(sqfs_info_t *info)
return -1;
}
- ret = write_retry(info->outfd, buffer, padd_sz);
+ ret = write_retry(outfd, buffer, padd_sz);
if (ret < 0) {
perror("Error padding squashfs image to page size");
@@ -41,113 +41,110 @@ int main(int argc, char **argv)
{
int status = EXIT_FAILURE, ret;
data_writer_t *data;
- sqfs_info_t info;
+ sqfs_super_t super;
+ compressor_t *cmp;
+ id_table_t idtbl;
+ options_t opt;
+ fstree_t fs;
+ int outfd;
- memset(&info, 0, sizeof(info));
+ process_command_line(&opt, argc, argv);
- process_command_line(&info.opt, argc, argv);
-
- if (sqfs_super_init(&info.super, info.opt.blksz, info.opt.def_mtime,
- info.opt.compressor)) {
+ if (sqfs_super_init(&super, opt.blksz, opt.def_mtime, opt.compressor))
return EXIT_FAILURE;
- }
- if (id_table_init(&info.idtbl))
+ if (id_table_init(&idtbl))
return EXIT_FAILURE;
- info.outfd = open(info.opt.outfile, info.opt.outmode, 0644);
- if (info.outfd < 0) {
- perror(info.opt.outfile);
+ outfd = open(opt.outfile, opt.outmode, 0644);
+ if (outfd < 0) {
+ perror(opt.outfile);
goto out_idtbl;
}
- if (sqfs_super_write(&info.super, info.outfd))
+ if (sqfs_super_write(&super, outfd))
goto out_outfd;
- if (fstree_init(&info.fs, info.opt.blksz, info.opt.def_mtime,
- info.opt.def_mode, info.opt.def_uid,
- info.opt.def_gid)) {
+ if (fstree_init(&fs, opt.blksz, opt.def_mtime, opt.def_mode,
+ opt.def_uid, opt.def_gid)) {
goto out_outfd;
}
- if (info.opt.infile != NULL) {
- if (fstree_from_file(&info.fs, info.opt.infile, info.opt.packdir))
+ if (opt.infile != NULL) {
+ if (fstree_from_file(&fs, opt.infile, opt.packdir))
goto out_fstree;
} else {
- if (fstree_from_dir(&info.fs, info.opt.packdir))
+ if (fstree_from_dir(&fs, opt.packdir))
goto out_fstree;
}
#ifdef WITH_SELINUX
- if (info.opt.selinux != NULL) {
- if (fstree_relabel_selinux(&info.fs, info.opt.selinux))
+ if (opt.selinux != NULL) {
+ if (fstree_relabel_selinux(&fs, opt.selinux))
goto out_fstree;
}
#endif
- fstree_xattr_deduplicate(&info.fs);
+ fstree_xattr_deduplicate(&fs);
- fstree_sort(&info.fs);
+ fstree_sort(&fs);
- if (fstree_gen_inode_table(&info.fs))
+ if (fstree_gen_inode_table(&fs))
goto out_fstree;
- info.super.inode_count = info.fs.inode_tbl_size - 2;
+ super.inode_count = fs.inode_tbl_size - 2;
- info.cmp = compressor_create(info.super.compression_id, true,
- info.super.block_size,
- info.opt.comp_extra);
- if (info.cmp == NULL) {
+ cmp = compressor_create(super.compression_id, true, super.block_size,
+ opt.comp_extra);
+ if (cmp == NULL) {
fputs("Error creating compressor\n", stderr);
goto out_outfd;
}
- ret = info.cmp->write_options(info.cmp, info.outfd);
+ ret = cmp->write_options(cmp, outfd);
if (ret < 0)
goto out_cmp;
if (ret > 0) {
- info.super.flags |= SQFS_FLAG_COMPRESSOR_OPTIONS;
- info.super.bytes_used += ret;
+ super.flags |= SQFS_FLAG_COMPRESSOR_OPTIONS;
+ super.bytes_used += ret;
}
- data = data_writer_create(&info.super, info.cmp, info.outfd);
+ data = data_writer_create(&super, cmp, outfd);
if (data == NULL)
goto out_cmp;
- if (write_data_to_image(data, &info))
+ if (write_data_to_image(data, &fs, &opt))
goto out_data;
- if (sqfs_serialize_fstree(info.outfd, &info.super, &info.fs,
- info.cmp, &info.idtbl)) {
+ if (sqfs_serialize_fstree(outfd, &super, &fs, cmp, &idtbl))
goto out_data;
- }
if (data_writer_write_fragment_table(data))
goto out_data;
- if (id_table_write(&info.idtbl, info.outfd, &info.super, info.cmp))
+ if (id_table_write(&idtbl, outfd, &super, cmp))
goto out_data;
- if (write_xattr(info.outfd, &info.fs, &info.super, info.cmp))
+ if (write_xattr(outfd, &fs, &super, cmp))
goto out_data;
- if (sqfs_super_write(&info.super, info.outfd))
+ if (sqfs_super_write(&super, outfd))
goto out_data;
- if (padd_file(&info))
+ if (padd_file(outfd, &super, &opt))
goto out_data;
status = EXIT_SUCCESS;
out_data:
data_writer_destroy(data);
out_cmp:
- info.cmp->destroy(info.cmp);
+ cmp->destroy(cmp);
out_fstree:
- fstree_cleanup(&info.fs);
+ fstree_cleanup(&fs);
out_outfd:
- close(info.outfd);
+ close(outfd);
out_idtbl:
- id_table_cleanup(&info.idtbl);
+ id_table_cleanup(&idtbl);
return status;
}