aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-16 23:13:42 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-18 22:44:39 +0200
commitcfe80ff9045f33375f11a285098fb15ce214372a (patch)
treecf70d1d5d29694392715c68c6d7b994d2005d6ea
parentb45850388ea5505f4fd50cd659abe2f02aeca0b5 (diff)
Minor interface change to data writer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/data_writer.h5
-rw-r--r--lib/sqfs/data_writer.c9
-rw-r--r--mkfs/mkfs.c2
-rw-r--r--tar/tar2sqfs.c2
4 files changed, 12 insertions, 6 deletions
diff --git a/include/data_writer.h b/include/data_writer.h
index f384ce7..bd7532d 100644
--- a/include/data_writer.h
+++ b/include/data_writer.h
@@ -51,11 +51,12 @@ void data_writer_destroy(data_writer_t *data);
int data_writer_write_fragment_table(data_writer_t *data);
/*
- Compress and flush the current fragment buffer even if it is not full yet.
+ Wait for everything to be written to disk. This also forces a currently
+ pending fragment block to be compressed and wrtten.
Returns 0 on success, prints errors to stderr.
*/
-int data_writer_flush_fragments(data_writer_t *data);
+int data_writer_sync(data_writer_t *data);
/*
Read data from the given file descriptor, partition it into blocks and
diff --git a/lib/sqfs/data_writer.c b/lib/sqfs/data_writer.c
index ea650bd..d24f2d9 100644
--- a/lib/sqfs/data_writer.c
+++ b/lib/sqfs/data_writer.c
@@ -105,7 +105,7 @@ static int allign_file(data_writer_t *data)
return 0;
}
-int data_writer_flush_fragments(data_writer_t *data)
+static int flush_fragments(data_writer_t *data)
{
uint64_t offset;
uint32_t out;
@@ -193,7 +193,7 @@ static int flush_data_block(data_writer_t *data, size_t size, bool is_last,
}
if (data->frag_offset + size > data->super->block_size) {
- if (data_writer_flush_fragments(data))
+ if (flush_fragments(data))
return -1;
}
@@ -398,3 +398,8 @@ int data_writer_write_fragment_table(data_writer_t *data)
data->super->fragment_table_start = start;
return 0;
}
+
+int data_writer_sync(data_writer_t *data)
+{
+ return flush_fragments(data);
+}
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 3dc9efb..449fa81 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -55,7 +55,7 @@ static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt)
return -1;
}
- if (data_writer_flush_fragments(data))
+ if (data_writer_sync(data))
return -1;
return restore_working_dir(opt);
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index 36f8cd6..f583fd4 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -397,7 +397,7 @@ int main(int argc, char **argv)
if (process_tar_ball(&fs, data))
goto out;
- if (data_writer_flush_fragments(data))
+ if (data_writer_sync(data))
goto out;
tree_node_sort_recursive(fs.root);