From 3a851dfe87c88ac1d4dddc2a26cc48b037f852f9 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 8 Sep 2019 14:53:30 +0200 Subject: 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 --- lib/sqfs/super.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'lib/sqfs/super.c') 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 @@ -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, ©, 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, ©, sizeof(copy)); } -- cgit v1.2.3