summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-06 21:54:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-06 21:54:26 +0200
commitc3dc5b65224ebcb532671320644cfb626a1b2e67 (patch)
treee408076300bf0cd4c40d27a19eaab001862ef370 /lib
parent7c6f0fa3836d9ede71a15917a3efc1f013d60d6d (diff)
Cleanup: move padd_sqfs to helper library
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfshelper/writer.c29
-rw-r--r--lib/util/padd_file.c29
2 files changed, 29 insertions, 29 deletions
diff --git a/lib/sqfshelper/writer.c b/lib/sqfshelper/writer.c
index 7626b1c..5d31be7 100644
--- a/lib/sqfshelper/writer.c
+++ b/lib/sqfshelper/writer.c
@@ -48,6 +48,35 @@ static size_t os_get_max_ram(void)
}
#endif
+static int padd_sqfs(sqfs_file_t *file, sqfs_u64 size, size_t blocksize)
+{
+ size_t padd_sz = size % blocksize;
+ int status = -1;
+ sqfs_u8 *buffer;
+
+ if (padd_sz == 0)
+ return 0;
+
+ padd_sz = blocksize - padd_sz;
+
+ buffer = calloc(1, padd_sz);
+ if (buffer == NULL)
+ goto fail_errno;
+
+ if (file->write_at(file, file->get_size(file),
+ buffer, padd_sz)) {
+ goto fail_errno;
+ }
+
+ status = 0;
+out:
+ free(buffer);
+ return status;
+fail_errno:
+ perror("padding output file to block size");
+ goto out;
+}
+
void sqfs_writer_cfg_init(sqfs_writer_cfg_t *cfg)
{
size_t max_ram;
diff --git a/lib/util/padd_file.c b/lib/util/padd_file.c
index 53e1a42..1803139 100644
--- a/lib/util/padd_file.c
+++ b/lib/util/padd_file.c
@@ -40,32 +40,3 @@ fail_errno:
perror("padding output file to block size");
goto out;
}
-
-int padd_sqfs(sqfs_file_t *file, sqfs_u64 size, size_t blocksize)
-{
- size_t padd_sz = size % blocksize;
- int status = -1;
- sqfs_u8 *buffer;
-
- if (padd_sz == 0)
- return 0;
-
- padd_sz = blocksize - padd_sz;
-
- buffer = calloc(1, padd_sz);
- if (buffer == NULL)
- goto fail_errno;
-
- if (file->write_at(file, file->get_size(file),
- buffer, padd_sz)) {
- goto fail_errno;
- }
-
- status = 0;
-out:
- free(buffer);
- return status;
-fail_errno:
- perror("padding output file to block size");
- goto out;
-}