From 5597dca9c6053cd19104e18d88edb199b32e3743 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 7 Oct 2019 13:49:40 +0200 Subject: Rename "hihglevel.h" to the more appropriate "common.h" It only contains helpers for _common_ stuff for all the utilities. The actual high level stuff has been moved to libsquashfs a while ago. Signed-off-by: David Oberhollenzer --- difftool/sqfsdiff.h | 4 +- include/common.h | 139 ++++++++++++++++++++++++++++++++++++ include/highlevel.h | 137 ----------------------------------- lib/sqfshelper/Makemodule.am | 2 +- lib/sqfshelper/comp_opt.c | 4 +- lib/sqfshelper/compress.c | 2 +- lib/sqfshelper/data_reader_dump.c | 6 +- lib/sqfshelper/data_writer.c | 4 +- lib/sqfshelper/get_path.c | 4 +- lib/sqfshelper/inode_stat.c | 4 +- lib/sqfshelper/io_stdin.c | 5 +- lib/sqfshelper/perror.c | 6 +- lib/sqfshelper/serialize_fstree.c | 10 +-- lib/sqfshelper/statistics.c | 5 +- lib/sqfshelper/write_export_table.c | 5 +- lib/sqfshelper/writer.c | 7 +- mkfs/mkfs.h | 2 +- tar/sqfs2tar.c | 8 +-- tar/tar2sqfs.c | 3 +- unpack/rdsquashfs.h | 12 +--- 20 files changed, 157 insertions(+), 212 deletions(-) create mode 100644 include/common.h delete mode 100644 include/highlevel.h diff --git a/difftool/sqfsdiff.h b/difftool/sqfsdiff.h index 2b3f2bd..8cef23a 100644 --- a/difftool/sqfsdiff.h +++ b/difftool/sqfsdiff.h @@ -8,9 +8,7 @@ #define DIFFTOOL_H #include "config.h" - -#include "sqfs/error.h" -#include "highlevel.h" +#include "common.h" #include "fstree.h" #include "util.h" diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..d4e11c4 --- /dev/null +++ b/include/common.h @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * common.h + * + * Copyright (C) 2019 David Oberhollenzer + */ +#ifndef COMMON_H +#define COMMON_H + +#include "config.h" + +#include "sqfs/xattr_writer.h" +#include "sqfs/xattr_reader.h" +#include "sqfs/compressor.h" +#include "sqfs/id_table.h" +#include "sqfs/inode.h" +#include "sqfs/table.h" +#include "sqfs/error.h" +#include "sqfs/meta_writer.h" +#include "sqfs/data_reader.h" +#include "sqfs/data_writer.h" +#include "sqfs/dir_writer.h" +#include "sqfs/dir_reader.h" +#include "sqfs/block.h" +#include "sqfs/xattr.h" +#include "sqfs/dir.h" +#include "sqfs/io.h" +#include "compat.h" +#include "fstree.h" +#include "util.h" +#include "tar.h" + +#include + +typedef struct { + size_t file_count; + size_t blocks_written; + size_t frag_blocks_written; + size_t duplicate_blocks; + size_t sparse_blocks; + size_t frag_count; + size_t frag_dup; + sqfs_u64 bytes_written; + sqfs_u64 bytes_read; +} data_writer_stats_t; + +typedef struct { + sqfs_data_writer_t *data; + sqfs_compressor_t *cmp; + sqfs_id_table_t *idtbl; + sqfs_file_t *outfile; + sqfs_super_t super; + fstree_t fs; + data_writer_stats_t stats; + sqfs_xattr_writer_t *xwr; +} sqfs_writer_t; + +typedef struct { + const char *filename; + char *fs_defaults; + char *comp_extra; + size_t block_size; + size_t devblksize; + size_t max_backlog; + size_t num_jobs; + + int outmode; + E_SQFS_COMPRESSOR comp_id; + + bool exportable; + bool no_xattr; + bool quiet; +} sqfs_writer_cfg_t; + +/* + High level helper function to serialize an entire file system tree to + a squashfs inode table and directory table. + + The data is written to the given file descriptor and the super block is + update accordingly (inode and directory table start and total size). + + The function internally creates two meta data writers and uses + meta_writer_write_inode to serialize the inode table of the fstree. + + Returns 0 on success. Prints error messages to stderr on failure. + */ +int sqfs_serialize_fstree(const char *filename, sqfs_file_t *file, + sqfs_super_t *super, fstree_t *fs, + sqfs_compressor_t *cmp, sqfs_id_table_t *idtbl); + +/* + Generate an NFS export table. + + Returns 0 on success. Prints error messages to stderr on failure. + */ +int write_export_table(const char *filename, sqfs_file_t *file, + fstree_t *fs, sqfs_super_t *super, + sqfs_compressor_t *cmp); + +/* Print out fancy statistics for squashfs packing tools */ +void sqfs_print_statistics(sqfs_super_t *super, data_writer_stats_t *stats); + +void compressor_print_available(void); + +E_SQFS_COMPRESSOR compressor_get_default(void); + +int compressor_cfg_init_options(sqfs_compressor_config_t *cfg, + E_SQFS_COMPRESSOR id, + size_t block_size, char *options); + +void compressor_print_help(E_SQFS_COMPRESSOR id); + +int inode_stat(const sqfs_tree_node_t *node, struct stat *sb); + +char *sqfs_tree_node_get_path(const sqfs_tree_node_t *node); + +int sqfs_data_reader_dump(const char *name, sqfs_data_reader_t *data, + const sqfs_inode_generic_t *inode, + int outfd, size_t block_size, bool allow_sparse); + +sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, sqfs_u64 size); + +void register_stat_hooks(sqfs_data_writer_t *data, data_writer_stats_t *stats); + +int write_data_from_file(const char *filename, sqfs_data_writer_t *data, + sqfs_inode_generic_t *inode, + sqfs_file_t *file, int flags); + +void sqfs_writer_cfg_init(sqfs_writer_cfg_t *cfg); + +int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg); + +int sqfs_writer_finish(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *cfg); + +void sqfs_writer_cleanup(sqfs_writer_t *sqfs); + +void sqfs_perror(const char *file, const char *action, int error_code); + +#endif /* COMMON_H */ diff --git a/include/highlevel.h b/include/highlevel.h deleted file mode 100644 index be2302b..0000000 --- a/include/highlevel.h +++ /dev/null @@ -1,137 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * highlevel.h - * - * Copyright (C) 2019 David Oberhollenzer - */ -#ifndef HIGHLEVEL_H -#define HIGHLEVEL_H - -#include "config.h" - -#include "sqfs/xattr_writer.h" -#include "sqfs/compressor.h" -#include "sqfs/id_table.h" -#include "sqfs/inode.h" -#include "sqfs/table.h" -#include "sqfs/meta_writer.h" -#include "sqfs/data_reader.h" -#include "sqfs/data_writer.h" -#include "sqfs/dir_writer.h" -#include "sqfs/dir_reader.h" -#include "sqfs/block.h" -#include "sqfs/xattr.h" -#include "sqfs/dir.h" -#include "sqfs/io.h" -#include "compat.h" -#include "fstree.h" -#include "util.h" -#include "tar.h" - -#include - -typedef struct { - size_t file_count; - size_t blocks_written; - size_t frag_blocks_written; - size_t duplicate_blocks; - size_t sparse_blocks; - size_t frag_count; - size_t frag_dup; - sqfs_u64 bytes_written; - sqfs_u64 bytes_read; -} data_writer_stats_t; - -typedef struct { - sqfs_data_writer_t *data; - sqfs_compressor_t *cmp; - sqfs_id_table_t *idtbl; - sqfs_file_t *outfile; - sqfs_super_t super; - fstree_t fs; - data_writer_stats_t stats; - sqfs_xattr_writer_t *xwr; -} sqfs_writer_t; - -typedef struct { - const char *filename; - char *fs_defaults; - char *comp_extra; - size_t block_size; - size_t devblksize; - size_t max_backlog; - size_t num_jobs; - - int outmode; - E_SQFS_COMPRESSOR comp_id; - - bool exportable; - bool no_xattr; - bool quiet; -} sqfs_writer_cfg_t; - -/* - High level helper function to serialize an entire file system tree to - a squashfs inode table and directory table. - - The data is written to the given file descriptor and the super block is - update accordingly (inode and directory table start and total size). - - The function internally creates two meta data writers and uses - meta_writer_write_inode to serialize the inode table of the fstree. - - Returns 0 on success. Prints error messages to stderr on failure. - */ -int sqfs_serialize_fstree(const char *filename, sqfs_file_t *file, - sqfs_super_t *super, fstree_t *fs, - sqfs_compressor_t *cmp, sqfs_id_table_t *idtbl); - -/* - Generate an NFS export table. - - Returns 0 on success. Prints error messages to stderr on failure. - */ -int write_export_table(const char *filename, sqfs_file_t *file, - fstree_t *fs, sqfs_super_t *super, - sqfs_compressor_t *cmp); - -/* Print out fancy statistics for squashfs packing tools */ -void sqfs_print_statistics(sqfs_super_t *super, data_writer_stats_t *stats); - -void compressor_print_available(void); - -E_SQFS_COMPRESSOR compressor_get_default(void); - -int compressor_cfg_init_options(sqfs_compressor_config_t *cfg, - E_SQFS_COMPRESSOR id, - size_t block_size, char *options); - -void compressor_print_help(E_SQFS_COMPRESSOR id); - -int inode_stat(const sqfs_tree_node_t *node, struct stat *sb); - -char *sqfs_tree_node_get_path(const sqfs_tree_node_t *node); - -int sqfs_data_reader_dump(const char *name, sqfs_data_reader_t *data, - const sqfs_inode_generic_t *inode, - int outfd, size_t block_size, bool allow_sparse); - -sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, sqfs_u64 size); - -void register_stat_hooks(sqfs_data_writer_t *data, data_writer_stats_t *stats); - -int write_data_from_file(const char *filename, sqfs_data_writer_t *data, - sqfs_inode_generic_t *inode, - sqfs_file_t *file, int flags); - -void sqfs_writer_cfg_init(sqfs_writer_cfg_t *cfg); - -int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg); - -int sqfs_writer_finish(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *cfg); - -void sqfs_writer_cleanup(sqfs_writer_t *sqfs); - -void sqfs_perror(const char *file, const char *action, int error_code); - -#endif /* HIGHLEVEL_H */ diff --git a/lib/sqfshelper/Makemodule.am b/lib/sqfshelper/Makemodule.am index 870cc86..b72b904 100644 --- a/lib/sqfshelper/Makemodule.am +++ b/lib/sqfshelper/Makemodule.am @@ -5,7 +5,7 @@ libsqfshelper_a_SOURCES += lib/sqfshelper/print_version.c libsqfshelper_a_SOURCES += lib/sqfshelper/inode_stat.c libsqfshelper_a_SOURCES += lib/sqfshelper/data_reader_dump.c libsqfshelper_a_SOURCES += lib/sqfshelper/compress.c lib/sqfshelper/comp_opt.c -libsqfshelper_a_SOURCES += lib/sqfshelper/data_writer.c include/highlevel.h +libsqfshelper_a_SOURCES += lib/sqfshelper/data_writer.c include/common.h libsqfshelper_a_SOURCES += lib/sqfshelper/get_path.c lib/sqfshelper/io_stdin.c libsqfshelper_a_SOURCES += lib/sqfshelper/writer.c lib/sqfshelper/perror.c diff --git a/lib/sqfshelper/comp_opt.c b/lib/sqfshelper/comp_opt.c index fa4157b..2b92da3 100644 --- a/lib/sqfshelper/comp_opt.c +++ b/lib/sqfshelper/comp_opt.c @@ -4,9 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "highlevel.h" +#include "common.h" #include #include diff --git a/lib/sqfshelper/compress.c b/lib/sqfshelper/compress.c index 9f89e45..04e1f40 100644 --- a/lib/sqfshelper/compress.c +++ b/lib/sqfshelper/compress.c @@ -4,7 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "highlevel.h" +#include "common.h" E_SQFS_COMPRESSOR compressor_get_default(void) { diff --git a/lib/sqfshelper/data_reader_dump.c b/lib/sqfshelper/data_reader_dump.c index 1a4ca65..140f527 100644 --- a/lib/sqfshelper/data_reader_dump.c +++ b/lib/sqfshelper/data_reader_dump.c @@ -4,11 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "sqfs/data_reader.h" -#include "sqfs/block.h" -#include "highlevel.h" +#include "common.h" #include "util.h" #include diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c index 960cf77..36de154 100644 --- a/lib/sqfshelper/data_writer.c +++ b/lib/sqfshelper/data_writer.c @@ -4,9 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "highlevel.h" +#include "common.h" #include "util.h" static sqfs_u8 buffer[4096]; diff --git a/lib/sqfshelper/get_path.c b/lib/sqfshelper/get_path.c index a432b4a..bdc6c3f 100644 --- a/lib/sqfshelper/get_path.c +++ b/lib/sqfshelper/get_path.c @@ -4,9 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "highlevel.h" +#include "common.h" #include #include diff --git a/lib/sqfshelper/inode_stat.c b/lib/sqfshelper/inode_stat.c index 67ff764..a73436b 100644 --- a/lib/sqfshelper/inode_stat.c +++ b/lib/sqfshelper/inode_stat.c @@ -4,9 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "highlevel.h" +#include "common.h" #include #include diff --git a/lib/sqfshelper/io_stdin.c b/lib/sqfshelper/io_stdin.c index fec8db7..0e9fb17 100644 --- a/lib/sqfshelper/io_stdin.c +++ b/lib/sqfshelper/io_stdin.c @@ -4,10 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "highlevel.h" -#include "sqfs/error.h" +#include "common.h" #include #include diff --git a/lib/sqfshelper/perror.c b/lib/sqfshelper/perror.c index 6f972d8..9b9f041 100644 --- a/lib/sqfshelper/perror.c +++ b/lib/sqfshelper/perror.c @@ -4,11 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "sqfs/error.h" - -#include "highlevel.h" +#include "common.h" #include diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c index c2d956f..14f0a42 100644 --- a/lib/sqfshelper/serialize_fstree.c +++ b/lib/sqfshelper/serialize_fstree.c @@ -4,15 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "sqfs/meta_writer.h" -#include "sqfs/error.h" -#include "sqfs/inode.h" -#include "sqfs/dir.h" - -#include "highlevel.h" -#include "util.h" +#include "common.h" #include #include diff --git a/lib/sqfshelper/statistics.c b/lib/sqfshelper/statistics.c index fb70615..a209461 100644 --- a/lib/sqfshelper/statistics.c +++ b/lib/sqfshelper/statistics.c @@ -4,10 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" -#include "highlevel.h" - -#include "sqfs/block.h" +#include "common.h" #include diff --git a/lib/sqfshelper/write_export_table.c b/lib/sqfshelper/write_export_table.c index 154688e..c797577 100644 --- a/lib/sqfshelper/write_export_table.c +++ b/lib/sqfshelper/write_export_table.c @@ -4,10 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "highlevel.h" -#include "util.h" +#include "common.h" #include #include diff --git a/lib/sqfshelper/writer.c b/lib/sqfshelper/writer.c index 68d26a3..fa732ad 100644 --- a/lib/sqfshelper/writer.c +++ b/lib/sqfshelper/writer.c @@ -4,12 +4,7 @@ * * Copyright (C) 2019 David Oberhollenzer */ -#include "config.h" - -#include "sqfs/error.h" - -#include "highlevel.h" -#include "util.h" +#include "common.h" #include #include diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h index 0c204e0..046a2a0 100644 --- a/mkfs/mkfs.h +++ b/mkfs/mkfs.h @@ -9,7 +9,7 @@ #include "config.h" -#include "highlevel.h" +#include "common.h" #include "fstree.h" #include "util.h" diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c index 7b306f9..331a907 100644 --- a/tar/sqfs2tar.c +++ b/tar/sqfs2tar.c @@ -5,13 +5,7 @@ * Copyright (C) 2019 David Oberhollenzer */ #include "config.h" - -#include "sqfs/meta_reader.h" -#include "sqfs/compressor.h" -#include "sqfs/data_reader.h" -#include "sqfs/xattr_reader.h" -#include "sqfs/error.h" -#include "highlevel.h" +#include "common.h" #include "util.h" #include "tar.h" diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index a22f2fe..81eb2e4 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -5,8 +5,7 @@ * Copyright (C) 2019 David Oberhollenzer */ #include "config.h" - -#include "highlevel.h" +#include "common.h" #include "tar.h" #include diff --git a/unpack/rdsquashfs.h b/unpack/rdsquashfs.h index 572a48b..c2af24a 100644 --- a/unpack/rdsquashfs.h +++ b/unpack/rdsquashfs.h @@ -8,17 +8,7 @@ #define RDSQUASHFS_H #include "config.h" - -#include "sqfs/xattr_reader.h" -#include "sqfs/meta_reader.h" -#include "sqfs/data_reader.h" -#include "sqfs/compressor.h" -#include "sqfs/id_table.h" -#include "sqfs/xattr.h" -#include "sqfs/block.h" -#include "sqfs/error.h" - -#include "highlevel.h" +#include "common.h" #include "fstree.h" #include "util.h" -- cgit v1.2.3