diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/meta_writer.h | 42 | ||||
| -rw-r--r-- | include/table.h | 16 | 
2 files changed, 58 insertions, 0 deletions
| diff --git a/include/meta_writer.h b/include/meta_writer.h index 7036b6a..df0c70c 100644 --- a/include/meta_writer.h +++ b/include/meta_writer.h @@ -4,6 +4,20 @@  #include "compress.h"  #include "squashfs.h" +#include "id_table.h" +#include "fstree.h" + +typedef struct { +	tree_node_t *node; +	uint32_t block; +	uint32_t offset; +} idx_ref_t; + +typedef struct { +	size_t num_nodes; +	size_t max_nodes; +	idx_ref_t idx_nodes[]; +} dir_index_t;  typedef struct meta_writer_t meta_writer_t; @@ -27,4 +41,32 @@ void meta_writer_get_position(const meta_writer_t *m, uint64_t *block_start,  /* Reset all internal state, including the current block start position. */  void meta_writer_reset(meta_writer_t *m); +/* +  High level helper function that writes squashfs directory entries to +  a meta data writer. + +  The dir_info_t structure is used to generate the listing and updated +  accordingly (such as writing back the header position and total size). +  A directory index is created on the fly and returned in *index. +  A single free() call is sufficient. + +  Returns 0 on success. Prints error messages to stderr on failure. + */ +int meta_writer_write_dir(meta_writer_t *dm, dir_info_t *dir, +			  dir_index_t **index); + +/* +  High level helper function to serialize a tree_node_t to a squashfs inode +  and write it to a meta data writer. + +  The inode is written to `im`. If it is a directory node, the directory +  contents are written to `dm` using meta_writer_write_dir. The given +  id_table_t is used to store the uid and gid on the fly and write the +  coresponding indices to the inode structure. + +  Returns 0 on success. Prints error messages to stderr on failure. + */ +int meta_writer_write_inode(fstree_t *fs, id_table_t *idtbl, meta_writer_t *im, +			    meta_writer_t *dm, tree_node_t *node); +  #endif /* META_WRITER_H */ diff --git a/include/table.h b/include/table.h index 6d61c85..57d8654 100644 --- a/include/table.h +++ b/include/table.h @@ -4,6 +4,7 @@  #include "squashfs.h"  #include "compress.h" +#include "fstree.h"  #include <stdint.h>  #include <stddef.h> @@ -23,4 +24,19 @@ int sqfs_write_table(int outfd, sqfs_super_t *super, const void *data,  		     size_t entsize, size_t count, uint64_t *startblock,  		     compressor_t *cmp); +/* +  High level helper function to serialize an entire file system tree to +  a squashfs inode table and directory table. + +  The data is written to the given file descriptor and the super block is +  update accordingly (inode and directory table start and total size). + +  The function internally creates two meta data writers and uses +  meta_writer_write_inode to serialize the inode table of the fstree. + +  Returns 0 on success. Prints error messages to stderr on failure. + */ +int sqfs_serialize_fstree(int outfd, sqfs_super_t *super, fstree_t *fs, +			  compressor_t *cmp, id_table_t *idtbl); +  #endif /* TABLE_H */ | 
