From 1fad07ce86fc2a506c59501d7fb7c7d7481525f6 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 7 Oct 2019 13:54:24 +0200 Subject: Rename libsqfshelper to libcommon That is IMO less confusing and express what it is (i.e. what it has become) more clearly, i.e. common code shared by the utilities. Signed-off-by: David Oberhollenzer --- lib/common/write_export_table.c | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/common/write_export_table.c (limited to 'lib/common/write_export_table.c') diff --git a/lib/common/write_export_table.c b/lib/common/write_export_table.c new file mode 100644 index 0000000..c797577 --- /dev/null +++ b/lib/common/write_export_table.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * write_export_table.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "common.h" + +#include +#include + +int write_export_table(const char *filename, sqfs_file_t *file, + fstree_t *fs, sqfs_super_t *super, + sqfs_compressor_t *cmp) +{ + sqfs_u64 *table, start; + size_t i, size; + int ret; + + if (fs->inode_tbl_size < 1) + return 0; + + table = alloc_array(sizeof(sqfs_u64), fs->inode_tbl_size); + + if (table == NULL) { + perror("Allocating NFS export table"); + return -1; + } + + for (i = 0; i < fs->inode_tbl_size; ++i) { + table[i] = htole64(fs->inode_table[i]->inode_ref); + } + + size = sizeof(sqfs_u64) * fs->inode_tbl_size; + ret = sqfs_write_table(file, cmp, table, size, &start); + if (ret) + sqfs_perror(filename, "writing NFS export table", ret); + + super->export_table_start = start; + super->flags |= SQFS_FLAG_EXPORTABLE; + free(table); + return ret; +} -- cgit v1.2.3