diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-15 14:44:44 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-15 14:47:03 +0200 |
commit | 14a925f6da442ecade7df75eb46a6edb9a1499af (patch) | |
tree | d63d56ec17e1d8bcbf310273f199f4891718a6b5 /include | |
parent | 1b35319762cd83982dacbe96eccf07fd00d7858a (diff) |
Add flags to data writer to micro manage behaviour
The added flags allow controlling the following on a per file level:
- forcing a file to be written uncompressed
- forcing a file to not have a fragment, i.e. the last truncated block
actually being written as a block
- padding a file to be alligned to device block size
The flags are not yet exposed to anything user controllable (such as
command line flags).
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r-- | include/data_writer.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/include/data_writer.h b/include/data_writer.h index 2ace899..a52b37f 100644 --- a/include/data_writer.h +++ b/include/data_writer.h @@ -9,6 +9,22 @@ typedef struct data_writer_t data_writer_t; +enum { + /* Don't generate fragments, always write the last block to disk as a + block, even if it is incomplete. */ + DW_DONT_FRAGMENT = 0x01, + + /* Intentionally write all blocks uncompressed. This implies + DW_DONT_FRAGMENT since sharing a fragment block with other files + would otherwise require the entire fragment block to be + uncompressed. */ + DW_DONT_COMPRESS = 0x03, + + /* Make sure the first block of a file is alligned to + device block size */ + DW_ALLIGN_DEVBLK = 0x04, +}; + /* Create a data writer. The pointer to the super block is kept internally and used to automatically update various counters when writing data. @@ -16,7 +32,7 @@ typedef struct data_writer_t data_writer_t; Returns NULL on failure and prints errors to stderr. */ data_writer_t *data_writer_create(sqfs_super_t *super, compressor_t *cmp, - int outfd); + int outfd, size_t devblksize); void data_writer_destroy(data_writer_t *data); @@ -46,18 +62,23 @@ int data_writer_flush_fragments(data_writer_t *data); Blocks or fragments that are all zero bytes automatically detected, not written out and the sparse file accounting updated accordingly. + The flags argument is a combination of DW_* flags. + Returns 0 on success, prints errors to stderr. */ -int write_data_from_fd(data_writer_t *data, file_info_t *fi, int infd); +int write_data_from_fd(data_writer_t *data, file_info_t *fi, int infd, + 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. + 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); + int infd, sparse_map_t *map, int flags); #endif /* DATA_WRITER_H */ |