diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-21 20:22:04 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-21 20:22:04 +0200 |
commit | 2a05bf5bc660bfebb35e42f1f8a0c0ac56e0f9d9 (patch) | |
tree | 07492d6744db580ba487503a7a4572d4a92ae0c1 /lib | |
parent | 80cc3970e97ec71b5e645ca5132bebf115423fb2 (diff) |
Implement generating an inode table for NFS export
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makemodule.am | 1 | ||||
-rw-r--r-- | lib/sqfs/write_export_table.c | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/Makemodule.am b/lib/Makemodule.am index 7e6ca82..ab2030c 100644 --- a/lib/Makemodule.am +++ b/lib/Makemodule.am @@ -35,6 +35,7 @@ libsquashfs_a_SOURCES += lib/sqfs/deserialize_fstree.c libsquashfs_a_SOURCES += lib/sqfs/data_writer.c lib/sqfs/write_xattr.c libsquashfs_a_SOURCES += include/data_writer.h include/frag_reader.h libsquashfs_a_SOURCES += include/data_reader.h lib/sqfs/data_reader.c +libsquashfs_a_SOURCES += lib/sqfs/write_export_table.c libutil_a_SOURCES = lib/util/canonicalize_name.c lib/util/write_data.c libutil_a_SOURCES += lib/util/read_data.c include/util.h diff --git a/lib/sqfs/write_export_table.c b/lib/sqfs/write_export_table.c new file mode 100644 index 0000000..eee4e01 --- /dev/null +++ b/lib/sqfs/write_export_table.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +#include "highlevel.h" + +#include <stdlib.h> +#include <stdio.h> + +int write_export_table(int outfd, fstree_t *fs, sqfs_super_t *super, + compressor_t *cmp) +{ + uint64_t *table, start; + size_t i; + int ret; + + table = malloc(sizeof(uint64_t) * fs->inode_tbl_size); + + if (table == NULL) { + perror("Allocating NFS export table"); + return -1; + } + + for (i = 0; i < fs->inode_tbl_size; ++i) { + if (fs->inode_table[i] == NULL) { + table[i] = 0xFFFFFFFFFFFFFFFF; + } else { + table[i] = htole64(fs->inode_table[i]->inode_ref); + } + } + + ret = sqfs_write_table(outfd, super, table, sizeof(table[0]), + fs->inode_tbl_size, &start, cmp); + + super->export_table_start = start; + super->flags |= SQFS_FLAG_EXPORTABLE; + free(table); + return ret; +} |