summaryrefslogtreecommitdiff
path: root/lib/sqfs/id_table_write.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-01 16:55:08 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-02 12:40:06 +0200
commit31d327c3780aecdb78304263f676ff89a8ea93d1 (patch)
tree747b11109f1748011d79ee7f388e89025b065cf5 /lib/sqfs/id_table_write.c
parent6ba88daae14e64009619562209060532eb6eadbb (diff)
unsquashfs: read ID table from file
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/id_table_write.c')
-rw-r--r--lib/sqfs/id_table_write.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sqfs/id_table_write.c b/lib/sqfs/id_table_write.c
new file mode 100644
index 0000000..490c2af
--- /dev/null
+++ b/lib/sqfs/id_table_write.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+#include "id_table.h"
+#include "table.h"
+
+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;
+}