summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/data_writer.h14
-rw-r--r--include/tar.h10
-rw-r--r--include/util.h7
3 files changed, 24 insertions, 7 deletions
diff --git a/include/data_writer.h b/include/data_writer.h
index cafe61e..2ace899 100644
--- a/include/data_writer.h
+++ b/include/data_writer.h
@@ -5,6 +5,7 @@
#include "squashfs.h"
#include "compress.h"
#include "fstree.h"
+#include "util.h"
typedef struct data_writer_t data_writer_t;
@@ -42,8 +43,21 @@ int data_writer_flush_fragments(data_writer_t *data);
The file_info_t object is updated accordingly and used to determine the
number of bytes to write and the input file name to report errors.
+ Blocks or fragments that are all zero bytes automatically detected,
+ not written out and the sparse file accounting updated accordingly.
+
Returns 0 on success, prints errors to stderr.
*/
int write_data_from_fd(data_writer_t *data, file_info_t *fi, int infd);
+/*
+ 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.
+
+ Returns 0 on success, prints errors to stderr.
+ */
+int write_data_from_fd_condensed(data_writer_t *data, file_info_t *fi,
+ int infd, sparse_map_t *map);
+
#endif /* DATA_WRITER_H */
diff --git a/include/tar.h b/include/tar.h
index 2819740..1f8ca7e 100644
--- a/include/tar.h
+++ b/include/tar.h
@@ -6,6 +6,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "util.h"
+
typedef enum {
ETV_UNKNOWN = 0,
ETV_V7_UNIX,
@@ -61,17 +63,11 @@ typedef struct {
char padding[7];
} gnu_sparse_t;
-typedef struct tar_sparse_data_t {
- struct tar_sparse_data_t *next;
- uint64_t offset;
- uint64_t count;
-} tar_sparse_data_t;
-
typedef struct {
struct stat sb;
char *name;
char *link_target;
- tar_sparse_data_t *sparse;
+ sparse_map_t *sparse;
uint64_t sparse_size;
bool unknown_record;
} tar_header_decoded_t;
diff --git a/include/util.h b/include/util.h
index d5b20dd..997cbf5 100644
--- a/include/util.h
+++ b/include/util.h
@@ -5,6 +5,13 @@
#include <sys/types.h>
#include <stdint.h>
+/* layout structure for sparse files, indicating where the actual data is */
+typedef struct sparse_map_t {
+ struct sparse_map_t *next;
+ uint64_t offset;
+ uint64_t count;
+} sparse_map_t;
+
/*
Convert back to forward slashed, remove all preceeding and trailing slashes,
collapse all sequences of slashes, remove all path components that are '.'