summaryrefslogtreecommitdiff
path: root/lib/sqfs/super.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-08 14:53:30 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-08 14:53:30 +0200
commit3a851dfe87c88ac1d4dddc2a26cc48b037f852f9 (patch)
treea8a8f34291aa58b25737088d247a91a7f60b4fec /lib/sqfs/super.c
parent60064dd0412a149fe00cfc4e2f2361c22656db57 (diff)
Replace direct file I/O with abstraction layer
This should make it easier to use libsquashfs with custom setups that embedd a squashfs image inside something else. Also, it should make it easier to port to non unix-like platforms. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/super.c')
-rw-r--r--lib/sqfs/super.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/sqfs/super.c b/lib/sqfs/super.c
index 0489079..b3984d2 100644
--- a/lib/sqfs/super.c
+++ b/lib/sqfs/super.c
@@ -9,6 +9,7 @@
#include "sqfs/super.h"
#include "sqfs/error.h"
+#include "sqfs/io.h"
#include "util.h"
#include <endian.h>
@@ -48,7 +49,7 @@ int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime,
return 0;
}
-int sqfs_super_write(sqfs_super_t *super, int fd)
+int sqfs_super_write(sqfs_super_t *super, sqfs_file_t *file)
{
sqfs_super_t copy;
@@ -72,14 +73,5 @@ int sqfs_super_write(sqfs_super_t *super, int fd)
copy.fragment_table_start = htole64(super->fragment_table_start);
copy.export_table_start = htole64(super->export_table_start);
- if (lseek(fd, 0, SEEK_SET) == (off_t)-1)
- return SQFS_ERROR_IO;
-
- if (write_data("writing super block", fd, &copy, sizeof(copy)))
- return SQFS_ERROR_IO;
-
- if (lseek(fd, 0, SEEK_END) == (off_t)-1)
- return SQFS_ERROR_IO;
-
- return 0;
+ return file->write_at(file, 0, &copy, sizeof(copy));
}