logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: a634c7fd3c187600231459ad9ea624ceb15336b0
parent 9f44ace11c0752c857e92748885fe636950225c8
Author: Michael Forney <mforney@mforney.org>
Date:   Sat, 30 May 2020 01:55:34 -0700

Add squashfs-tools-ng 0.9.1

Diffstat:

M.gitmodules4++++
Mpkg/gen.lua1+
Apkg/squashfs-tools-ng/config.h36++++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/gen.lua141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/patch/0001-Remove-unnecessary-alloca.patch36++++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/patch/0002-Add-missing-includes-of-alloca.h.patch38++++++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/patch/0003-Use-_MAX-to-remove-need-for-configure-time-type-size.patch192+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/patch/0004-Add-mul-add-overflow-fallbacks.patch35+++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/patch/0005-Avoid-unnecessary-VLAs.patch57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/squashfs-tools-ng/src1+
Apkg/squashfs-tools-ng/ver1+
11 files changed, 542 insertions(+), 0 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -261,6 +261,10 @@ path = pkg/squashfs-tools/src url = https://github.com/plougher/squashfs-tools.git ignore = all +[submodule "pkg/squashfs-tools-ng/src"] + path = pkg/squashfs-tools-ng/src + url = https://github.com/AgentD/squashfs-tools-ng.git + ignore = all [submodule "pkg/sshfs/src"] path = pkg/sshfs/src url = https://github.com/libfuse/sshfs diff --git a/pkg/gen.lua b/pkg/gen.lua @@ -94,6 +94,7 @@ subgen 'sdhcp' subgen 'sinit' subgen 'skeleton' subgen 'squashfs-tools' +subgen 'squashfs-tools-ng' subgen 'sshfs' subgen 'st' subgen 'strace' diff --git a/pkg/squashfs-tools-ng/config.h b/pkg/squashfs-tools-ng/config.h @@ -0,0 +1,36 @@ +#define WITH_GZIP 1 + +#define HAVE_DLFCN_H 1 +#define HAVE_GETLINE 1 +#define HAVE_GETSUBOPT 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_PTHREAD_PRIO_INHERIT 1 +/* #undef HAVE_SELINUX_LABEL_H */ +/* #undef HAVE_SELINUX_SELINUX_H */ +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRNDUP 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_SYSINFO_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_XATTR_H 1 +#define HAVE_UNISTD_H 1 +#define LT_OBJDIR ".libs/" +#define PACKAGE "squashfs-tools-ng" +#define PACKAGE_BUGREPORT "goliath@infraroot.at" +#define PACKAGE_NAME "squashfs-tools-ng" +#define PACKAGE_STRING "squashfs-tools-ng 0.9.1" +#define PACKAGE_TARNAME "squashfs-tools-ng" +#define PACKAGE_URL "" +#define PACKAGE_VERSION "0.9.1" +/* #undef PTHREAD_CREATE_JOINABLE */ +#define STDC_HEADERS 1 +#define VERSION "0.9.1" +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif +/* #undef _FILE_OFFSET_BITS */ +/* #undef _LARGE_FILES */ diff --git a/pkg/squashfs-tools-ng/gen.lua b/pkg/squashfs-tools-ng/gen.lua @@ -0,0 +1,141 @@ +cflags{ + '-std=c99', '-Wall', '-Wpedantic', + '-D _XOPEN_SOURCE=700', + '-I $srcdir', + '-I $srcdir/include', + '-I $dir', +} + +pkg.deps = {} + +local cfg = {} +for line in iterlines('config.h', 1) do + local var = line:match('^#define (WITH_[%w_]+)') + if var then + cfg[var] = true + end +end + +local srcs = paths[[ + lib/sqfs/( + id_table.c super.c + readdir.c xattr.c + write_table.c meta_writer.c + read_super.c meta_reader.c + read_inode.c write_inode.c + dir_writer.c xattr_reader.c + read_table.c comp/compressor.c + xattr_writer.c + dir_reader.c read_tree.c + inode.c + write_super.c data_reader.c + block_processor/common.c + frag_table.c + block_writer.c + + unix/io_file.c + block_processor/winpthread.c + ) + libutil.a +]] + +if cfg.WITH_GZIP then + cflags{'-I $builddir/pkg/zlib/include'} + table.insert(pkg.deps, 'pkg/zlib/headers') + table.insert(srcs, { + 'lib/sqfs/comp/gzip.c', + '$builddir/pkg/zlib/libz.a', + }) +end + +lib('libsquashfs.a', srcs) + +lib('libcommon.a', [[ + lib/common/( + serialize_fstree.c statistics.c + inode_stat.c hardlink.c + print_version.c data_reader_dump.c + compress.c comp_opt.c + data_writer.c + get_path.c io_stdin.c + writer.c perror.c + mkdir_p.c parse_size.c + print_size.c + ) + libsquashfs.a.d + libfstree.a +]]) + +lib('libfstree.a', [[ + lib/fstree/( + fstree.c fstree_from_file.c + fstree_sort.c hardlink.c + post_process.c get_path.c + mknode.c + add_by_path.c get_by_path.c + source_date_epoch.c + canonicalize_name.c + filename_sane.c + ) +]]) + +lib('libtar.a', [[ + lib/tar/( + read_header.c write_header.c skip.c + number.c checksum.c cleanup.c + read_sparse_map.c read_sparse_map_old.c + base64.c urldecode.c + padd_file.c read_retry.c + write_retry.c pax_header.c + ) +]]) + +lib('libutil.a', [[ + lib/util/( + str_table.c alloc.c + rbtree.c + xxhash.c hash_table.c + ) +]]) + +exe('gensquashfs', [[ + bin/gensquashfs/(mkfs.c options.c selinux.c dirscan.c dirscan_xattr.c) + libcommon.a.d +]]) +file('bin/gensquashfs', '755', '$outdir/gensquashfs') +man{'doc/gensquashfs.1'} + +exe('rdsquashfs', [[ + bin/rdsquashfs/( + rdsquashfs.c + list_files.c options.c + restore_fstree.c describe.c + fill_files.c dump_xattrs.c + ) + libcommon.a.d +]]) +file('bin/rdsquashfs', '755', '$outdir/rdsquashfs') +man{'doc/rdsquashfs.1'} + +exe('sqfsdiff', [[ + bin/sqfsdiff/( + sqfsdiff.c + util.c options.c + compare_dir.c node_compare.c + compare_files.c super.c + extract.c + ) + libcommon.a.d +]]) +file('bin/sqfsdiff', '755', '$outdir/sqfsdiff') +man{'doc/sqfsdiff.1'} + +exe('sqfs2tar', 'bin/sqfs2tar.c libcommon.a.d libtar.a') +file('bin/sqfs2tar', '755', '$outdir/sqfs2tar') +man{'doc/sqfs2tar.1'} + +exe('tar2sqfs', 'bin/tar2sqfs.c libcommon.a.d libtar.a') +file('bin/tar2sqfs', '755', '$outdir/tar2sqfs') +man{'doc/tar2sqfs.1'} + +fetch 'git' diff --git a/pkg/squashfs-tools-ng/patch/0001-Remove-unnecessary-alloca.patch b/pkg/squashfs-tools-ng/patch/0001-Remove-unnecessary-alloca.patch @@ -0,0 +1,36 @@ +From 196586b33706fc3d8efaf51d60676be307f525e3 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sat, 30 May 2020 00:24:00 -0700 +Subject: [PATCH] Remove unnecessary alloca + +--- + lib/common/io_stdin.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/common/io_stdin.c b/lib/common/io_stdin.c +index 4694989..6451f6b 100644 +--- a/lib/common/io_stdin.c ++++ b/lib/common/io_stdin.c +@@ -43,7 +43,7 @@ static int stdin_read_at(sqfs_file_t *base, sqfs_u64 offset, + { + sqfs_file_stdinout_t *file = (sqfs_file_stdinout_t *)base; + size_t temp_size = 0; +- sqfs_u8 *temp = NULL; ++ sqfs_u8 *temp = NULL, temp_buf[1024]; + sqfs_u64 diff; + size_t ret; + +@@ -51,8 +51,8 @@ static int stdin_read_at(sqfs_file_t *base, sqfs_u64 offset, + return SQFS_ERROR_IO; + + if (offset > file->offset) { +- temp_size = 1024; +- temp = alloca(temp_size); ++ temp_size = sizeof(temp_buf); ++ temp = temp_buf; + } + + if (offset >= file->real_size || (offset + size) > file->real_size) +-- +2.26.2 + diff --git a/pkg/squashfs-tools-ng/patch/0002-Add-missing-includes-of-alloca.h.patch b/pkg/squashfs-tools-ng/patch/0002-Add-missing-includes-of-alloca.h.patch @@ -0,0 +1,38 @@ +From d7dd64b56ce96630d01a269439b86dc940c9df07 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sat, 30 May 2020 00:24:10 -0700 +Subject: [PATCH] Add missing includes of alloca.h + +--- + bin/sqfsdiff/extract.c | 2 ++ + lib/common/mkdir_p.c | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/bin/sqfsdiff/extract.c b/bin/sqfsdiff/extract.c +index 979572a..45e32e7 100644 +--- a/bin/sqfsdiff/extract.c ++++ b/bin/sqfsdiff/extract.c +@@ -6,6 +6,8 @@ + */ + #include "sqfsdiff.h" + ++#include <alloca.h> ++ + static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, + const char *prefix, const char *path, size_t block_size) + { +diff --git a/lib/common/mkdir_p.c b/lib/common/mkdir_p.c +index 0413495..b1845b1 100644 +--- a/lib/common/mkdir_p.c ++++ b/lib/common/mkdir_p.c +@@ -6,6 +6,7 @@ + */ + #include "common.h" + ++#include <alloca.h> + #include <string.h> + #include <stdlib.h> + #include <stdio.h> +-- +2.26.2 + diff --git a/pkg/squashfs-tools-ng/patch/0003-Use-_MAX-to-remove-need-for-configure-time-type-size.patch b/pkg/squashfs-tools-ng/patch/0003-Use-_MAX-to-remove-need-for-configure-time-type-size.patch @@ -0,0 +1,192 @@ +From b288e677f7258365379dae8708044fea14774d22 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sat, 30 May 2020 01:23:59 -0700 +Subject: [PATCH] Use *_MAX to remove need for configure-time type size checks + +--- + configure.ac | 5 -- + include/compat.h | 14 +++-- + m4/ax_compile_check_sizeof.m4 | 115 ---------------------------------- + 3 files changed, 8 insertions(+), 126 deletions(-) + delete mode 100644 m4/ax_compile_check_sizeof.m4 + +diff --git a/configure.ac b/configure.ac +index a47872e..7bf97b2 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -231,11 +231,6 @@ PKG_CHECK_MODULES(READLINE, [readline], [have_readline="yes"], + AM_CONDITIONAL([WITH_READLINE], [test "x$have_readline" = "xyes"]) + + ##### additional checks ##### +-AX_COMPILE_CHECK_SIZEOF(size_t) +-AX_COMPILE_CHECK_SIZEOF(int) +-AX_COMPILE_CHECK_SIZEOF(long) +-AX_COMPILE_CHECK_SIZEOF(long long) +- + AC_CHECK_HEADERS([sys/xattr.h], [], []) + AC_CHECK_HEADERS([sys/sysinfo.h], [], []) + +diff --git a/include/compat.h b/include/compat.h +index b2bb054..3eac307 100644 +--- a/include/compat.h ++++ b/include/compat.h +@@ -9,15 +9,17 @@ + + #include "sqfs/predef.h" + ++#include <limits.h> ++ + #if defined(__GNUC__) || defined(__clang__) + # if defined(__GNUC__) && __GNUC__ < 5 +-# if SIZEOF_SIZE_T <= SIZEOF_INT ++# if SIZE_MAX <= UINT_MAX + # define SZ_ADD_OV __builtin_uadd_overflow + # define SZ_MUL_OV __builtin_umul_overflow +-# elif SIZEOF_SIZE_T == SIZEOF_LONG ++# elif SIZE_MAX == ULONG_MAX + # define SZ_ADD_OV __builtin_uaddl_overflow + # define SZ_MUL_OV __builtin_umull_overflow +-# elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG ++# elif SIZE_MAX == ULLONG_MAX + # define SZ_ADD_OV __builtin_uaddll_overflow + # define SZ_MUL_OV __builtin_umulll_overflow + # else +@@ -40,11 +42,11 @@ + # define PRI_U32 "%" PRIu32 + #endif + +-#if SIZEOF_SIZE_T <= SIZEOF_INT ++#if SIZE_MAX <= UINT_MAX + # define PRI_SZ "%u" +-#elif SIZEOF_SIZE_T == SIZEOF_LONG ++#elif SIZE_MAX == ULONG_MAX + # define PRI_SZ "%lu" +-#elif defined(_WIN32) && SIZEOF_SIZE_T == 8 ++#elif defined(_WIN32) && SIZE_MAX == UINT64_MAX + # define PRI_SZ "%I64u" + #else + # error Cannot figure out propper printf specifier for size_t +diff --git a/m4/ax_compile_check_sizeof.m4 b/m4/ax_compile_check_sizeof.m4 +deleted file mode 100644 +index f834df6..0000000 +--- a/m4/ax_compile_check_sizeof.m4 ++++ /dev/null +@@ -1,115 +0,0 @@ +-# ============================================================================ +-# https://www.gnu.org/software/autoconf-archive/ax_compile_check_sizeof.html +-# ============================================================================ +-# +-# SYNOPSIS +-# +-# AX_COMPILE_CHECK_SIZEOF(TYPE [, HEADERS [, EXTRA_SIZES...]]) +-# +-# DESCRIPTION +-# +-# This macro checks for the size of TYPE using compile checks, not run +-# checks. You can supply extra HEADERS to look into. the check will cycle +-# through 1 2 4 8 16 and any EXTRA_SIZES the user supplies. If a match is +-# found, it will #define SIZEOF_`TYPE' to that value. Otherwise it will +-# emit a configure time error indicating the size of the type could not be +-# determined. +-# +-# The trick is that C will not allow duplicate case labels. While this is +-# valid C code: +-# +-# switch (0) case 0: case 1:; +-# +-# The following is not: +-# +-# switch (0) case 0: case 0:; +-# +-# Thus, the AC_COMPILE_IFELSE will fail if the currently tried size does +-# not match. +-# +-# Here is an example skeleton configure.in script, demonstrating the +-# macro's usage: +-# +-# AC_PROG_CC +-# AC_CHECK_HEADERS(stddef.h unistd.h) +-# AC_TYPE_SIZE_T +-# AC_CHECK_TYPE(ssize_t, int) +-# +-# headers='#ifdef HAVE_STDDEF_H +-# #include <stddef.h> +-# #endif +-# #ifdef HAVE_UNISTD_H +-# #include <unistd.h> +-# #endif +-# ' +-# +-# AX_COMPILE_CHECK_SIZEOF(char) +-# AX_COMPILE_CHECK_SIZEOF(short) +-# AX_COMPILE_CHECK_SIZEOF(int) +-# AX_COMPILE_CHECK_SIZEOF(long) +-# AX_COMPILE_CHECK_SIZEOF(unsigned char *) +-# AX_COMPILE_CHECK_SIZEOF(void *) +-# AX_COMPILE_CHECK_SIZEOF(size_t, $headers) +-# AX_COMPILE_CHECK_SIZEOF(ssize_t, $headers) +-# AX_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers) +-# AX_COMPILE_CHECK_SIZEOF(off_t, $headers) +-# +-# LICENSE +-# +-# Copyright (c) 2008 Kaveh Ghazi <ghazi@caip.rutgers.edu> +-# Copyright (c) 2017 Reini Urban <rurban@cpan.org> +-# +-# This program is free software: you can redistribute it and/or modify it +-# under the terms of the GNU General Public License as published by the +-# Free Software Foundation, either version 3 of the License, or (at your +-# option) any later version. +-# +-# This program is distributed in the hope that it will be useful, but +-# WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +-# Public License for more details. +-# +-# You should have received a copy of the GNU General Public License along +-# with this program. If not, see <https://www.gnu.org/licenses/>. +-# +-# As a special exception, the respective Autoconf Macro's copyright owner +-# gives unlimited permission to copy, distribute and modify the configure +-# scripts that are the output of Autoconf when processing the Macro. You +-# need not follow the terms of the GNU General Public License when using +-# or distributing such scripts, even though portions of the text of the +-# Macro appear in them. The GNU General Public License (GPL) does govern +-# all other use of the material that constitutes the Autoconf Macro. +-# +-# This special exception to the GPL applies to versions of the Autoconf +-# Macro released by the Autoconf Archive. When you make and distribute a +-# modified version of the Autoconf Macro, you may extend this special +-# exception to the GPL to apply to your modified version as well. +- +-#serial 8 +- +-AU_ALIAS([AC_COMPILE_CHECK_SIZEOF], [AX_COMPILE_CHECK_SIZEOF]) +-AC_DEFUN([AX_COMPILE_CHECK_SIZEOF], +-[changequote(<<, >>)dnl +-dnl The name to #define. +-define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl +-dnl The cache variable name. +-define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl +-changequote([, ])dnl +-AC_MSG_CHECKING(size of $1) +-AC_CACHE_VAL(AC_CV_NAME, +-[for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence. +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include <sys/types.h> +-$2 +-]], [[switch (0) case 0: case (sizeof ($1) == $ac_size):;]])], [AC_CV_NAME=$ac_size]) +- if test x$AC_CV_NAME != x ; then break; fi +-done +-]) +-if test x$AC_CV_NAME = x ; then +- AC_MSG_ERROR([cannot determine a size for $1]) +-fi +-AC_MSG_RESULT($AC_CV_NAME) +-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) +-undefine([AC_TYPE_NAME])dnl +-undefine([AC_CV_NAME])dnl +-]) +-- +2.26.2 + diff --git a/pkg/squashfs-tools-ng/patch/0004-Add-mul-add-overflow-fallbacks.patch b/pkg/squashfs-tools-ng/patch/0004-Add-mul-add-overflow-fallbacks.patch @@ -0,0 +1,35 @@ +From 1bcd4df6fbcd9c3dbace99b62065b05a75653d4b Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sat, 30 May 2020 01:45:49 -0700 +Subject: [PATCH] Add mul/add overflow fallbacks + +--- + include/compat.h | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/include/compat.h b/include/compat.h +index 3eac307..5a879e2 100644 +--- a/include/compat.h ++++ b/include/compat.h +@@ -30,7 +30,17 @@ + # define SZ_MUL_OV __builtin_mul_overflow + # endif + #else +-# error I do not know how to trap integer overflows with this compiler ++static inline bool SZ_ADD_OV(size_t a, size_t b, size_t *res) ++{ ++ *res = a + b; ++ return a > SIZE_MAX - b; ++} ++ ++static inline bool SZ_MUL_OV(size_t a, size_t b, size_t *res) ++{ ++ *res = a * b; ++ return b && a > SIZE_MAX / b; ++} + #endif + + #if defined(_WIN32) || defined(__WINDOWS__) +-- +2.26.2 + diff --git a/pkg/squashfs-tools-ng/patch/0005-Avoid-unnecessary-VLAs.patch b/pkg/squashfs-tools-ng/patch/0005-Avoid-unnecessary-VLAs.patch @@ -0,0 +1,57 @@ +From ce07abcd65ad1d5c39c53b39a16bc8d960fd3279 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sat, 30 May 2020 01:50:48 -0700 +Subject: [PATCH] Avoid unnecessary VLAs + +All compressors use only 8 bytes for options, so just use a fixed +32-byte buffer. +--- + lib/sqfs/comp/compressor.c | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +diff --git a/lib/sqfs/comp/compressor.c b/lib/sqfs/comp/compressor.c +index 946ee25..7e3f092 100644 +--- a/lib/sqfs/comp/compressor.c ++++ b/lib/sqfs/comp/compressor.c +@@ -42,27 +42,33 @@ static const char *names[] = { + + int sqfs_generic_write_options(sqfs_file_t *file, const void *data, size_t size) + { +- sqfs_u8 buffer[size + 2]; ++ sqfs_u8 buffer[32]; + int ret; + ++ if (size > sizeof(buffer) - 2) ++ return SQFS_ERROR_INTERNAL; ++ + *((sqfs_u16 *)buffer) = htole16(0x8000 | size); + memcpy(buffer + 2, data, size); + + ret = file->write_at(file, sizeof(sqfs_super_t), +- buffer, sizeof(buffer)); ++ buffer, 2 + size); + if (ret) + return ret; + +- return sizeof(buffer); ++ return 2 + size; + } + + int sqfs_generic_read_options(sqfs_file_t *file, void *data, size_t size) + { +- sqfs_u8 buffer[size + 2]; ++ sqfs_u8 buffer[32]; + int ret; + ++ if (size > sizeof(buffer) - 2) ++ return SQFS_ERROR_INTERNAL; ++ + ret = file->read_at(file, sizeof(sqfs_super_t), +- buffer, sizeof(buffer)); ++ buffer, 2 + size); + if (ret) + return ret; + +-- +2.26.2 + diff --git a/pkg/squashfs-tools-ng/src b/pkg/squashfs-tools-ng/src @@ -0,0 +1 @@ +Subproject commit d4cccaa8dd4c49eba3d26f078769e72d71c4563d diff --git a/pkg/squashfs-tools-ng/ver b/pkg/squashfs-tools-ng/ver @@ -0,0 +1 @@ +0.9.1 r0