summaryrefslogtreecommitdiff
path: root/lib/sqfs/id_table_write.c
blob: 3bbe30241ac8d1ca83c5a5c584e372bd3f92a589 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* SPDX-License-Identifier: GPL-3.0-or-later */
#include "config.h"

#include "highlevel.h"

int id_table_write(id_table_t *tbl, int outfd, sqfs_super_t *super,
		   compressor_t *cmp)
{
	uint64_t start;
	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, cmp, tbl->ids,
			       sizeof(tbl->ids[0]) * tbl->num_ids, &start);

	super->id_table_start = start;

	for (i = 0; i < tbl->num_ids; ++i)
		tbl->ids[i] = le32toh(tbl->ids[i]);

	return ret;
}