diff options
| author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 17:47:19 +0200 | 
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 17:47:19 +0200 | 
| commit | 3511b1fa7c6f71c579e161951e945904e552e1d9 (patch) | |
| tree | 55fa94e5daef7bcc8e4b650f27d05af49fd1b02d /include | |
| parent | 4d79f55f4a626a3cfd8bd18673aa29b48b16e137 (diff) | |
Remove condensed sparse file handling from libsquashfs
This only exists for tar2sqfs. Move the sparse file map to libtar
and add the ability to do this into the stind sqfs_file_t abstraction,
so it acts like a normal file but internally stitches the data
together from the sparse implementation.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
| -rw-r--r-- | include/data_writer.h | 14 | ||||
| -rw-r--r-- | include/highlevel.h | 3 | ||||
| -rw-r--r-- | include/sqfs/io.h | 44 | ||||
| -rw-r--r-- | include/sqfs/predef.h | 1 | ||||
| -rw-r--r-- | include/tar.h | 10 | 
5 files changed, 9 insertions, 63 deletions
diff --git a/include/data_writer.h b/include/data_writer.h index e29881b..cdf7a44 100644 --- a/include/data_writer.h +++ b/include/data_writer.h @@ -88,20 +88,6 @@ int data_writer_sync(data_writer_t *data);  int write_data_from_file(data_writer_t *data, sqfs_inode_generic_t *inode,  			 sqfs_file_t *file, int flags); -/* -  Does the same as write_data_from_fd but the input file is the condensed -  representation of a sparse file. The layout must be in order and -  non-overlapping. - -  The flags argument is a combination of DW_* flags. After completion the -  data writer collects the 'fi' in an internal list it uses for deduplication. - -  Returns 0 on success, prints errors to stderr. - */ -int write_data_from_file_condensed(data_writer_t *data, sqfs_file_t *file, -				   sqfs_inode_generic_t *inode, -				   const sqfs_sparse_map_t *map, int flags); -  data_writer_stats_t *data_writer_get_stats(data_writer_t *data);  #endif /* DATA_WRITER_H */ diff --git a/include/highlevel.h b/include/highlevel.h index ed0f4bf..bfc2d91 100644 --- a/include/highlevel.h +++ b/include/highlevel.h @@ -23,6 +23,7 @@  #include "sqfs/data_reader.h"  #include "data_writer.h"  #include "fstree.h" +#include "tar.h"  #include <sys/stat.h>  #include <stdint.h> @@ -83,6 +84,6 @@ int sqfs_data_reader_dump(sqfs_data_reader_t *data,  			  const sqfs_inode_generic_t *inode,  			  int outfd, size_t block_size, bool allow_sparse); -sqfs_file_t *sqfs_get_stdin_file(uint64_t size); +sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, uint64_t size);  #endif /* HIGHLEVEL_H */ diff --git a/include/sqfs/io.h b/include/sqfs/io.h index d7a923c..5c1bfd5 100644 --- a/include/sqfs/io.h +++ b/include/sqfs/io.h @@ -120,20 +120,6 @@ struct sqfs_file_t {  	int (*truncate)(sqfs_file_t *file, uint64_t size);  }; -/** - * @struct sqfs_sparse_map_t - * - * @brief Describes the layout of a sparse file. - * - * This structure is part of a linked list that indicates where the actual - * data is located in a sparse file. - */ -struct sqfs_sparse_map_t { -	sqfs_sparse_map_t *next; -	uint64_t offset; -	uint64_t count; -}; -  #ifdef __cplusplus  extern "C" {  #endif @@ -175,36 +161,6 @@ SQFS_API int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset,  				    size_t size, sqfs_inode_generic_t *inode,  				    uint32_t flags, sqfs_block_t **out); -/** - * @brief Read a chunk from a condensed version of a sparse file and turn it - *        into a block that can be fed to a block processor. - * - * @member sqfs_file_t - * - * This function works on condensed sparse files, i.e. a sparse file that had - * its holdes removed. The given mapping describes the original data region - * that are actually packed next to each other. The function emulates the - * orignal sparse file by zero-initializing the block data, then figuring - * out which regions overlap the block, working out their physical location and - * stitching the block together. - * - * @param file A pointer to a file implementation. - * @param offset A byte offset into the file. - * @param size The number of bytes to read, starting at the given offset. - * @param inode The inode pointer to set for the block. - * @param flags The flags to store in the newly created block. - * @param map Describes the data regions of the original sparse file. - * @param out Returns a pointer to a block on success. - * - * @return Zero on success, an @ref E_SQFS_ERROR identifier on failure. - */ -SQFS_API int sqfs_file_create_block_dense(sqfs_file_t *file, uint64_t offset, -					  size_t size, -					  sqfs_inode_generic_t *inode, -					  uint32_t flags, -					  const sqfs_sparse_map_t *map, -					  sqfs_block_t **out); -  #ifdef __cplusplus  }  #endif diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h index 8a554dd..ebe99e1 100644 --- a/include/sqfs/predef.h +++ b/include/sqfs/predef.h @@ -69,7 +69,6 @@ typedef struct sqfs_meta_reader_t sqfs_meta_reader_t;  typedef struct sqfs_meta_writer_t sqfs_meta_writer_t;  typedef struct sqfs_xattr_reader_t sqfs_xattr_reader_t;  typedef struct sqfs_file_t sqfs_file_t; -typedef struct sqfs_sparse_map_t sqfs_sparse_map_t;  typedef struct sqfs_tree_node_t sqfs_tree_node_t;  typedef struct sqfs_data_reader_t sqfs_data_reader_t;  typedef struct sqfs_block_hooks_t sqfs_block_hooks_t; diff --git a/include/tar.h b/include/tar.h index 38f6289..45457da 100644 --- a/include/tar.h +++ b/include/tar.h @@ -8,13 +8,17 @@  #define TAR_H  #include "config.h" +#include "util.h"  #include <sys/stat.h>  #include <stdbool.h>  #include <stdint.h> -#include "sqfs/io.h" -#include "util.h" +typedef struct sparse_map_t { +	struct sparse_map_t *next; +	uint64_t offset; +	uint64_t count; +} sparse_map_t;  typedef struct {  	char name[100]; @@ -75,7 +79,7 @@ typedef struct {  	struct stat sb;  	char *name;  	char *link_target; -	sqfs_sparse_map_t *sparse; +	sparse_map_t *sparse;  	uint64_t actual_size;  	uint64_t record_size;  	bool unknown_record;  | 
