summaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-24 16:15:05 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-24 16:15:05 +0100
commitdea3b64dd11a3a3391bd9d8f8c26f20392e7eb3c (patch)
tree5117e08148428a8fd201ce523aba447a25830a41 /lib/sqfs
parentc8d234ddcf42f4a2d3e30122877d792fabd92f68 (diff)
Cleanup: split out sqfs_write_super similar to sqfs_read_super
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/Makemodule.am2
-rw-r--r--lib/sqfs/super.c29
-rw-r--r--lib/sqfs/write_super.c39
3 files changed, 40 insertions, 30 deletions
diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am
index da2e3b2..c687d1c 100644
--- a/lib/sqfs/Makemodule.am
+++ b/lib/sqfs/Makemodule.am
@@ -19,7 +19,7 @@ libsquashfs_la_SOURCES += lib/sqfs/read_table.c lib/sqfs/comp/compressor.c
libsquashfs_la_SOURCES += lib/sqfs/comp/internal.h lib/sqfs/xattr_writer.c
libsquashfs_la_SOURCES += lib/sqfs/dir_reader.c lib/sqfs/read_tree.c
libsquashfs_la_SOURCES += lib/sqfs/inode.c lib/sqfs/data_writer/fragment.c
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/block.c
+libsquashfs_la_SOURCES += lib/sqfs/write_super.c lib/sqfs/data_writer/block.c
libsquashfs_la_SOURCES += lib/sqfs/data_writer/internal.h lib/sqfs/data_reader.c
libsquashfs_la_SOURCES += lib/sqfs/data_writer/common.c
libsquashfs_la_SOURCES += lib/sqfs/data_writer/fileapi.c
diff --git a/lib/sqfs/super.c b/lib/sqfs/super.c
index 18a6736..20ce420 100644
--- a/lib/sqfs/super.c
+++ b/lib/sqfs/super.c
@@ -9,8 +9,6 @@
#include "sqfs/super.h"
#include "sqfs/error.h"
-#include "sqfs/io.h"
-#include "util/util.h"
#include <string.h>
@@ -46,30 +44,3 @@ int sqfs_super_init(sqfs_super_t *super, size_t block_size, sqfs_u32 mtime,
return 0;
}
-
-int sqfs_super_write(const sqfs_super_t *super, sqfs_file_t *file)
-{
- sqfs_super_t copy;
-
- copy.magic = htole32(super->magic);
- copy.inode_count = htole32(super->inode_count);
- copy.modification_time = htole32(super->modification_time);
- copy.block_size = htole32(super->block_size);
- copy.fragment_entry_count = htole32(super->fragment_entry_count);
- copy.compression_id = htole16(super->compression_id);
- copy.block_log = htole16(super->block_log);
- copy.flags = htole16(super->flags);
- copy.id_count = htole16(super->id_count);
- copy.version_major = htole16(super->version_major);
- copy.version_minor = htole16(super->version_minor);
- copy.root_inode_ref = htole64(super->root_inode_ref);
- copy.bytes_used = htole64(super->bytes_used);
- copy.id_table_start = htole64(super->id_table_start);
- copy.xattr_id_table_start = htole64(super->xattr_id_table_start);
- copy.inode_table_start = htole64(super->inode_table_start);
- copy.directory_table_start = htole64(super->directory_table_start);
- copy.fragment_table_start = htole64(super->fragment_table_start);
- copy.export_table_start = htole64(super->export_table_start);
-
- return file->write_at(file, 0, &copy, sizeof(copy));
-}
diff --git a/lib/sqfs/write_super.c b/lib/sqfs/write_super.c
new file mode 100644
index 0000000..35127da
--- /dev/null
+++ b/lib/sqfs/write_super.c
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/*
+ * write_super.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
+#include "sqfs/super.h"
+#include "sqfs/io.h"
+#include "compat.h"
+
+int sqfs_super_write(const sqfs_super_t *super, sqfs_file_t *file)
+{
+ sqfs_super_t copy;
+
+ copy.magic = htole32(super->magic);
+ copy.inode_count = htole32(super->inode_count);
+ copy.modification_time = htole32(super->modification_time);
+ copy.block_size = htole32(super->block_size);
+ copy.fragment_entry_count = htole32(super->fragment_entry_count);
+ copy.compression_id = htole16(super->compression_id);
+ copy.block_log = htole16(super->block_log);
+ copy.flags = htole16(super->flags);
+ copy.id_count = htole16(super->id_count);
+ copy.version_major = htole16(super->version_major);
+ copy.version_minor = htole16(super->version_minor);
+ copy.root_inode_ref = htole64(super->root_inode_ref);
+ copy.bytes_used = htole64(super->bytes_used);
+ copy.id_table_start = htole64(super->id_table_start);
+ copy.xattr_id_table_start = htole64(super->xattr_id_table_start);
+ copy.inode_table_start = htole64(super->inode_table_start);
+ copy.directory_table_start = htole64(super->directory_table_start);
+ copy.fragment_table_start = htole64(super->fragment_table_start);
+ copy.export_table_start = htole64(super->export_table_start);
+
+ return file->write_at(file, 0, &copy, sizeof(copy));
+}