aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-29 00:38:04 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-29 00:39:35 +0200
commit99f3eaecb4ad3c85d791361c8857e6ba2be8f9ea (patch)
tree08e8a2c854eca57f20f788fd929d86642e2fbc0e
parent74a755290c6b000b1a793f09ce5b6ee6d4016eaf (diff)
Bring back the don't fragment flag
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/sqfs/block.h11
-rw-r--r--lib/sqfs/data_writer/fileapi.c14
2 files changed, 20 insertions, 5 deletions
diff --git a/include/sqfs/block.h b/include/sqfs/block.h
index 84629eb..7ee3bcb 100644
--- a/include/sqfs/block.h
+++ b/include/sqfs/block.h
@@ -81,6 +81,15 @@ typedef enum {
SQFS_BLK_ALLIGN = 0x0002,
/**
+ * @brief Don't add the tail end of a file to a fragment block.
+ *
+ * If set, the @ref sqfs_data_writer_t will always generate a final
+ * block for a file, even if it is truncated. It will not add the
+ * tail end to a fragment block.
+ */
+ SQFS_BLK_DONT_FRAGMENT = 0x0004,
+
+ /**
* @brief Set by the @ref sqfs_data_writer_t on the first
* block of a file.
*/
@@ -113,7 +122,7 @@ typedef enum {
/**
* @brief The combination of all flags that are user settable.
*/
- SQFS_BLK_USER_SETTABLE_FLAGS = 0x0003,
+ SQFS_BLK_USER_SETTABLE_FLAGS = 0x0007,
} E_SQFS_BLK_FLAGS;
/**
diff --git a/lib/sqfs/data_writer/fileapi.c b/lib/sqfs/data_writer/fileapi.c
index 2a5d02a..98bdf5c 100644
--- a/lib/sqfs/data_writer/fileapi.c
+++ b/lib/sqfs/data_writer/fileapi.c
@@ -56,7 +56,8 @@ static int flush_block(sqfs_data_writer_t *proc, sqfs_block_t *block)
return 0;
}
- if (block->size < proc->max_block_size) {
+ if (block->size < proc->max_block_size &&
+ !(block->flags & SQFS_BLK_DONT_FRAGMENT)) {
block->flags |= SQFS_BLK_IS_FRAGMENT;
} else {
proc->inode->num_file_blocks += 1;
@@ -124,9 +125,14 @@ int sqfs_data_writer_end_file(sqfs_data_writer_t *proc)
return test_and_set_status(proc, SQFS_ERROR_INTERNAL);
if (!(proc->blk_flags & SQFS_BLK_FIRST_BLOCK)) {
- err = add_sentinel_block(proc);
- if (err)
- return err;
+ if (proc->blk_current != NULL &&
+ (proc->blk_flags & SQFS_BLK_DONT_FRAGMENT)) {
+ proc->blk_flags |= SQFS_BLK_LAST_BLOCK;
+ } else {
+ err = add_sentinel_block(proc);
+ if (err)
+ return err;
+ }
}
if (proc->blk_current != NULL) {