diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-07 13:54:24 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-07 13:54:24 +0200 |
commit | 1fad07ce86fc2a506c59501d7fb7c7d7481525f6 (patch) | |
tree | 6ba41c514e2ddc692cb95a0fb2070dd222897c7c /lib/common/write_export_table.c | |
parent | 5597dca9c6053cd19104e18d88edb199b32e3743 (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common/write_export_table.c')
-rw-r--r-- | lib/common/write_export_table.c | 43 |
1 files changed, 43 insertions, 0 deletions
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 <goliath@infraroot.at> + */ +#include "common.h" + +#include <stdlib.h> +#include <stdio.h> + +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; +} |