summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-10 21:40:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-10 21:40:10 +0200
commit41fd1d4b9cd42eb28bf889719b8ce1a81af444b9 (patch)
treed0ba2b29a49a1acaf9bf260a27192aef524ea095 /mkfs
parent080d8952ecc441faa32f772c590d6b2e56a57634 (diff)
Make sqfs_write_inodes independend of sqfs_info_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/meta.c25
-rw-r--r--mkfs/mkfs.c4
-rw-r--r--mkfs/mkfs.h5
3 files changed, 19 insertions, 15 deletions
diff --git a/mkfs/meta.c b/mkfs/meta.c
index 2d969a3..369149f 100644
--- a/mkfs/meta.c
+++ b/mkfs/meta.c
@@ -2,7 +2,8 @@
#include "mkfs.h"
#include "util.h"
-int sqfs_write_inodes(sqfs_info_t *info)
+int sqfs_write_inodes(sqfs_super_t *super, fstree_t *fs, int outfd,
+ compressor_t *cmp, id_table_t *idtbl)
{
meta_writer_t *im, *dm;
uint8_t buffer[1024];
@@ -21,17 +22,17 @@ int sqfs_write_inodes(sqfs_info_t *info)
tmpfd = fileno(tmp);
- im = meta_writer_create(info->outfd, info->cmp);
+ im = meta_writer_create(outfd, cmp);
if (im == NULL)
goto fail_tmp;
- dm = meta_writer_create(tmpfd, info->cmp);
+ dm = meta_writer_create(tmpfd, cmp);
if (dm == NULL)
goto fail_im;
- for (i = 2; i < info->fs.inode_tbl_size; ++i) {
- if (write_inode(&info->fs, &info->idtbl, im, dm,
- info->fs.inode_table[i])) {
+ for (i = 2; i < fs->inode_tbl_size; ++i) {
+ if (write_inode(fs, idtbl, im, dm,
+ fs->inode_table[i])) {
goto fail;
}
}
@@ -42,15 +43,15 @@ int sqfs_write_inodes(sqfs_info_t *info)
if (meta_writer_flush(dm))
goto fail;
- info->super.root_inode_ref = info->fs.root->inode_ref;
+ super->root_inode_ref = fs->root->inode_ref;
meta_writer_get_position(im, &block, &offset);
- info->super.inode_table_start = info->super.bytes_used;
- info->super.bytes_used += block;
+ super->inode_table_start = super->bytes_used;
+ super->bytes_used += block;
- info->super.directory_table_start = info->super.bytes_used;
+ super->directory_table_start = super->bytes_used;
meta_writer_get_position(dm, &block, &offset);
- info->super.bytes_used += block;
+ super->bytes_used += block;
if (lseek(tmpfd, 0, SEEK_SET) == (off_t)-1) {
perror("rewind on directory temp file");
@@ -68,7 +69,7 @@ int sqfs_write_inodes(sqfs_info_t *info)
break;
diff = ret;
- ret = write_retry(info->outfd, buffer, diff);
+ ret = write_retry(outfd, buffer, diff);
if (ret < 0) {
perror("write to image file");
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 405d6fd..7c3fa28 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -114,8 +114,10 @@ int main(int argc, char **argv)
if (write_data_to_image(&info))
goto out_cmp;
- if (sqfs_write_inodes(&info))
+ if (sqfs_write_inodes(&info.super, &info.fs, info.outfd,
+ info.cmp, &info.idtbl)) {
goto out_cmp;
+ }
info.super.fragment_entry_count = info.num_fragments;
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index 13eb690..36f412d 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -73,8 +73,6 @@ void process_command_line(options_t *opt, int argc, char **argv);
int write_data_to_image(sqfs_info_t *info);
-int sqfs_write_inodes(sqfs_info_t *info);
-
int write_xattr(sqfs_info_t *info);
int write_dir(meta_writer_t *dm, dir_info_t *dir, dir_index_t **index);
@@ -82,4 +80,7 @@ int write_dir(meta_writer_t *dm, dir_info_t *dir, dir_index_t **index);
int write_inode(fstree_t *fs, id_table_t *idtbl, meta_writer_t *im,
meta_writer_t *dm, tree_node_t *node);
+int sqfs_write_inodes(sqfs_super_t *super, fstree_t *fs, int outfd,
+ compressor_t *cmp, id_table_t *idtbl);
+
#endif /* MKFS_H */