summaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/id_table.c21
-rw-r--r--lib/sqfs/table.c36
2 files changed, 24 insertions, 33 deletions
diff --git a/lib/sqfs/id_table.c b/lib/sqfs/id_table.c
index cd31360..4cc12c6 100644
--- a/lib/sqfs/id_table.c
+++ b/lib/sqfs/id_table.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#include "id_table.h"
+#include "table.h"
#include <stdlib.h>
#include <string.h>
@@ -50,3 +51,23 @@ int id_table_id_to_index(id_table_t *tbl, uint32_t id, uint16_t *out)
tbl->ids[tbl->num_ids++] = id;
return 0;
}
+
+int id_table_write(id_table_t *tbl, int outfd, sqfs_super_t *super,
+ compressor_t *cmp)
+{
+ size_t i;
+ int ret;
+
+ for (i = 0; i < tbl->num_ids; ++i)
+ tbl->ids[i] = htole32(tbl->ids[i]);
+
+ super->id_count = tbl->num_ids;
+
+ ret = sqfs_write_table(outfd, super, tbl->ids, sizeof(tbl->ids[0]),
+ tbl->num_ids, &super->id_table_start, cmp);
+
+ for (i = 0; i < tbl->num_ids; ++i)
+ tbl->ids[i] = le32toh(tbl->ids[i]);
+
+ return ret;
+}
diff --git a/lib/sqfs/table.c b/lib/sqfs/table.c
index 2fab3cc..882d9ba 100644
--- a/lib/sqfs/table.c
+++ b/lib/sqfs/table.c
@@ -6,9 +6,9 @@
#include <endian.h>
#include <stdio.h>
-static int sqfs_write_table(int outfd, sqfs_super_t *super, const void *data,
- size_t entsize, size_t count, uint64_t *startblock,
- compressor_t *cmp)
+int sqfs_write_table(int outfd, sqfs_super_t *super, const void *data,
+ size_t entsize, size_t count, uint64_t *startblock,
+ compressor_t *cmp)
{
size_t ent_per_blocks = SQFS_META_BLOCK_SIZE / entsize;
uint64_t blocks[count / ent_per_blocks + 1];
@@ -62,33 +62,3 @@ fail:
meta_writer_destroy(m);
return -1;
}
-
-int sqfs_write_fragment_table(int outfd, sqfs_super_t *super,
- sqfs_fragment_t *fragments, size_t count,
- compressor_t *cmp)
-{
- super->fragment_entry_count = count;
-
- return sqfs_write_table(outfd, super, fragments, sizeof(fragments[0]),
- count, &super->fragment_table_start, cmp);
-}
-
-int sqfs_write_ids(int outfd, sqfs_super_t *super, uint32_t *id_tbl,
- size_t count, compressor_t *cmp)
-{
- size_t i;
- int ret;
-
- for (i = 0; i < count; ++i)
- id_tbl[i] = htole32(id_tbl[i]);
-
- super->id_count = count;
-
- ret = sqfs_write_table(outfd, super, id_tbl, sizeof(id_tbl[0]),
- count, &super->id_table_start, cmp);
-
- for (i = 0; i < count; ++i)
- id_tbl[i] = htole32(id_tbl[i]);
-
- return ret;
-}