diff --git a/README.md b/README.md index 1620b01fcf1..2d32592b95a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This project is based on original rt-n56u with latest mtk 4.4.198 kernel, which - Added ccache support, may save up to 50%+ build time - Upgraded the toolchain and libc: - gcc 13.3.0 - - musl 1.2.5 / uClibc-ng 1.0.48 + - musl 1.2.5 / uClibc-ng 1.0.50 - OpenWrt style package Makefile - Enabled kernel cgroups support - Fixed K2P led label names diff --git a/toolchain/config/libc/glibc.in b/toolchain/config/libc/glibc.in index 52cb3149241..8f1e0672dab 100644 --- a/toolchain/config/libc/glibc.in +++ b/toolchain/config/libc/glibc.in @@ -68,7 +68,7 @@ config GLIBC_DEP_MAKE_4_0 # where the build process hangs indefinitely config GLIBC_DEP_MAKE_4_3 def_bool y - depends on GLIBC_older_than_2_32 && CONFIGURE_has_make_4_4_or_newer + depends on GLIBC_older_than_2_32 && (CONFIGURE_has_make_4_4_or_newer || GLIBC_DEP_MAKE_4_0) select COMP_TOOLS_MAKE select MAKE_GNUMAKE_SYMLINK select MAKE_REQUIRE_older_than_4_4 @@ -197,8 +197,8 @@ config GLIBC_ENABLE_DEBUG config GLIBC_EXTRA_CFLAGS string prompt "extra target CFLAGS" - default "-Wno-missing-attributes -Wno-array-bounds -Wno-array-parameter -Wno-stringop-overflow -Wno-maybe-uninitialized" if GLIBC_2_29_or_older && GCC_11_or_later - default "" + default "-Wno-missing-attributes -Wno-array-bounds -Wno-array-parameter -Wno-stringop-overflow -Wno-maybe-uninitialized" if GLIBC_2_29_or_older && GCC_11_or_later && !GCC_14_or_later + default "-Wno-missing-attributes -Wno-array-bounds -Wno-array-parameter -Wno-stringop-overflow -Wno-maybe-uninitialized -Wno-implicit-int" if GLIBC_2_29_or_older && GCC_14_or_later help Extra target CFLAGS to use when building. diff --git a/toolchain/packages/avr-libc/2.2.1/chksum b/toolchain/packages/avr-libc/2.2.1/chksum new file mode 100644 index 00000000000..f9b06be06ac --- /dev/null +++ b/toolchain/packages/avr-libc/2.2.1/chksum @@ -0,0 +1,4 @@ +md5 avr-libc-2.2.1.tar.bz2 400bef303b53e45e0e30d2a617c60a79 +sha1 avr-libc-2.2.1.tar.bz2 9868b17dc67e5c2e87b9fbbe7232d18947638dc5 +sha256 avr-libc-2.2.1.tar.bz2 006a6306cbbc938c3bdb583ac54f93fe7d7c8cf97f9cde91f91c6fb0273ab465 +sha512 avr-libc-2.2.1.tar.bz2 7746c701e9172584bb8923b941958b7ab7ff323bcf1fe6c46a46e3627f74bb750dcaeab23fbb8ba535c7aa2d56347a9d1b7c64098fda505b24e87e116e71f714 diff --git a/toolchain/packages/picolibc/1.8.6/version.desc b/toolchain/packages/avr-libc/2.2.1/version.desc similarity index 100% rename from toolchain/packages/picolibc/1.8.6/version.desc rename to toolchain/packages/avr-libc/2.2.1/version.desc diff --git a/toolchain/packages/avr-libc/package.desc b/toolchain/packages/avr-libc/package.desc index 24c75958a46..aadb3b2bd97 100644 --- a/toolchain/packages/avr-libc/package.desc +++ b/toolchain/packages/avr-libc/package.desc @@ -1,4 +1,4 @@ repository='git https://github.com/avrdudes/avr-libc.git' -mirrors='http://download.savannah.gnu.org/releases/avr-libc' +mirrors='http://download.savannah.gnu.org/releases/avr-libc https://github.com/avrdudes/avr-libc/releases/download/avr-libc-$(echo ${CT_AVR_LIBC_VERSION} | tr '.' '_')-release' archive_formats='.tar.bz2' signature_format='packed/.sig' diff --git a/toolchain/packages/picolibc/1.8.6/0000-fix-specs_prefix_format-to-point-to-root-toolchain-s.patch b/toolchain/packages/picolibc/1.8.6/0000-fix-specs_prefix_format-to-point-to-root-toolchain-s.patch deleted file mode 100644 index 8a408e1b5ce..00000000000 --- a/toolchain/packages/picolibc/1.8.6/0000-fix-specs_prefix_format-to-point-to-root-toolchain-s.patch +++ /dev/null @@ -1,60 +0,0 @@ -From cf914a3a79578bc97d80c3d3a0090b2fab0eb834 Mon Sep 17 00:00:00 2001 -From: Alexey Lapshin -Date: Thu, 1 Aug 2024 17:00:55 +0700 -Subject: [PATCH] fix specs_prefix_format to point to root toolchain's - directory - ---- - meson.build | 35 +++++++++++++++++++++++++++-------- - 1 file changed, 27 insertions(+), 8 deletions(-) - ---- a/meson.build -+++ b/meson.build -@@ -500,20 +500,39 @@ - endif - - if sysroot_install -+ # Get 'sysroot' or 'GCC_EXEC_PREFIX' from GCC output - sysroot = run_command(cc.cmd_array() + ['-print-sysroot'], check : true).stdout().split('\n')[0] - if sysroot != '' -- specs_prefix_format = '%R/@0@' -+ specs_prefix_format_format = '%R/@0@' -+ specs_prefix_format_default = '%R/@0@' - else -- sysroot = cc_install_dir + '../../../..' -- specs_prefix_format = '%:getenv(GCC_EXEC_PREFIX ../../@0@)' -- endif -- if not get_option('sysroot-install-skip-checks') -- if sysroot == '' -+ if not get_option('sysroot-install-skip-checks') - error('sysroot install requested, but compiler has no sysroot') - endif -- if not fs.is_samepath(sysroot, prefix) -- error('sysroot install requires --prefix=' + sysroot) -+ sysroot = run_command(cc.cmd_array() + ['-print-search-dirs'], check : true).stdout().split('\n')[0].split(' ')[1] -+ specs_prefix_format_format = '%:getenv(GCC_EXEC_PREFIX @0@)' -+ specs_prefix_format_default = '%:getenv(GCC_EXEC_PREFIX ../../@0@)' -+ endif -+ -+ # Try to calculate relative path from sysroot to prefix -+ specs_prefix_format = '' -+ if fs.exists(sysroot) -+ sysroot_to_prefix_correction = '' -+ foreach _ : sysroot.split('/') -+ if fs.is_samepath(sysroot + '/' + sysroot_to_prefix_correction, prefix) -+ specs_prefix_format = specs_prefix_format_format.format(sysroot_to_prefix_correction + '@0@') -+ break -+ endif -+ sysroot_to_prefix_correction += '../' -+ endforeach -+ endif -+ -+ # Use default 'specs_prefix_format' if can not have relative sysroot path -+ if specs_prefix_format == '' -+ if not get_option('sysroot-install-skip-checks') -+ error('sysroot install requires sysroot(' + sysroot + ') to be a subdirectory of --prefix=(' + prefix + ')') - endif -+ specs_prefix_format = specs_prefix_format_default - endif - else - specs_prefix_format = prefix + '/@0@' diff --git a/toolchain/packages/picolibc/1.8.6/chksum b/toolchain/packages/picolibc/1.8.6/chksum deleted file mode 100644 index 26095738675..00000000000 --- a/toolchain/packages/picolibc/1.8.6/chksum +++ /dev/null @@ -1,4 +0,0 @@ -md5 picolibc-1.8.6.tar.xz c6972e4d6e6e7b1275ae8dc80eadb269 -sha1 picolibc-1.8.6.tar.xz a8b1148c782dc931e8c2e41bfe8062192df3f5e9 -sha256 picolibc-1.8.6.tar.xz 9549aac02bef6b2761af124392a7ffc6bbc8dfc8541b698ac032567b516c9b34 -sha512 picolibc-1.8.6.tar.xz f7e03aed7f24fb7a52f1e44bc244abccb72159b01c591aa68c43499f320765a559e4cdfd996bec855447781d8db311bc34f111a4d233cfdaa783f8347bf03f09 diff --git a/toolchain/packages/picolibc/1.8.8/chksum b/toolchain/packages/picolibc/1.8.8/chksum new file mode 100644 index 00000000000..0effb817499 --- /dev/null +++ b/toolchain/packages/picolibc/1.8.8/chksum @@ -0,0 +1,4 @@ +md5 picolibc-1.8.8.tar.xz f895a09650b665dd68ae74780008c182 +sha1 picolibc-1.8.8.tar.xz ee70ebe5ed56e25f70cfb78ac1830f547a9baa03 +sha256 picolibc-1.8.8.tar.xz 565f335e39ba8dfcf3f100b61c929af4861269ae983b4493568f55c5eaa26538 +sha512 picolibc-1.8.8.tar.xz fc7f7a4af5ecc4b5f6e85fe1b4d318dca9555c6d19f59795db29f76e83b48e87f806f2043d96c07028c6748f032b801a0ed68306d28628fd124d8da215510c13 diff --git a/toolchain/packages/zlib/1.3/version.desc b/toolchain/packages/picolibc/1.8.8/version.desc similarity index 100% rename from toolchain/packages/zlib/1.3/version.desc rename to toolchain/packages/picolibc/1.8.8/version.desc diff --git a/toolchain/packages/uClibc-ng/1.0.50/chksum b/toolchain/packages/uClibc-ng/1.0.50/chksum new file mode 100644 index 00000000000..58b4e5ff421 --- /dev/null +++ b/toolchain/packages/uClibc-ng/1.0.50/chksum @@ -0,0 +1,16 @@ +md5 uClibc-ng-1.0.50.tar.xz 22bc49c27947837496a9715e2329a6d6 +sha1 uClibc-ng-1.0.50.tar.xz c258d6a0a93166eae16eebd3768cd697704bab2f +sha256 uClibc-ng-1.0.50.tar.xz aed867251f4823a74ea5e3a3993d3a7c123280abe15e38dc206770c3968f21cf +sha512 uClibc-ng-1.0.50.tar.xz a478cbef1160f12a5ff7453f7b6f9c9d8df49c1421b660cb8e9e2a3b792a662ad0793dc9cec7c00490628f46eaadbe9ec578dd8ea86fc27b0069d1f075422612 +md5 uClibc-ng-1.0.50.tar.lz c246355764d3e99b801a77d216f8457b +sha1 uClibc-ng-1.0.50.tar.lz c209b0db8bb36160218b64dbfd9158d2ba16b357 +sha256 uClibc-ng-1.0.50.tar.lz e338da442fcb6e58c48006e647ec701e0f835fb2b65068f485d08ecf1df992d4 +sha512 uClibc-ng-1.0.50.tar.lz 197ee180177bf589704ac84d2d54db791871735400b6bcb245df309a67d646e42b199627fe0df4d9aeacd76587fe0a90c48563b51a247e8dc9a27fb55f377d89 +md5 uClibc-ng-1.0.50.tar.bz2 6a08f6f6a6006352cfccc16bb800d1da +sha1 uClibc-ng-1.0.50.tar.bz2 33cce2382d85072db1046e0d132ed10f06f7e2cf +sha256 uClibc-ng-1.0.50.tar.bz2 b7ac95dd3ac0b293e82e8e1fcb772269dfab9ee623c1b5c15f04f02a7573de78 +sha512 uClibc-ng-1.0.50.tar.bz2 3b909767d1a8e9c216da0220adeeb1681789f4717088416fb4e15357c160f99df711008c6b6efa9849b6347c3d6c56d1d49d11774057ede2b6ee991f0886c12d +md5 uClibc-ng-1.0.50.tar.gz 067c5acc3ce7b99048776e6b96450ca3 +sha1 uClibc-ng-1.0.50.tar.gz b68c51faf7023e62d5b309e13517fdad0aff8b3b +sha256 uClibc-ng-1.0.50.tar.gz 7b96bc6d0695ee77370ac49116f1012059de0f37342a68cd437e45d876449664 +sha512 uClibc-ng-1.0.50.tar.gz b7f0cecdd14463a003a4b7c414d87c1bd3dbfd3bdee4ed7141df500012a938ae9d0a286035807a2d2d50728688f4f427e1ba46cdcca08e07996edfa31bdd020c diff --git a/toolchain/packages/uClibc-ng/1.0.50/version.desc b/toolchain/packages/uClibc-ng/1.0.50/version.desc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/toolchain/packages/zlib/1.3.1/chksum b/toolchain/packages/zlib/1.3.1/chksum index 369312099d8..bdcd73f533c 100644 --- a/toolchain/packages/zlib/1.3.1/chksum +++ b/toolchain/packages/zlib/1.3.1/chksum @@ -5,4 +5,4 @@ sha512 zlib-1.3.1.tar.xz 1e8e70b362d64a233591906a1f50b59001db04ca14aaffad522198b md5 zlib-1.3.1.tar.gz 9855b6d802d7fe5b7bd5b196a2271655 sha1 zlib-1.3.1.tar.gz f535367b1a11e2f9ac3bec723fb007fbc0d189e5 sha256 zlib-1.3.1.tar.gz 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 -sha512 zlib-1.3.1.tar.gz 580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f \ No newline at end of file +sha512 zlib-1.3.1.tar.gz 580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f diff --git a/toolchain/packages/zlib/1.3/chksum b/toolchain/packages/zlib/1.3/chksum deleted file mode 100644 index 312d187ceec..00000000000 --- a/toolchain/packages/zlib/1.3/chksum +++ /dev/null @@ -1,8 +0,0 @@ -md5 zlib-1.3.tar.xz b49e70aacafacfceb1107943497f5545 -sha1 zlib-1.3.tar.xz 3631636d7166a7f1a3209a3feca45404e6c5f54b -sha256 zlib-1.3.tar.xz 8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7 -sha512 zlib-1.3.tar.xz 3868ac4da5842dd36c9dad794930675b9082ce15cbd099ddb79c0f6bd20a24aa8f33a123f378f26fe0ae02d91f31f2994dccaac565cedeaffed7b315e6ded2a2 -md5 zlib-1.3.tar.gz 60373b133d630f74f4a1f94c1185a53f -sha1 zlib-1.3.tar.gz 04d053e4d4064a0fb8f0cbd127f0bfb5fe4eb554 -sha256 zlib-1.3.tar.gz ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e -sha512 zlib-1.3.tar.gz 185795044461cd78a5545250e06f6efdb0556e8d1bfe44e657b509dd6f00ba8892c8eb3febe65f79ee0b192d6af857f0e0055326d33a881449f3833f92e5f8fb diff --git a/toolchain/samples/mipsel-linux-uclibc-gcc10/crosstool.config b/toolchain/samples/mipsel-linux-uclibc-gcc10/crosstool.config index db1213e88a7..cdab24d5193 100644 --- a/toolchain/samples/mipsel-linux-uclibc-gcc10/crosstool.config +++ b/toolchain/samples/mipsel-linux-uclibc-gcc10/crosstool.config @@ -25,7 +25,7 @@ CT_LINUX_V_4_4=y # CT_KERNEL_LINUX_INSTALL_CHECK is not set CT_LIBC_UCLIBC_NG=y CT_UCLIBC_NG_SRC_RELEASE=y -CT_UCLIBC_NG_V_1_0_49=y +CT_UCLIBC_NG_V_1_0_50=y CT_LIBC_UCLIBC_CONFIG_FILE="${CT_TOP_DIR}/../trunk/configs/boards/uclibc-mipsel.config" CT_LIBC_UCLIBC_IPV6=y CT_LIBC_UCLIBC_WCHAR=y diff --git a/toolchain/samples/mipsel-linux-uclibc-gcc7/crosstool.config b/toolchain/samples/mipsel-linux-uclibc-gcc7/crosstool.config index fd1f0a760e3..9e9280f0668 100644 --- a/toolchain/samples/mipsel-linux-uclibc-gcc7/crosstool.config +++ b/toolchain/samples/mipsel-linux-uclibc-gcc7/crosstool.config @@ -25,7 +25,7 @@ CT_LINUX_V_4_4=y # CT_KERNEL_LINUX_INSTALL_CHECK is not set CT_LIBC_UCLIBC_NG=y CT_UCLIBC_NG_SRC_RELEASE=y -CT_UCLIBC_NG_V_1_0_49=y +CT_UCLIBC_NG_V_1_0_50=y CT_LIBC_UCLIBC_CONFIG_FILE="${CT_TOP_DIR}/../trunk/configs/boards/uclibc-mipsel.config" CT_LIBC_UCLIBC_IPV6=y CT_LIBC_UCLIBC_WCHAR=y diff --git a/toolchain/samples/mipsel-linux-uclibc/crosstool.config b/toolchain/samples/mipsel-linux-uclibc/crosstool.config index 47ce4019f74..f18777727eb 100644 --- a/toolchain/samples/mipsel-linux-uclibc/crosstool.config +++ b/toolchain/samples/mipsel-linux-uclibc/crosstool.config @@ -25,7 +25,7 @@ CT_LINUX_V_4_4=y # CT_KERNEL_LINUX_INSTALL_CHECK is not set CT_LIBC_UCLIBC_NG=y CT_UCLIBC_NG_SRC_RELEASE=y -CT_UCLIBC_NG_V_1_0_49=y +CT_UCLIBC_NG_V_1_0_50=y CT_LIBC_UCLIBC_CONFIG_FILE="${CT_TOP_DIR}/../trunk/configs/boards/uclibc-mipsel.config" CT_LIBC_UCLIBC_IPV6=y CT_LIBC_UCLIBC_WCHAR=y diff --git a/toolchain/scripts/build/cc/gcc.sh b/toolchain/scripts/build/cc/gcc.sh index afcbeb2be6f..6cf7e51f465 100644 --- a/toolchain/scripts/build/cc/gcc.sh +++ b/toolchain/scripts/build/cc/gcc.sh @@ -282,6 +282,7 @@ do_gcc_core_backend() { gcc_build|gcc_host) CT_DoLog EXTRA "Configuring final gcc compiler" extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" ) + extra_config+=( "--with-headers=${CT_PREFIX_DIR}/${CT_TARGET}/include" ) extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) log_txt="final gcc compiler" # to inhibit the libiberty and libgcc tricks later on diff --git a/toolchain/scripts/build/debug/300-gdb.sh b/toolchain/scripts/build/debug/300-gdb.sh index 8f9c51e5f40..ce77260a392 100644 --- a/toolchain/scripts/build/debug/300-gdb.sh +++ b/toolchain/scripts/build/debug/300-gdb.sh @@ -347,7 +347,7 @@ do_gdb_backend() "${extra_config[@]}" \ if [ "${static}" = "y" ]; then - if [ "${GDB_CC_LD_LIBTOOL}" = "y" ]; then + if [ "${CT_GDB_CC_LD_LIBTOOL}" = "y" ]; then extra_make_flags+=("LDFLAGS=${ldflags} -all-static") else extra_make_flags+=("LDFLAGS=${ldflags} -static") diff --git a/toolchain/scripts/crosstool-NG.sh b/toolchain/scripts/crosstool-NG.sh index fdcfe4b3369..bfada4f692d 100644 --- a/toolchain/scripts/crosstool-NG.sh +++ b/toolchain/scripts/crosstool-NG.sh @@ -361,10 +361,12 @@ if [ -z "${CT_RESTART}" ]; then # binutils 2.14 and later obey it, older binutils ignore it. # Lets you build a working 32->64 bit cross gcc CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - # Use --with-headers, else final gcc will define disable_glibc while - # building libgcc, and you'll have no profiling CT_CC_CORE_SYSROOT_ARG=("--without-headers") - CT_CC_SYSROOT_ARG=("--with-headers=${CT_HEADERS_DIR}") + if [ "${CT_LIBC_GLIBC}" = "y" ]; then + # Use --with-headers, else final gcc will define disable_glibc while + # building libgcc, and you'll have no profiling + CT_CC_SYSROOT_ARG=("--with-headers=${CT_HEADERS_DIR}") + fi fi CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" diff --git a/trunk/configs/boards/uclibc-mipsel.config b/trunk/configs/boards/uclibc-mipsel.config index 02d254a7d3e..dce618a6a29 100644 --- a/trunk/configs/boards/uclibc-mipsel.config +++ b/trunk/configs/boards/uclibc-mipsel.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# uClibc-ng 1.0.49 C Library Configuration +# uClibc-ng 1.0.50 C Library Configuration # # TARGET_aarch64 is not set # TARGET_alpha is not set diff --git a/trunk/libs/libcurl/Makefile b/trunk/libs/libcurl/Makefile index 3cc375f6ed0..ec23e7fbf98 100644 --- a/trunk/libs/libcurl/Makefile +++ b/trunk/libs/libcurl/Makefile @@ -1,11 +1,11 @@ include $(ROOTDIR)/rules.mk PKG_NAME:=curl -PKG_VERSION:=8.9.1 +PKG_VERSION:=8.10.1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://github.com/curl/curl/releases/download/curl-$(subst .,_,$(PKG_VERSION))/ -PKG_HASH:=f292f6cc051d5bbabf725ef85d432dfeacc8711dd717ea97612ae590643801e5 +PKG_HASH:=73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee include $(INCLUDE_DIR)/package.mk @@ -27,6 +27,7 @@ CONFIGURE_ARGS += \ --disable-dict \ --disable-ares \ --disable-debug \ + --disable-docs \ --disable-curldebug \ --disable-manual \ --disable-verbose \ @@ -39,6 +40,7 @@ CONFIGURE_ARGS += \ --without-krb4 \ --without-nss \ --without-ca-path \ + --without-libpsl \ --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt \ --with-random=/dev/urandom \ --with-zlib=$(STAGING_DIR) \ diff --git a/trunk/libs/libcurl/patches/200-no_docs_tests.patch b/trunk/libs/libcurl/patches/200-no_docs_tests.patch index 58a2a832e56..262eba65a32 100644 --- a/trunk/libs/libcurl/patches/200-no_docs_tests.patch +++ b/trunk/libs/libcurl/patches/200-no_docs_tests.patch @@ -1,15 +1,15 @@ --- a/Makefile.am +++ b/Makefile.am -@@ -87,7 +87,7 @@ CLEANFILES = $(VC14_LIBVCXPROJ) $(VC14_S +@@ -94,7 +94,7 @@ CLEANFILES = $(VC14_LIBVCXPROJ) $(VC14_S bin_SCRIPTS = curl-config SUBDIRS = lib docs src scripts --DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs +-DIST_SUBDIRS = $(SUBDIRS) tests packages include docs +DIST_SUBDIRS = $(SUBDIRS) packages include pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libcurl.pc -@@ -196,12 +196,9 @@ cygwinbin: +@@ -203,12 +203,9 @@ cygwinbin: if BUILD_DOCS install-data-hook: (cd include && $(MAKE) install) diff --git a/trunk/libs/libssl/Makefile b/trunk/libs/libssl/Makefile index 756bd5a2967..379e9702ad1 100644 --- a/trunk/libs/libssl/Makefile +++ b/trunk/libs/libssl/Makefile @@ -1,11 +1,11 @@ include $(ROOTDIR)/rules.mk PKG_NAME:=openssl -PKG_VERSION:=1.1.1w +PKG_VERSION:=3.0.15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://www.openssl.org/source/ -PKG_HASH:=cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 +PKG_HASH:=23c666d0edf20f14249b3d8f0368acaee9ab585b09e1de82107c66e1f3ec9533 include $(INCLUDE_DIR)/package.mk diff --git a/trunk/libs/libssl/patches/0001-do-not-build-tests.patch b/trunk/libs/libssl/patches/0001-do-not-build-tests.patch deleted file mode 100644 index 41e18bc3b81..00000000000 --- a/trunk/libs/libssl/patches/0001-do-not-build-tests.patch +++ /dev/null @@ -1,136 +0,0 @@ -From ba2fe646f2d9104a18b066e43582154049e9ffcb Mon Sep 17 00:00:00 2001 -From: Eneas U de Queiroz -Date: Thu, 27 Sep 2018 08:34:38 -0300 -Subject: Do not build tests and fuzz directories - -This shortens build time. - -Signed-off-by: Eneas U de Queiroz - -diff --git a/Configure b/Configure -index 74d057c219..5813e9f8fe 100755 ---- a/Configure -+++ b/Configure -@@ -318,7 +318,7 @@ my $auto_threads=1; # enable threads automatically? true by default - my $default_ranlib; - - # Top level directories to build --$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ]; -+$config{dirs} = [ "crypto", "ssl", "engines", "apps", "util", "tools" ]; - # crypto/ subdirectories to build - $config{sdirs} = [ - "objects", -@@ -330,7 +330,7 @@ $config{sdirs} = [ - "cms", "ts", "srp", "cmac", "ct", "async", "kdf", "store" - ]; - # test/ subdirectories to build --$config{tdirs} = [ "ossl_shim" ]; -+$config{tdirs} = []; - - # Known TLS and DTLS protocols - my @tls = qw(ssl3 tls1 tls1_1 tls1_2 tls1_3); -From 4ad8f2fe6bf3b91df7904fcbe960e5fdfca36336 Mon Sep 17 00:00:00 2001 -From: Eneas U de Queiroz -Date: Thu, 27 Sep 2018 08:31:38 -0300 -Subject: Avoid exposing build directories - -The CFLAGS contain the build directories, and are shown by calling -OpenSSL_version(OPENSSL_CFLAGS), or running openssl version -a - -Signed-off-by: Eneas U de Queiroz - -diff --git a/crypto/build.info b/crypto/build.info -index 2c619c62e8..893128345a 100644 ---- a/crypto/build.info -+++ b/crypto/build.info -@@ -10,7 +10,7 @@ EXTRA= ../ms/uplink-x86.pl ../ms/uplink.c ../ms/applink.c \ - ppccpuid.pl pariscid.pl alphacpuid.pl arm64cpuid.pl armv4cpuid.pl - - DEPEND[cversion.o]=buildinf.h --GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)" -+GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(filter-out -I% -iremap% -fmacro-prefix-map% -ffile-prefix-map%,$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q))" "$(PLATFORM)" - DEPEND[buildinf.h]=../configdata.pm - - GENERATE[uplink-x86.s]=../ms/uplink-x86.pl $(PERLASM_SCHEME) -From 4f7ab2040bb71f03a8f8388911144559aa2a5b60 Mon Sep 17 00:00:00 2001 -From: Eneas U de Queiroz -Date: Thu, 27 Sep 2018 08:44:39 -0300 -Subject: Add OPENSSL_PREFER_CHACHA_OVER_GCM option - -This enables a compile-time option to prefer ChaCha20-Poly1305 over -AES-GCM in the openssl default ciphersuite, which is useful in systems -without AES specific CPU instructions. -OPENSSL_PREFER_CHACHA_OVER_GCM must be defined to enable it. - -Note that this does not have the same effect as the -SL_OP_PRIORITIZE_CHACHA option, which prioritizes ChaCha20-Poly1305 only -when the client has it on top of its ciphersuite preference. - -Signed-off-by: Eneas U de Queiroz - -diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h -index 6724ccf2d2..96d959427e 100644 ---- a/include/openssl/ssl.h -+++ b/include/openssl/ssl.h -@@ -173,9 +173,15 @@ extern "C" { - # define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" - /* This is the default set of TLSv1.3 ciphersuites */ - # if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) --# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ -- "TLS_CHACHA20_POLY1305_SHA256:" \ -- "TLS_AES_128_GCM_SHA256" -+# ifdef OPENSSL_PREFER_CHACHA_OVER_GCM -+# define TLS_DEFAULT_CIPHERSUITES "TLS_CHACHA20_POLY1305_SHA256:" \ -+ "TLS_AES_256_GCM_SHA384:" \ -+ "TLS_AES_128_GCM_SHA256" -+# else -+# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ -+ "TLS_CHACHA20_POLY1305_SHA256:" \ -+ "TLS_AES_128_GCM_SHA256" -+# endif - # else - # define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ - "TLS_AES_128_GCM_SHA256" -diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c -index 27a1b2ec68..7039811323 100644 ---- a/ssl/ssl_ciph.c -+++ b/ssl/ssl_ciph.c -@@ -1467,11 +1467,29 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, - ssl_cipher_apply_rule(0, SSL_kECDHE, 0, 0, 0, 0, 0, CIPHER_DEL, -1, &head, - &tail); - -+ /* -+ * If OPENSSL_PREFER_CHACHA_OVER_GCM is defined, ChaCha20_Poly1305 -+ * will be placed before AES-256. Otherwise, the default behavior of -+ * preferring GCM over CHACHA is used. -+ * This is useful for systems that do not have AES-specific CPU -+ * instructions, where ChaCha20-Poly1305 is 3 times faster than AES. -+ * Note that this does not have the same effect as the SSL_OP_PRIORITIZE_CHACHA -+ * option, which prioritizes ChaCha20-Poly1305 only when the client has it on top -+ * of its ciphersuite preference. -+ */ -+ -+#ifdef OPENSSL_PREFER_CHACHA_OVER_GCM -+ ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20, 0, 0, 0, CIPHER_ADD, -1, -+ &head, &tail); -+ ssl_cipher_apply_rule(0, 0, 0, SSL_AESGCM, 0, 0, 0, CIPHER_ADD, -1, -+ &head, &tail); -+#else - /* Within each strength group, we prefer GCM over CHACHA... */ - ssl_cipher_apply_rule(0, 0, 0, SSL_AESGCM, 0, 0, 0, CIPHER_ADD, -1, - &head, &tail); - ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20, 0, 0, 0, CIPHER_ADD, -1, - &head, &tail); -+#endif - - /* - * ...and generally, our preferred cipher is AES. -@@ -1527,7 +1545,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, - * Within each group, ciphers remain sorted by strength and previous - * preference, i.e., - * 1) ECDHE > DHE -- * 2) GCM > CHACHA -+ * 2) GCM > CHACHA, reversed if OPENSSL_PREFER_CHACHA_OVER_GCM is defined - * 3) AES > rest - * 4) TLS 1.2 > legacy - * \ No newline at end of file diff --git a/trunk/libs/libssl/patches/130-dont-build-fuzz-docs.patch b/trunk/libs/libssl/patches/130-dont-build-fuzz-docs.patch new file mode 100644 index 00000000000..de1ed19bd70 --- /dev/null +++ b/trunk/libs/libssl/patches/130-dont-build-fuzz-docs.patch @@ -0,0 +1,20 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eneas U de Queiroz +Date: Thu, 27 Sep 2018 08:34:38 -0300 +Subject: Do not build tests and fuzz directories + +This shortens build time. + +Signed-off-by: Eneas U de Queiroz + +--- a/build.info ++++ b/build.info +@@ -1,7 +1,7 @@ + # Note that some of these directories are filtered in Configure. Look for + # %skipdir there for further explanations. + +-SUBDIRS=crypto ssl apps util tools fuzz providers doc ++SUBDIRS=crypto ssl apps util tools providers + IF[{- !$disabled{tests} -}] + SUBDIRS=test + ENDIF \ No newline at end of file diff --git a/trunk/libs/libssl/patches/140-allow-prefer-chacha20.patch b/trunk/libs/libssl/patches/140-allow-prefer-chacha20.patch new file mode 100644 index 00000000000..402669bba70 --- /dev/null +++ b/trunk/libs/libssl/patches/140-allow-prefer-chacha20.patch @@ -0,0 +1,92 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eneas U de Queiroz +Date: Thu, 27 Sep 2018 08:44:39 -0300 +Subject: Add OPENSSL_PREFER_CHACHA_OVER_GCM option + +This enables a compile-time option to prefer ChaCha20-Poly1305 over +AES-GCM in the openssl default ciphersuite, which is useful in systems +without AES specific CPU instructions. +OPENSSL_PREFER_CHACHA_OVER_GCM must be defined to enable it. + +Note that this does not have the same effect as the +SL_OP_PRIORITIZE_CHACHA option, which prioritizes ChaCha20-Poly1305 only +when the client has it on top of its ciphersuite preference. + +Signed-off-by: Eneas U de Queiroz + +--- a/ssl/ssl_ciph.c ++++ b/ssl/ssl_ciph.c +@@ -1506,11 +1506,29 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_ + ssl_cipher_apply_rule(0, SSL_kECDHE, 0, 0, 0, 0, 0, CIPHER_DEL, -1, &head, + &tail); + ++ /* ++ * If OPENSSL_PREFER_CHACHA_OVER_GCM is defined, ChaCha20_Poly1305 ++ * will be placed before AES-256. Otherwise, the default behavior of ++ * preferring GCM over CHACHA is used. ++ * This is useful for systems that do not have AES-specific CPU ++ * instructions, where ChaCha20-Poly1305 is 3 times faster than AES. ++ * Note that this does not have the same effect as the SSL_OP_PRIORITIZE_CHACHA ++ * option, which prioritizes ChaCha20-Poly1305 only when the client has it on top ++ * of its ciphersuite preference. ++ */ ++ ++#ifdef OPENSSL_PREFER_CHACHA_OVER_GCM ++ ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20, 0, 0, 0, CIPHER_ADD, -1, ++ &head, &tail); ++ ssl_cipher_apply_rule(0, 0, 0, SSL_AESGCM, 0, 0, 0, CIPHER_ADD, -1, ++ &head, &tail); ++#else + /* Within each strength group, we prefer GCM over CHACHA... */ + ssl_cipher_apply_rule(0, 0, 0, SSL_AESGCM, 0, 0, 0, CIPHER_ADD, -1, + &head, &tail); + ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20, 0, 0, 0, CIPHER_ADD, -1, + &head, &tail); ++#endif + + /* + * ...and generally, our preferred cipher is AES. +@@ -1565,7 +1583,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_ + * Within each group, ciphers remain sorted by strength and previous + * preference, i.e., + * 1) ECDHE > DHE +- * 2) GCM > CHACHA ++ * 2) GCM > CHACHA, reversed if OPENSSL_PREFER_CHACHA_OVER_GCM is defined + * 3) AES > rest + * 4) TLS 1.2 > legacy + * +@@ -2236,7 +2254,13 @@ const char *OSSL_default_cipher_list(voi + */ + const char *OSSL_default_ciphersuites(void) + { ++#ifdef OPENSSL_PREFER_CHACHA_OVER_GCM ++ return "TLS_CHACHA20_POLY1305_SHA256:" ++ "TLS_AES_256_GCM_SHA384:" ++ "TLS_AES_128_GCM_SHA256"; ++#else + return "TLS_AES_256_GCM_SHA384:" + "TLS_CHACHA20_POLY1305_SHA256:" + "TLS_AES_128_GCM_SHA256"; ++#endif + } +--- a/include/openssl/ssl.h.in ++++ b/include/openssl/ssl.h.in +@@ -195,9 +195,15 @@ extern "C" { + * DEPRECATED IN 3.0.0, in favor of OSSL_default_ciphersuites() + * Update both macro and function simultaneously + */ +-# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ +- "TLS_CHACHA20_POLY1305_SHA256:" \ +- "TLS_AES_128_GCM_SHA256" ++# ifdef OPENSSL_PREFER_CHACHA_OVER_GCM ++# define TLS_DEFAULT_CIPHERSUITES "TLS_CHACHA20_POLY1305_SHA256:" \ ++ "TLS_AES_256_GCM_SHA384:" \ ++ "TLS_AES_128_GCM_SHA256" ++# else ++# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ ++ "TLS_CHACHA20_POLY1305_SHA256:" \ ++ "TLS_AES_128_GCM_SHA256" ++# endif + # endif + /* + * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always \ No newline at end of file diff --git a/trunk/libs/libxml2/Makefile b/trunk/libs/libxml2/Makefile index 0650c1e7a32..2dba05190e1 100644 --- a/trunk/libs/libxml2/Makefile +++ b/trunk/libs/libxml2/Makefile @@ -1,11 +1,11 @@ include $(ROOTDIR)/rules.mk PKG_NAME:=libxml2 -PKG_VERSION:=2.13.3 +PKG_VERSION:=2.13.4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNOME/libxml2/$(basename $(PKG_VERSION)) -PKG_HASH:=0805d7c180cf09caad71666c7a458a74f041561a532902454da5047d83948138 +PKG_HASH:=832f8c4c652f813c9d0a01adcaf86145b77c64e56c71ed85db8071aa78beb98f include $(INCLUDE_DIR)/package.mk diff --git a/trunk/tools/mksquashfs_xz/squashfs/Makefile b/trunk/tools/mksquashfs_xz/squashfs/Makefile index 112e7c5bf0e..8c482424c20 100755 --- a/trunk/tools/mksquashfs_xz/squashfs/Makefile +++ b/trunk/tools/mksquashfs_xz/squashfs/Makefile @@ -25,7 +25,7 @@ ifndef CONFIG # # LZMA2 compression. # -# XZ Utils liblzma (http://tukaani.org/xz/) is supported +# XZ Utils liblzma (https://tukaani.org/xz/) is supported # # Development packages (libraries and header files) should be # supported by most modern distributions. Please refer to @@ -178,7 +178,7 @@ INSTALL_MANPAGES_DIR = $(INSTALL_PREFIX)/man/man1 # LZMA1 compression is obsolete, and the newer and better XZ (LZMA2) # compression should be used in preference. # -# Both XZ Utils liblzma (http://tukaani.org/xz/) and LZMA SDK +# Both XZ Utils liblzma (https://tukaani.org/xz/) and LZMA SDK # (http://www.7-zip.org/sdk.html) are supported # # To build using XZ Utils liblzma - install the library and uncomment diff --git a/trunk/tools/mksquashfs_xz/squashfs/caches-queues-lists.c b/trunk/tools/mksquashfs_xz/squashfs/caches-queues-lists.c index f6bcba44a71..c3b590f27ce 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/caches-queues-lists.c +++ b/trunk/tools/mksquashfs_xz/squashfs/caches-queues-lists.c @@ -317,7 +317,7 @@ struct cache *cache_init(int buffer_size, int max_buffers, int noshrink_lookup, */ cache->first_freelist = first_freelist; - memset(cache->hash_table, 0, sizeof(struct file_buffer *) * 65536); + memset(cache->hash_table, 0, sizeof(struct file_buffer *) * HASH_SIZE); pthread_mutex_init(&cache->mutex, NULL); pthread_cond_init(&cache->wait_for_free, NULL); pthread_cond_init(&cache->wait_for_unlock, NULL); diff --git a/trunk/tools/mksquashfs_xz/squashfs/lzma_xz_wrapper.c b/trunk/tools/mksquashfs_xz/squashfs/lzma_xz_wrapper.c index 0df3429ac6c..61096e04fd7 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/lzma_xz_wrapper.c +++ b/trunk/tools/mksquashfs_xz/squashfs/lzma_xz_wrapper.c @@ -18,7 +18,7 @@ * * lzma_xz_wrapper.c * - * Support for LZMA1 compression using XZ Utils liblzma http://tukaani.org/xz/ + * Support for LZMA1 compression using XZ Utils liblzma https://tukaani.org/xz/ */ #include diff --git a/trunk/tools/mksquashfs_xz/squashfs/mksquashfs.c b/trunk/tools/mksquashfs_xz/squashfs/mksquashfs.c index e0ef491d74b..03631af112c 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/mksquashfs.c +++ b/trunk/tools/mksquashfs_xz/squashfs/mksquashfs.c @@ -198,7 +198,8 @@ long long hardlnk_count = 0; struct squashfs_super_block sBlk; /* write position within data section */ -long long bytes = 0, total_bytes = 0; +long long pos = 0, total_bytes = 0; +long long marked_pos = 0; /* in memory directory table - possibly compressed */ char *directory_table = NULL; @@ -368,7 +369,7 @@ static struct file_info *duplicate(int *dup, int *block_dup, long long file_size, long long bytes, unsigned int *block_list, long long start, struct dir_ent *dir_ent, struct file_buffer *file_buffer, int blocks, long long sparse, - int bl_hash, int thresh); + int bl_hash); static struct dir_info *dir_scan1(char *, char *, struct pathnames *, struct dir_ent *(_readdir)(struct dir_info *), unsigned int); static void dir_scan2(struct dir_info *dir, struct pseudo *pseudo); @@ -449,13 +450,98 @@ int multiply_overflowll(long long a, int multiplier) + (((char *)A) - data_cache))) +inline void set_pos(long long value) +{ + pos = value; +} + + +inline long long get_pos(void) +{ + return pos; +} + + +long long get_and_inc_pos(long long value) +{ + long long tmp = pos; + + pos += value; + return tmp; +} + + +inline int reset_pos(void) +{ + if(marked_pos == 0) + BAD_ERROR("BUG: Saved write position is empty!\n"); + else if(marked_pos == 1) + return FALSE; + else { + set_pos(marked_pos); + return TRUE; + } +} + + +inline void unmark_pos() +{ + if(marked_pos == 0) + BAD_ERROR("BUG: Saved write position should not be empty!\n"); + + marked_pos = 0; +} + + +inline void mark_pos() +{ + if(marked_pos != 0) + BAD_ERROR("BUG: Saved write position should be empty!\n"); + + marked_pos = 1; +} + + +inline long long get_marked_pos(void) +{ + if(marked_pos == 0) + BAD_ERROR("BUG: Saved write position is empty!\n"); + else if(marked_pos == 1) + return get_pos(); + else + return marked_pos; +} + + +inline long long set_write_buffer(struct file_buffer *buffer, int size) +{ + buffer->block = get_and_inc_pos(size); + return buffer->block; +} + + +inline void put_write_buffer_hash(struct file_buffer *buffer, int put) +{ + if(marked_pos == 0) + BAD_ERROR("BUG: Saved write position should not be empty!\n"); + else if(marked_pos == 1) + marked_pos = get_pos(); + + buffer->block = get_and_inc_pos(buffer->size); + cache_hash(buffer, buffer->block); + + if(put) + queue_put(to_writer, buffer); +} + + void restorefs() { int i, res; ERROR("Exiting - restoring original filesystem!\n\n"); - bytes = sbytes; + set_pos(sbytes); memcpy(data_cache, sdata_cache, cache_bytes = scache_bytes); memcpy(directory_data_cache, sdirectory_data_cache, sdirectory_cache_bytes); @@ -482,15 +568,15 @@ void restorefs() write_filesystem_tables(&sBlk); if(!block_device) { - int res = ftruncate(fd, bytes); + int res = ftruncate(fd, get_pos()); if(res != 0) BAD_ERROR("Failed to truncate dest file because %s\n", strerror(errno)); } - if(!nopad && (i = bytes & (4096 - 1))) { + if(!nopad && (i = get_pos() & (4096 - 1))) { char temp[4096] = {0}; - write_destination(fd, bytes, 4096 - i, temp); + write_destination(fd, get_pos(), 4096 - i, temp); } res = close(fd); @@ -688,7 +774,7 @@ static long long write_inodes() unsigned short c_byte; int avail_bytes; char *datap = data_cache; - long long start_bytes = bytes; + long long start_bytes; while(cache_bytes) { if(inode_size - inode_bytes < @@ -712,8 +798,8 @@ static long long write_inodes() cache_bytes -= avail_bytes; } - write_destination(fd, bytes, inode_bytes, inode_table); - bytes += inode_bytes; + start_bytes = get_and_inc_pos(inode_bytes); + write_destination(fd, start_bytes, inode_bytes, inode_table); return start_bytes; } @@ -724,7 +810,7 @@ static long long write_directories() unsigned short c_byte; int avail_bytes; char *directoryp = directory_data_cache; - long long start_bytes = bytes; + long long start_bytes; while(directory_cache_bytes) { if(directory_size - directory_bytes < @@ -752,8 +838,9 @@ static long long write_directories() directoryp += avail_bytes; directory_cache_bytes -= avail_bytes; } - write_destination(fd, bytes, directory_bytes, directory_table); - bytes += directory_bytes; + + start_bytes = get_and_inc_pos(directory_bytes); + write_destination(fd, start_bytes, directory_bytes, directory_table); return start_bytes; } @@ -1623,9 +1710,7 @@ static void unlock_fragments() write_buffer = queue_get(locked_fragment); frg = write_buffer->block; size = SQUASHFS_COMPRESSED_SIZE_BLOCK(fragment_table[frg].size); - fragment_table[frg].start_block = bytes; - write_buffer->block = bytes; - bytes += size; + fragment_table[frg].start_block = set_write_buffer(write_buffer, size); fragments_outstanding --; queue_put(to_writer, write_buffer); log_fragment(frg, fragment_table[frg].start_block); @@ -1737,13 +1822,13 @@ long long generic_write_table(long long length, void *buffer, int length2, { int meta_blocks = (length + SQUASHFS_METADATA_SIZE - 1) / SQUASHFS_METADATA_SIZE; - long long *list, start_bytes; + long long *list, start_bytes, bytes; int compressed_size, i, list_size = meta_blocks * sizeof(long long); unsigned short c_byte; char cbuffer[(SQUASHFS_METADATA_SIZE << 2) + 2]; #ifdef SQUASHFS_TRACE - long long obytes = bytes; + long long obytes = get_pos(); long long olength = length; #endif @@ -1758,31 +1843,30 @@ long long generic_write_table(long long length, void *buffer, int length2, SQUASHFS_METADATA_SIZE , avail_bytes, SQUASHFS_METADATA_SIZE, uncompressed, 0); SQUASHFS_SWAP_SHORTS(&c_byte, cbuffer, 1); - list[i] = bytes; compressed_size = SQUASHFS_COMPRESSED_SIZE(c_byte) + BLOCK_OFFSET; - TRACE("block %d @ 0x%llx, compressed size %d\n", i, bytes, - compressed_size); + bytes = get_and_inc_pos(compressed_size); write_destination(fd, bytes, compressed_size, cbuffer); - bytes += compressed_size; + list[i] = bytes; total_bytes += avail_bytes; length -= avail_bytes; + TRACE("block %d @ 0x%llx, compressed size %d\n", i, bytes, + compressed_size); } - start_bytes = bytes; + start_bytes = get_and_inc_pos(length2); if(length2) { - write_destination(fd, bytes, length2, buffer2); - bytes += length2; + write_destination(fd, start_bytes, length2, buffer2); total_bytes += length2; } SQUASHFS_INSWAP_LONG_LONGS(list, meta_blocks); + bytes = get_and_inc_pos(list_size); write_destination(fd, bytes, list_size, list); - bytes += list_size; total_bytes += list_size; TRACE("generic_write_table: total uncompressed %lld compressed %lld\n", - olength, bytes - obytes); + olength, get_pos() - obytes); free(list); @@ -2170,16 +2254,17 @@ static struct file_info *frag_duplicate(struct file_buffer *file_buffer, int *du } -static void reset_and_truncate(long long start, int thresh) +static void reset_and_truncate(void) { - bytes = start; - if(thresh && !block_device) { + int res = reset_pos(); + + if(res && !block_device) { int res; queue_put(to_writer, NULL); if(queue_get(from_writer) != 0) EXIT_MKSQUASHFS(); - res = ftruncate(fd, bytes); + res = ftruncate(fd, get_pos()); if(res != 0) BAD_ERROR("Failed to truncate dest file because" " %s\n", strerror(errno)); @@ -2191,7 +2276,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, long long file_size, long long bytes, unsigned int *block_list, long long start, struct dir_ent *dir_ent, struct file_buffer *file_buffer, int blocks, long long sparse, - int bl_hash, int thresh) + int bl_hash) { struct file_info *dupl_ptr, *file; struct file_info *block_dupl = NULL, *frag_dupl = NULL; @@ -2320,7 +2405,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, */ if(!frag_bytes && !dupl_ptr->fragment->size) { *dupf = *block_dup = TRUE; - reset_and_truncate(start, thresh); + reset_and_truncate(); if(file_size == dupl_ptr->file_size) return dupl_ptr; else @@ -2358,7 +2443,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, * finished. Return the duplicate */ *dupf = *block_dup = TRUE; - reset_and_truncate(start, thresh); + reset_and_truncate(); return dupl_ptr; } } @@ -2400,7 +2485,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, */ if(block_dupl && block_dupl->start == dupl_ptr->start) { *dupf = *block_dup = TRUE; - reset_and_truncate(start, thresh); + reset_and_truncate(); return dupl_ptr; } @@ -2466,7 +2551,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, if(dup) { /* Found a matching file. Return the duplicate */ *dupf = *block_dup = TRUE; - reset_and_truncate(start, thresh); + reset_and_truncate(); return dup->file; } } @@ -2479,7 +2564,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, * if the current fragment is too full, this will force a * write out of the fragment. */ - reset_and_truncate(start, thresh); + reset_and_truncate(); } if(frag_dupl) @@ -2530,7 +2615,7 @@ static struct file_info *duplicate(int *dupf, int *block_dup, dup->file = file; dup->next = block_dupl->dup; block_dupl->dup = dup; - reset_and_truncate(start, thresh); + reset_and_truncate(); } return file; @@ -2669,9 +2754,7 @@ static void *frag_deflator(void *arg) pthread_mutex_lock(&fragment_mutex); if(fragments_locked == FALSE) { fragment_table[file_buffer->block].size = c_byte; - fragment_table[file_buffer->block].start_block = bytes; - write_buffer->block = bytes; - bytes += compressed_size; + fragment_table[file_buffer->block].start_block = set_write_buffer(write_buffer, compressed_size); fragments_outstanding --; queue_put(to_writer, write_buffer); log_fragment(file_buffer->block, fragment_table[file_buffer->block].start_block); @@ -2736,9 +2819,7 @@ static void *frag_orderer(void *arg) int block = write_buffer->block; pthread_mutex_lock(&fragment_mutex); - fragment_table[block].start_block = bytes; - write_buffer->block = bytes; - bytes += SQUASHFS_COMPRESSED_SIZE_BLOCK(write_buffer->size); + fragment_table[block].start_block = set_write_buffer(write_buffer, SQUASHFS_COMPRESSED_SIZE_BLOCK(write_buffer->size)); fragments_outstanding --; log_fragment(block, write_buffer->block); queue_put(to_writer, write_buffer); @@ -2811,10 +2892,10 @@ static void log_file(struct dir_ent *dir_ent, long long start) static struct file_info *write_file_process(int *status, struct dir_ent *dir_ent, struct file_buffer *read_buffer, int *duplicate_file) { - long long read_size, file_bytes, start; + long long read_size, file_bytes; struct fragment *fragment; unsigned int *block_list = NULL; - int block = 0; + int block = 0, res; long long sparse = 0; struct file_buffer *fragment_buffer = NULL; struct file_info *file; @@ -2827,13 +2908,11 @@ static struct file_info *write_file_process(int *status, struct dir_ent *dir_ent lock_fragments(); file_bytes = 0; - start = bytes; + mark_pos(); while (1) { read_size = read_buffer->file_size; if(read_buffer->fragment) { fragment_buffer = read_buffer; - if(block == 0) - start=0; } else { block_list = realloc(block_list, (block + 1) * sizeof(unsigned int)); @@ -2841,11 +2920,8 @@ static struct file_info *write_file_process(int *status, struct dir_ent *dir_ent MEM_ERROR(); block_list[block ++] = read_buffer->c_byte; if(read_buffer->c_byte) { - read_buffer->block = bytes; - bytes += read_buffer->size; - cache_hash(read_buffer, read_buffer->block); file_bytes += read_buffer->size; - queue_put(to_writer, read_buffer); + put_write_buffer_hash(read_buffer, TRUE); } else { sparse += read_buffer->size; cache_block_put(read_buffer); @@ -2870,34 +2946,36 @@ static struct file_info *write_file_process(int *status, struct dir_ent *dir_ent int bl_hash = block ? block_hash(block_list[0], block) : 0; file = add_non_dup(read_size, file_bytes, block, sparse, - block_list, start, fragment, 0, fragment_buffer ? - fragment_buffer->checksum : 0, FALSE, TRUE, FALSE, - FALSE, bl_hash); + block_list, get_marked_pos(), fragment, 0, + fragment_buffer ? fragment_buffer->checksum : 0, FALSE, + TRUE, FALSE, FALSE, bl_hash); } else file = create_non_dup(read_size, file_bytes, block, sparse, - block_list, start, fragment, 0, fragment_buffer ? - fragment_buffer->checksum : 0, FALSE, TRUE); + block_list, get_marked_pos(), fragment, 0, + fragment_buffer ? fragment_buffer->checksum : 0, FALSE, + TRUE); cache_block_put(fragment_buffer); file_count ++; total_bytes += read_size; - log_file(dir_ent, start); + log_file(dir_ent, file->start); *status = 0; + unmark_pos(); return file; read_err: dec_progress_bar(block); *status = read_buffer->error; - bytes = start; - if(!block_device) { + res = reset_pos(); + if(res && !block_device) { int res; queue_put(to_writer, NULL); if(queue_get(from_writer) != 0) EXIT_MKSQUASHFS(); - res = ftruncate(fd, bytes); + res = ftruncate(fd, get_pos()); if(res != 0) BAD_ERROR("Failed to truncate dest file because %s\n", strerror(errno)); @@ -2906,6 +2984,7 @@ static struct file_info *write_file_process(int *status, struct dir_ent *dir_ent unlock_fragments(); free(block_list); cache_block_put(read_buffer); + unmark_pos(); return NULL; } @@ -2913,9 +2992,9 @@ static struct file_info *write_file_process(int *status, struct dir_ent *dir_ent static struct file_info *write_file_blocks_dup(int *status, struct dir_ent *dir_ent, struct file_buffer *read_buffer, int *duplicate_file, int bl_hash) { - int block, thresh; + int block, thresh, res; long long read_size = read_buffer->file_size; - long long file_bytes, start; + long long file_bytes; int blocks = (read_size + block_size - 1) >> block_log; unsigned int *block_list; struct file_buffer **buffer_list; @@ -2938,7 +3017,7 @@ static struct file_info *write_file_blocks_dup(int *status, struct dir_ent *dir_ lock_fragments(); file_bytes = 0; - start = bytes; + mark_pos(); thresh = blocks > bwriter_size ? blocks - bwriter_size : 0; for(block = 0; block < blocks;) { @@ -2951,15 +3030,9 @@ static struct file_info *write_file_blocks_dup(int *status, struct dir_ent *dir_ block_list[block] = read_buffer->c_byte; if(read_buffer->c_byte) { - read_buffer->block = bytes; - bytes += read_buffer->size; file_bytes += read_buffer->size; - cache_hash(read_buffer, read_buffer->block); - if(block < thresh) { - buffer_list[block] = NULL; - queue_put(to_writer, read_buffer); - } else - buffer_list[block] = read_buffer; + buffer_list[block] = block >= thresh ? read_buffer : NULL; + put_write_buffer_hash(read_buffer, block < thresh); } else { buffer_list[block] = NULL; sparse += read_buffer->size; @@ -2987,7 +3060,7 @@ static struct file_info *write_file_blocks_dup(int *status, struct dir_ent *dir_ sparse = 0; file = duplicate(duplicate_file, &block_dup, read_size, file_bytes, block_list, - start, dir_ent, fragment_buffer, blocks, sparse, bl_hash, thresh); + get_marked_pos(), dir_ent, fragment_buffer, blocks, sparse, bl_hash); if(block_dup == FALSE) { for(block = thresh; block < blocks; block ++) @@ -3011,19 +3084,20 @@ static struct file_info *write_file_blocks_dup(int *status, struct dir_ent *dir_ log_file(dir_ent, file->start); *status = 0; + unmark_pos(); return file; read_err: dec_progress_bar(block); *status = read_buffer->error; - bytes = start; - if(thresh && !block_device) { + res = reset_pos(); + if(res && thresh && !block_device) { int res; queue_put(to_writer, NULL); if(queue_get(from_writer) != 0) EXIT_MKSQUASHFS(); - res = ftruncate(fd, bytes); + res = ftruncate(fd, get_pos()); if(res != 0) BAD_ERROR("Failed to truncate dest file because %s\n", strerror(errno)); @@ -3035,6 +3109,7 @@ static struct file_info *write_file_blocks_dup(int *status, struct dir_ent *dir_ free(buffer_list); free(block_list); cache_block_put(read_buffer); + unmark_pos(); return NULL; } @@ -3043,10 +3118,10 @@ static struct file_info *write_file_blocks(int *status, struct dir_ent *dir_ent, struct file_buffer *read_buffer, int *dup) { long long read_size = read_buffer->file_size; - long long file_bytes, start; + long long file_bytes; struct fragment *fragment; unsigned int *block_list; - int block; + int block, res; int blocks = (read_size + block_size - 1) >> block_log; long long sparse = 0; struct file_buffer *fragment_buffer = NULL; @@ -3068,7 +3143,7 @@ static struct file_info *write_file_blocks(int *status, struct dir_ent *dir_ent, lock_fragments(); file_bytes = 0; - start = bytes; + mark_pos(); for(block = 0; block < blocks;) { if(read_buffer->fragment) { block_list[block] = 0; @@ -3077,11 +3152,8 @@ static struct file_info *write_file_blocks(int *status, struct dir_ent *dir_ent, } else { block_list[block] = read_buffer->c_byte; if(read_buffer->c_byte) { - read_buffer->block = bytes; - bytes += read_buffer->size; - cache_hash(read_buffer, read_buffer->block); file_bytes += read_buffer->size; - queue_put(to_writer, read_buffer); + put_write_buffer_hash(read_buffer, TRUE); } else { sparse += read_buffer->size; cache_block_put(read_buffer); @@ -3114,34 +3186,35 @@ static struct file_info *write_file_blocks(int *status, struct dir_ent *dir_ent, if(duplicate_checking) file = add_non_dup(read_size, file_bytes, blocks, sparse, - block_list, start, fragment, 0, fragment_buffer ? + block_list, get_marked_pos(), fragment, 0, fragment_buffer ? fragment_buffer->checksum : 0, FALSE, TRUE, FALSE, FALSE, bl_hash); else file = create_non_dup(read_size, file_bytes, blocks, sparse, - block_list, start, fragment, 0, fragment_buffer ? + block_list, get_marked_pos(), fragment, 0, fragment_buffer ? fragment_buffer->checksum : 0, FALSE, TRUE); cache_block_put(fragment_buffer); file_count ++; total_bytes += read_size; - log_file(dir_ent, start); + log_file(dir_ent, file->start); *status = 0; + unmark_pos(); return file; read_err: dec_progress_bar(block); *status = read_buffer->error; - bytes = start; - if(!block_device) { + res = reset_pos(); + if(res && !block_device) { int res; queue_put(to_writer, NULL); if(queue_get(from_writer) != 0) EXIT_MKSQUASHFS(); - res = ftruncate(fd, bytes); + res = ftruncate(fd, get_pos()); if(res != 0) BAD_ERROR("Failed to truncate dest file because %s\n", strerror(errno)); @@ -3150,6 +3223,7 @@ static struct file_info *write_file_blocks(int *status, struct dir_ent *dir_ent, unlock_fragments(); free(block_list); cache_block_put(read_buffer); + unmark_pos(); return NULL; } @@ -4135,9 +4209,27 @@ static void dir_scan2(struct dir_info *dir, struct pseudo *pseudo) pseudo_ent->dev->symlink, strlen(pseudo_ent->dev->symlink) + 1), dir); } else if(pseudo_ent->dev->type == 'l') { - add_dir_entry2(pseudo_ent->name, NULL, - pseudo_ent->dev->linkname, NULL, - lookup_inode(pseudo_ent->dev->linkbuf), dir); + if(S_ISLNK(pseudo_ent->dev->linkbuf->st_mode)) { + int byte; + static char buff[65536]; /* overflow safe */ + + byte = readlink(pseudo_ent->dev->linkname, buff, 65536); + if(byte == -1) { + ERROR_START("Failed to read symlink %s", pseudo_ent->dev->linkname); + ERROR_EXIT(", ignoring\n"); + } else if(byte == 65536) { + ERROR_START("Symlink %s is greater than 65535 bytes!", pseudo_ent->dev->linkname); + ERROR_EXIT(", ignoring\n"); + } else { + /* readlink doesn't 0 terminate the returned path */ + buff[byte] = '\0'; + add_dir_entry2(pseudo_ent->name, NULL, pseudo_ent->dev->linkname, NULL, + lookup_inode3(pseudo_ent->dev->linkbuf, NULL, buff, byte + 1), dir); + } + } else + add_dir_entry2(pseudo_ent->name, NULL, + pseudo_ent->dev->linkname, NULL, + lookup_inode(pseudo_ent->dev->linkbuf), dir); } else { add_dir_entry2(pseudo_ent->name, NULL, pseudo_ent->pathname, NULL, @@ -5290,7 +5382,7 @@ static void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq, sigaddset(&sigmask, SIGQUIT); sigaddset(&sigmask, SIGHUP); if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) != 0) - BAD_ERROR("Failed to set signal mask in intialise_threads\n"); + BAD_ERROR("Failed to set signal mask in initialise_threads\n"); /* * temporarily block these signals, so the created sub-threads @@ -5301,7 +5393,7 @@ static void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq, sigaddset(&sigmask, SIGTERM); sigaddset(&sigmask, SIGUSR1); if(pthread_sigmask(SIG_BLOCK, &sigmask, &old_mask) != 0) - BAD_ERROR("Failed to set signal mask in intialise_threads\n"); + BAD_ERROR("Failed to set signal mask in initialise_threads\n"); if(processors == -1) processors = get_nprocessors(); @@ -5360,7 +5452,7 @@ static void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq, /* Restore the signal mask for the main thread */ if(pthread_sigmask(SIG_SETMASK, &old_mask, NULL) != 0) - BAD_ERROR("Failed to set signal mask in intialise_threads\n"); + BAD_ERROR("Failed to set signal mask in initialise_threads\n"); } @@ -5848,7 +5940,7 @@ static void write_filesystem_tables(struct squashfs_super_block *sBlk) TRACE("sBlk->lookup_table_start 0x%llx\n", sBlk->lookup_table_start); - sBlk->bytes_used = bytes; + sBlk->bytes_used = get_pos(); sBlk->compression = comp->id; @@ -6159,10 +6251,10 @@ static void print_summary() "compressed", noI || noId ? "uncompressed" : "compressed"); printf("\tduplicates are %sremoved\n", duplicate_checking ? "" : "not "); - printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n", bytes / 1024.0, - bytes / (1024.0 * 1024.0)); + printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n", get_pos() / 1024.0, + get_pos() / (1024.0 * 1024.0)); printf("\t%.2f%% of uncompressed filesystem size (%.2f Kbytes)\n", - ((float) bytes / total_bytes) * 100.0, total_bytes / 1024.0); + ((float) get_pos() / total_bytes) * 100.0, total_bytes / 1024.0); printf("Inode table size %lld bytes (%.2f Kbytes)\n", inode_bytes, inode_bytes / 1024.0); printf("\t%.2f%% of uncompressed inode table size (%lld bytes)\n", @@ -6314,30 +6406,30 @@ static int sqfstar(int argc, char *argv[]) print_version("sqfstar"); exit(0); } else if(strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) - sqfstar_help(FALSE, argv[0]); + sqfstar_help(FALSE); else if(strcmp(argv[i], "-help-all") == 0 || strcmp(argv[i], "-ha") == 0) - sqfstar_help_all(argv[0]); + sqfstar_help_all(); else if(strcmp(argv[i], "-help-option") == 0 || strcmp(argv[i], "-ho") == 0) { if(++i == argc) { - ERROR("%s: %s missing regex\n", argv[0], argv[i - 1]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: %s missing regex\n", argv[i - 1]); + sqfstar_option_help(argv[i - 1]); } - sqfstar_option(argv[0], argv[i - 1], argv[i]); + sqfstar_option(argv[i - 1], argv[i]); } else if(strcmp(argv[i], "-help-section") == 0 || strcmp(argv[i], "-hs") == 0) { if(++i == argc) { - ERROR("%s: %s missing section\n", argv[0], argv[i - 1]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: %s missing section\n", argv[i - 1]); + sqfstar_option_help(argv[i - 1]); } - sqfstar_section(argv[0], argv[i - 1], argv[i]); + sqfstar_section(argv[i - 1], argv[i]); } else if(strcmp(argv[i], "-help-comp") == 0) { if(++i == argc) { - ERROR("%s: -help-comp missing compressor name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -help-comp missing compressor name\n"); + sqfstar_option_help(argv[i - 1]); } - print_compressor_options(argv[i], argv[0]); + print_compressor_options(argv[i], "sqfstar"); exit(0); } else if(strcmp(argv[1], "-mem-default") == 0) { printf("%d\n", total_mem); @@ -6368,28 +6460,27 @@ static int sqfstar(int argc, char *argv[]) struct compressor *prev_comp = comp; if(++i == argc) { - ERROR("%s: -comp missing compression type\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -comp missing compression type\n"); + sqfstar_option_help(argv[i - 1]); } comp = lookup_compressor(argv[i]); if(!comp->supported) { - ERROR("%s: Compressor \"%s\" is not supported!\n", - argv[0], argv[i]); - ERROR("%s: Compressors available:\n", argv[0]); + ERROR("sqfstar: Compressor \"%s\" is not supported!\n", argv[i]); + ERROR("sqfstar: Compressors available:\n"); display_compressors(stderr, "", COMP_DEFAULT); exit(1); } if(compressor_opt_parsed) { - ERROR("%s: -comp multiple conflicting -comp" + ERROR("sqfstar: -comp multiple conflicting -comp" " options specified on command line" - ", previously %s, now %s\n", argv[0], + ", previously %s, now %s\n", prev_comp->name, comp->name); exit(1); } compressor_opt_parsed = 1; if(X_opt_parsed) { ERROR("%s: -comp option should be before any " - "-X option\n", argv[0]); + "-X option\n"); exit(1); } } else if(strcmp(argv[i], "-Xhelp") == 0) @@ -6401,7 +6492,7 @@ static int sqfstar(int argc, char *argv[]) } if(Xhelp) { - print_selected_comp_options(stdout, comp, argv[0]); + print_selected_comp_options(stdout, comp, "sqfstar"); exit(0); } @@ -6434,22 +6525,22 @@ static int sqfstar(int argc, char *argv[]) no_hardlinks = TRUE; else if(strcmp(argv[i], "-throttle") == 0) { if((++i == dest_index) || !parse_number(argv[i], &sleep_time, 2)) { - ERROR("%s: -throttle missing or invalid value\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -throttle missing or invalid value\n"); + sqfstar_option_help(argv[i - 1]); } if(sleep_time > 99) { - ERROR("%s: -throttle value should be between 0 and 99\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -throttle value should be between 0 and 99\n"); + sqfstar_option_help(argv[i - 1]); } readq = 4; } else if(strcmp(argv[i], "-limit") == 0) { if((++i == dest_index) || !parse_number(argv[i], &sleep_time, 0)) { - ERROR("%s: -limit missing or invalid value\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -limit missing or invalid value\n"); + sqfstar_option_help(argv[i - 1]); } if(sleep_time < 1 || sleep_time > 100) { - ERROR("%s: -limit value should be between 1 and 100\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -limit value should be between 1 and 100\n"); + sqfstar_option_help(argv[i - 1]); } sleep_time = 100 - sleep_time; readq = 4; @@ -6458,18 +6549,17 @@ static int sqfstar(int argc, char *argv[]) if((++i == dest_index) || (!parse_num_unsigned(argv[i], &mkfs_time) && !exec_date(argv[i], &mkfs_time))) { - ERROR("%s: %s missing or invalid time " - "value\n", argv[0], - argv[i - 1]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: %s missing or invalid time " + "value\n", argv[i - 1]); + sqfstar_option_help(argv[i - 1]); } mkfs_time_opt = TRUE; } else if(strcmp(argv[i], "-all-time") == 0) { if((++i == dest_index) || (!parse_num_unsigned(argv[i], &all_time) && !exec_date(argv[i], &all_time))) { - ERROR("%s: -all-time missing or invalid time value\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -all-time missing or invalid time value\n"); + sqfstar_option_help(argv[i - 1]); } all_time_opt = TRUE; clamping = FALSE; @@ -6479,99 +6569,90 @@ static int sqfstar(int argc, char *argv[]) reproducible = FALSE; else if(strcmp(argv[i], "-root-mode") == 0) { if((++i == dest_index) || !parse_mode(argv[i], &root_mode)) { - ERROR("%s: -root-mode missing or invalid mode," - " octal number <= 07777 expected\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -root-mode missing or invalid mode," + " octal number <= 07777 expected\n"); + sqfstar_option_help(argv[i - 1]); } root_mode_opt = TRUE; } else if(strcmp(argv[i], "-root-uid") == 0) { if(++i == dest_index) { - ERROR("%s: -root-uid missing uid or user name\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -root-uid missing uid or user name\n"); + sqfstar_option_help(argv[i - 1]); } res = get_uid_from_arg(argv[i], &root_uid); if(res) { if(res == -2) - ERROR("%s: -root-uid uid out of range\n", - argv[0]); + ERROR("sqfstar: -root-uid uid out of range\n"); else - ERROR("%s: -root-uid invalid uid or " - "unknown user name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -root-uid invalid uid or " + "unknown user name\n"); + sqfstar_option_help(argv[i - 1]); } root_uid_opt = TRUE; } else if(strcmp(argv[i], "-root-gid") == 0) { if(++i == dest_index) { - ERROR("%s: -root-gid missing gid or group name\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -root-gid missing gid or group name\n"); + sqfstar_option_help(argv[i - 1]); } res = get_gid_from_arg(argv[i], &root_gid); if(res) { if(res == -2) - ERROR("%s: -root-gid gid out of range\n", - argv[0]); + ERROR("sqfstar: -root-gid gid out of range\n"); else - ERROR("%s: -root-gid invalid gid or " - "unknown group name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -root-gid invalid gid or " + "unknown group name\n"); + sqfstar_option_help(argv[i - 1]); } root_gid_opt = TRUE; } else if(strcmp(argv[i], "-root-time") == 0) { if((++i == argc) || (!parse_num_unsigned(argv[i], &root_time) && !exec_date(argv[i], &root_time))) { - ERROR("%s: -root-time missing or invalid time\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -root-time missing or invalid time\n"); + sqfstar_option_help(argv[i - 1]); } root_time_opt = TRUE; } else if(strcmp(argv[i], "-default-mode") == 0) { if((++i == dest_index) || !parse_mode(argv[i], &default_mode)) { - ERROR("%s: -default-mode missing or invalid mode," - " octal number <= 07777 expected\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -default-mode missing or invalid mode," + " octal number <= 07777 expected\n"); + sqfstar_option_help(argv[i - 1]); } root_mode = default_mode; default_mode_opt = root_mode_opt = TRUE; } else if(strcmp(argv[i], "-default-uid") == 0) { if(++i == dest_index) { - ERROR("%s: -default-uid missing uid or user name\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -default-uid missing uid or user name\n"); + sqfstar_option_help(argv[i - 1]); } res = get_uid_from_arg(argv[i], &default_uid); if(res) { if(res == -2) - ERROR("%s: -default-uid uid out of range\n", - argv[0]); + ERROR("sqfstar: -default-uid uid out of range\n"); else - ERROR("%s: -default-uid invalid uid or " - "unknown user name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -default-uid invalid uid or " + "unknown user name\n"); + sqfstar_option_help(argv[i - 1]); } root_uid = default_uid; default_uid_opt = root_uid_opt = TRUE; } else if(strcmp(argv[i], "-default-gid") == 0) { if(++i == dest_index) { - ERROR("%s: -default-gid missing gid or group name\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -default-gid missing gid or group name\n"); + sqfstar_option_help(argv[i - 1]); } res = get_gid_from_arg(argv[i], &default_gid); if(res) { if(res == -2) - ERROR("%s: -default-gid gid out of range" - "\n", argv[0]); + ERROR("sqfstar: -default-gid gid out of range\n"); else - ERROR("%s: -default-gid invalid gid or " - "unknown group name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -default-gid invalid gid or " + "unknown group name\n"); + sqfstar_option_help(argv[i - 1]); } root_gid = default_gid; default_gid_opt = root_gid_opt = TRUE; @@ -6583,16 +6664,14 @@ static int sqfstar(int argc, char *argv[]) if(args < 0) { if(args == -1) { - ERROR("%s: Unrecognised compressor" - " option %s\n", argv[0], - argv[i]); + ERROR("sqfstar: Unrecognised compressor" + " option %s\n", argv[i]); if(!compressor_opt_parsed) - ERROR("%s: Did you forget to" + ERROR("sqfstar: Did you forget to" " specify -comp, or " "specify it after the" - " -X options?\n", - argv[0]); - print_selected_comp_options(stderr, comp, argv[0]); + " -X options?\n"); + print_selected_comp_options(stderr, comp, "sqfstar"); } exit(1); } @@ -6600,24 +6679,23 @@ static int sqfstar(int argc, char *argv[]) } else if(strcmp(argv[i], "-pf") == 0) { if(++i == dest_index) { - ERROR("%s: -pf missing filename\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -pf missing filename\n"); + sqfstar_option_help(argv[i - 1]); } if(read_pseudo_file(argv[i], argv[dest_index]) == FALSE) exit(1); } else if(strcmp(argv[i], "-p") == 0) { if(++i == dest_index) { - ERROR("%s: -p missing pseudo file definition\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -p missing pseudo file definition\n"); + sqfstar_option_help(argv[i - 1]); } if(read_pseudo_definition(argv[i], argv[dest_index]) == FALSE) exit(1); } else if(strcmp(argv[i], "-pd") == 0 || strcmp(argv[i], "-pseudo-dir") == 0) { if(++i == dest_index) { - ERROR("%s: %s missing pseudo file definition\n", - argv[0], argv[i-1]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: %s missing pseudo file definition\n", + argv[i-1]); + sqfstar_option_help(argv[i - 1]); } pseudo_dir = read_pseudo_dir(argv[i]); @@ -6637,20 +6715,19 @@ static int sqfstar(int argc, char *argv[]) strcmp(argv[i], "-o") == 0) { if((++i == dest_index) || !parse_numberll(argv[i], &start_offset, 1)) { - ERROR("%s: %s missing or invalid offset " - "size\n", argv[0], argv[i - 1]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: %s missing or invalid offset " + "size\n", argv[i - 1]); + sqfstar_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-processors") == 0) { if((++i == dest_index) || !parse_num(argv[i], &processors)) { - ERROR("%s: -processors missing or invalid " - "processor number\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -processors missing or invalid " + "processor number\n"); + sqfstar_option_help(argv[i - 1]); } if(processors < 1) { - ERROR("%s: -processors should be 1 or larger\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -processors should be 1 or larger\n"); + sqfstar_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-mem") == 0) { long long number = 0; @@ -6663,9 +6740,8 @@ static int sqfstar(int argc, char *argv[]) if((++i == dest_index) || !parse_numberll(argv[i], &number, 1)) { - ERROR("%s: -mem missing or invalid mem size\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -mem missing or invalid mem size\n"); + sqfstar_option_help(argv[i - 1]); } /* @@ -6673,16 +6749,16 @@ static int sqfstar(int argc, char *argv[]) * does not overflow a signed int */ if(number >= (1LL << 51)) { - ERROR("%s: -mem invalid mem size\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -mem invalid mem size\n"); + sqfstar_option_help(argv[i - 1]); } total_mem = number / 1048576; if(total_mem < (SQUASHFS_LOWMEM / SQUASHFS_TAKE)) { - ERROR("%s: -mem should be %d Mbytes or " - "larger\n", argv[0], - SQUASHFS_LOWMEM / SQUASHFS_TAKE); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -mem should be %d Mbytes or " + "larger\n", SQUASHFS_LOWMEM / + SQUASHFS_TAKE); + sqfstar_option_help(argv[i - 1]); } calculate_queue_sizes(total_mem, &readq, &fragq, &bwriteq, &fwriteq); @@ -6703,33 +6779,32 @@ static int sqfstar(int argc, char *argv[]) if((++i == dest_index) || !parse_number(argv[i], &percent, 2) || (percent < 1)) { - ERROR("%s: -mem-percent missing or invalid " - "percentage: it should be 1 - 75%\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -mem-percent missing or invalid " + "percentage: it should be 1 - 75%\n"); + sqfstar_option_help(argv[i - 1]); } phys_mem = get_physical_memory(); if(phys_mem == 0) { - ERROR("%s: -mem-percent unable to get physical " - "memory\n", argv[0]); + ERROR("sqfstar: -mem-percent unable to get physical " + "memory\n"); exit(1); } if(multiply_overflow(phys_mem, percent)) { - ERROR("%s: -mem-percent requested phys mem too " - "large\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -mem-percent requested phys mem too " + "large\n"); + sqfstar_option_help(argv[i - 1]); } total_mem = phys_mem * percent / 100; if(total_mem < (SQUASHFS_LOWMEM / SQUASHFS_TAKE)) { - ERROR("%s: -mem-percent mem too small, should " - "be %d Mbytes or larger\n", argv[0], + ERROR("sqfstar: -mem-percent mem too small, should " + "be %d Mbytes or larger\n", SQUASHFS_LOWMEM / SQUASHFS_TAKE); - sqfstar_option_help(argv[0], argv[i - 1]); + sqfstar_option_help(argv[i - 1]); } calculate_queue_sizes(total_mem, &readq, &fragq, &bwriteq, &fwriteq); @@ -6738,23 +6813,22 @@ static int sqfstar(int argc, char *argv[]) exit(0); } else if(strcmp(argv[i], "-b") == 0) { if(++i == dest_index) { - ERROR("%s: -b missing block size\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -b missing block size\n"); + sqfstar_option_help(argv[i - 1]); } if(!parse_number(argv[i], &block_size, 1)) { - ERROR("%s: -b invalid block size\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -b invalid block size\n"); + sqfstar_option_help(argv[i - 1]); } if((block_log = slog(block_size)) == 0) { - ERROR("%s: -b block size not power of two or " - "not between 4096 and 1Mbyte\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -b block size not power of two or " + "not between 4096 and 1Mbyte\n"); + sqfstar_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-ef") == 0) { if(++i == dest_index) { - ERROR("%s: -ef missing filename\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -ef missing filename\n"); + sqfstar_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-no-duplicates") == 0) duplicate_checking = FALSE; @@ -6771,38 +6845,34 @@ static int sqfstar(int argc, char *argv[]) global_uid_opt = global_gid_opt = TRUE; } else if(strcmp(argv[i], "-force-uid") == 0) { if(++i == dest_index) { - ERROR("%s: -force-uid missing uid or user name\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -force-uid missing uid or user name\n"); + sqfstar_option_help(argv[i - 1]); } res = get_uid_from_arg(argv[i], &global_uid); if(res) { if(res == -2) - ERROR("%s: -force-uid uid out of range\n", - argv[0]); + ERROR("sqfstar: -force-uid uid out of range\n"); else - ERROR("%s: -force-uid invalid uid or " - "unknown user name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -force-uid invalid uid or " + "unknown user name\n"); + sqfstar_option_help(argv[i - 1]); } global_uid_opt = TRUE; } else if(strcmp(argv[i], "-force-gid") == 0) { if(++i == dest_index) { - ERROR("%s: -force-gid missing gid or group name\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -force-gid missing gid or group name\n"); + sqfstar_option_help(argv[i - 1]); } res = get_gid_from_arg(argv[i], &global_gid); if(res) { if(res == -2) - ERROR("%s: -force-gid gid out of range" - "\n", argv[0]); + ERROR("sqfstar: -force-gid gid out of range\n"); else - ERROR("%s: -force-gid invalid gid or " - "unknown group name\n", argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -force-gid invalid gid or " + "unknown group name\n"); + sqfstar_option_help(argv[i - 1]); } global_gid_opt = TRUE; } else if(strcmp(argv[i], "-pseudo-override") == 0) @@ -6833,10 +6903,9 @@ static int sqfstar(int argc, char *argv[]) else if(strcmp(argv[i], "-no-xattrs") == 0) { if(xattr_exclude_preg || xattr_include_preg || add_xattrs()) { - ERROR("%s: -no-xattrs should not be used in " - "combination with -xattrs-* options\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -no-xattrs should not be used in " + "combination with -xattrs-* options\n"); + sqfstar_option_help(argv[i - 1]); } no_xattrs = TRUE; @@ -6845,46 +6914,43 @@ static int sqfstar(int argc, char *argv[]) if(xattrs_supported()) no_xattrs = FALSE; else { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("sqfstar: xattrs are unsupported in " + "this build\n"); exit(1); } } else if(strcmp(argv[i], "-xattrs-exclude") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("sqfstar: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == dest_index) { - ERROR("%s: -xattrs-exclude missing regex pattern\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -xattrs-exclude missing regex pattern\n"); + sqfstar_option_help(argv[i - 1]); } else { xattr_exclude_preg = xattr_regex(argv[i], "exclude"); no_xattrs = FALSE; } } else if(strcmp(argv[i], "-xattrs-include") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("sqfstar: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == dest_index) { - ERROR("%s: -xattrs-include missing regex pattern\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -xattrs-include missing regex pattern\n"); + sqfstar_option_help(argv[i - 1]); } else { xattr_include_preg = xattr_regex(argv[i], "include"); no_xattrs = FALSE; } } else if(strcmp(argv[i], "-xattrs-add") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("sqfstar: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == dest_index) { - ERROR("%s: -xattrs-add missing xattr argument\n", - argv[0]); - sqfstar_option_help(argv[0], argv[i - 1]); + ERROR("sqfstar: -xattrs-add missing xattr argument\n"); + sqfstar_option_help(argv[i - 1]); } else { xattrs_add(argv[i]); no_xattrs = FALSE; @@ -6910,12 +6976,12 @@ static int sqfstar(int argc, char *argv[]) progress = silent = TRUE; } else - sqfstar_invalid_option(argv[0], argv[i]); + sqfstar_invalid_option(argv[i]); } if(i == argc) { - ERROR("%s: fatal error: no output filesystem specified on command line\n\n", argv[0]); - sqfstar_help(TRUE, argv[0]); + ERROR("sqfstar: fatal error: no output filesystem specified on command line\n\n"); + sqfstar_help(TRUE); exit(1); } @@ -7084,11 +7150,10 @@ static int sqfstar(int argc, char *argv[]) sizeof(c_byte), &c_byte); write_destination(fd, sizeof(struct squashfs_super_block) + sizeof(c_byte), size, comp_data); - bytes = sizeof(struct squashfs_super_block) + sizeof(c_byte) - + size; + set_pos(sizeof(struct squashfs_super_block) + sizeof(c_byte) + size); comp_opts = TRUE; } else - bytes = sizeof(struct squashfs_super_block); + set_pos(sizeof(struct squashfs_super_block)); if(path) paths = add_subdir(paths, path); @@ -7137,9 +7202,9 @@ static int sqfstar(int argc, char *argv[]) set_progressbar_state(FALSE); write_filesystem_tables(&sBlk); - if(!nopad && (i = bytes & (4096 - 1))) { + if(!nopad && (i = get_pos() & (4096 - 1))) { char temp[4096] = {0}; - write_destination(fd, bytes, 4096 - i, temp); + write_destination(fd, get_pos(), 4096 - i, temp); } res = close(fd); @@ -7208,31 +7273,30 @@ int main(int argc, char *argv[]) /* Scan the command line for options that will immediately quit afterwards */ for(j = i; j < argc; j++) { if(strcmp(argv[j], "-help") == 0 || strcmp(argv[j], "-h") == 0) - mksquashfs_help(FALSE, argv[0]); + mksquashfs_help(FALSE); else if(strcmp(argv[j], "-help-all") == 0 || strcmp(argv[j], "-ha") == 0) - mksquashfs_help_all(argv[0]); + mksquashfs_help_all(); else if(strcmp(argv[j], "-help-option") == 0 || strcmp(argv[j], "-ho") == 0) { if(++j == argc) { - ERROR("%s: %s missing regex\n", argv[0], argv[j - 1]); - mksquashfs_option_help(argv[0], argv[j - 1]); + ERROR("mksquashfs: %s missing regex\n", argv[j - 1]); + mksquashfs_option_help(argv[j - 1]); } - mksquashfs_option(argv[0], argv[j - 1], argv[j]); + mksquashfs_option(argv[j - 1], argv[j]); } else if(strcmp(argv[j], "-help-section") == 0 || strcmp(argv[j], "-hs") == 0) { if(++j == argc) { - ERROR("%s: %s missing section\n", argv[0], argv[j - 1]); - mksquashfs_option_help(argv[0], argv[j - 1]); + ERROR("mksquashfs: %s missing section\n", argv[j - 1]); + mksquashfs_option_help(argv[j - 1]); } - mksquashfs_section(argv[0], argv[j - 1], argv[j]); + mksquashfs_section(argv[j - 1], argv[j]); } else if(strcmp(argv[j], "-help-comp") == 0) { if(++j == argc) { - ERROR("%s: -help-comp missing compressor name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[j - 1]); + ERROR("mksquashfs: -help-comp missing compressor name\n"); + mksquashfs_option_help(argv[j - 1]); } - print_compressor_options(argv[j], argv[0]); + print_compressor_options(argv[j], "mksquashfs"); exit(0); } else if(strcmp(argv[j], "-mem-default") == 0) { printf("%d\n", total_mem); @@ -7255,22 +7319,21 @@ int main(int argc, char *argv[]) if(strcmp(argv[j], "-comp") == 0) { if(++j == argc) { - ERROR("%s: -comp missing compression type\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[j - 1]); + ERROR("mksquashfs: -comp missing compression type\n"); + mksquashfs_option_help(argv[j - 1]); } comp = lookup_compressor(argv[j]); if(!comp->supported) { - ERROR("%s: Compressor \"%s\" is not supported!" - "\n", argv[0], argv[j]); - ERROR("%s: Compressors available:\n", argv[0]); + ERROR("mksquashfs: Compressor \"%s\" is not " + "supported!\n", argv[j]); + ERROR("mksquashfs: Compressors available:\n"); display_compressors(stderr, "", COMP_DEFAULT); exit(1); } if(prev_comp != NULL && prev_comp != comp) { - ERROR("%s: -comp multiple conflicting -comp" - " options specified on command line" - ", previously %s, now %s\n", argv[0], + ERROR("mksquashfs: -comp multiple conflicting " + "-comp options specified on command " + "line, previously %s, now %s\n", prev_comp->name, comp->name); exit(1); } @@ -7293,16 +7356,16 @@ int main(int argc, char *argv[]) comp = lookup_compressor(COMP_DEFAULT); if(Xhelp) { - print_selected_comp_options(stdout, comp, argv[0]); + print_selected_comp_options(stdout, comp, "mksquashfs"); exit(0); } if(i < 3) { if(i == 1) - ERROR("%s: fatal error: no source or output filesystem specified on command line\n\n", argv[0]); + ERROR("mksquashfs: fatal error: no source or output filesystem specified on command line\n\n"); else - ERROR("%s: fatal error: no output filesystem specified on command line\n\n", argv[0]); - mksquashfs_help(TRUE, argv[0]); + ERROR("mksquashfs: fatal error: no output filesystem specified on command line\n\n"); + mksquashfs_help(TRUE); } option_offset = i; @@ -7331,8 +7394,8 @@ int main(int argc, char *argv[]) always_use_fragments = TRUE; } else if(strcmp(argv[i], "-pf") == 0) { if(++i == argc) { - ERROR("%s: -pf missing filename\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -pf missing filename\n"); + mksquashfs_option_help(argv[i - 1]); } if(strcmp(argv[i], "-") == 0) pseudo_stdin = TRUE; @@ -7362,9 +7425,8 @@ int main(int argc, char *argv[]) one_file_system = one_file_system_x = TRUE; else if(strcmp(argv[i], "-recovery-path") == 0) { if(++i == argc) { - ERROR("%s: -recovery-path missing pathname\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -recovery-path missing pathname\n"); + mksquashfs_option_help(argv[i - 1]); } recovery_pathname = argv[i]; } else if(strcmp(argv[i], "-no-hardlinks") == 0) @@ -7374,32 +7436,27 @@ int main(int argc, char *argv[]) tarstyle = TRUE; else if(strcmp(argv[i], "-max-depth") == 0) { if((++i == argc) || !parse_num_unsigned(argv[i], &max_depth)) { - ERROR("%s: -max-depth missing or invalid value\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -max-depth missing or invalid value\n"); + mksquashfs_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-throttle") == 0) { if((++i == argc) || !parse_number(argv[i], &sleep_time, 2)) { - ERROR("%s: -throttle missing or invalid value\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -throttle missing or invalid value\n"); + mksquashfs_option_help(argv[i - 1]); } if(sleep_time > 99) { - ERROR("%s: -throttle value should be between 0 and " - "99\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -throttle value should be between 0 and 99\n"); + mksquashfs_option_help(argv[i - 1]); } readq = 4; } else if(strcmp(argv[i], "-limit") == 0) { if((++i == argc) || !parse_number(argv[i], &sleep_time, 2)) { - ERROR("%s: -limit missing or invalid value\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -limit missing or invalid value\n"); + mksquashfs_option_help(argv[i - 1]); } if(sleep_time < 1 || sleep_time > 100) { - ERROR("%s: -limit value should be between 1 and " - "100\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -limit value should be between 1 and 100\n"); + mksquashfs_option_help(argv[i - 1]); } sleep_time = 100 - sleep_time; readq = 4; @@ -7408,19 +7465,18 @@ int main(int argc, char *argv[]) if((++i == argc) || (!parse_num_unsigned(argv[i], &mkfs_time) && !exec_date(argv[i], &mkfs_time))) { - ERROR("%s: %s missing or invalid time " - "value\n", argv[0], - argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing or invalid time " + "value\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } mkfs_time_opt = TRUE; } else if(strcmp(argv[i], "-all-time") == 0) { if((++i == argc) || (!parse_num_unsigned(argv[i], &all_time) && !exec_date(argv[i], &all_time))) { - ERROR("%s: -all-time missing or invalid time " - "value\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -all-time missing or invalid time " + "value\n"); + mksquashfs_option_help(argv[i - 1]); } all_time_opt = TRUE; clamping = FALSE; @@ -7430,116 +7486,105 @@ int main(int argc, char *argv[]) reproducible = FALSE; else if(strcmp(argv[i], "-root-mode") == 0) { if((++i == argc) || !parse_mode(argv[i], &root_mode)) { - ERROR("%s: -root-mode missing or invalid mode," - " octal number <= 07777 expected\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-mode missing or invalid mode," + " octal number <= 07777 expected\n"); + mksquashfs_option_help(argv[i - 1]); } root_mode_opt = TRUE; } else if(strcmp(argv[i], "-root-uid") == 0) { if(++i == argc) { - ERROR("%s: -root-uid missing uid or user name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-uid missing uid or user name\n"); + mksquashfs_option_help(argv[i - 1]); } res = get_uid_from_arg(argv[i], &root_uid); if(res) { if(res == -2) - ERROR("%s: -root-uid uid out of range\n", - argv[0]); + ERROR("mksquashfs: -root-uid uid out of range\n"); else - ERROR("%s: -root-uid invalid uid or " - "unknown user name\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-uid invalid uid or " + "unknown user name\n"); + mksquashfs_option_help(argv[i - 1]); } root_uid_opt = TRUE; } else if(strcmp(argv[i], "-root-gid") == 0) { if(++i == argc) { - ERROR("%s: -root-gid missing gid or group name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-gid missing gid or group name\n"); + mksquashfs_option_help(argv[i - 1]); } res = get_gid_from_arg(argv[i], &root_gid); if(res) { if(res == -2) - ERROR("%s: -root-gid gid out of range\n", - argv[0]); + ERROR("mksquashfs: -root-gid gid out of range\n"); else - ERROR("%s: -root-gid invalid gid or " - "unknown group name\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-gid invalid gid or " + "unknown group name\n"); + mksquashfs_option_help(argv[i - 1]); } root_gid_opt = TRUE; } else if(strcmp(argv[i], "-root-time") == 0) { if((++i == argc) || (!parse_num_unsigned(argv[i], &root_time) && !exec_date(argv[i], &root_time))) { - ERROR("%s: -root-time missing or invalid time\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-time missing or invalid time\n"); + mksquashfs_option_help(argv[i - 1]); } root_time_opt = TRUE; } else if(strcmp(argv[i], "-default-mode") == 0) { if((++i == argc) || !parse_mode(argv[i], &default_mode)) { - ERROR("%s: -default-mode missing or invalid mode," - " octal number <= 07777 expected\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -default-mode missing or invalid mode," + " octal number <= 07777 expected\n"); + mksquashfs_option_help(argv[i - 1]); } root_mode = default_mode; default_mode_opt = root_mode_opt = TRUE; } else if(strcmp(argv[i], "-default-uid") == 0) { if(++i == argc) { - ERROR("%s: -default-uid missing uid or user name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -default-uid missing uid or user name\n"); + mksquashfs_option_help(argv[i - 1]); } res = get_uid_from_arg(argv[i], &default_uid); if(res) { if(res == -2) - ERROR("%s: -default-uid uid out of range\n", - argv[0]); + ERROR("mksquashfs: -default-uid uid out of range\n"); else - ERROR("%s: -default-uid invalid uid or " - "unknown user name\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -default-uid invalid uid or " + "unknown user name\n"); + mksquashfs_option_help(argv[i - 1]); } root_uid = default_uid; default_uid_opt = root_uid_opt = TRUE; } else if(strcmp(argv[i], "-default-gid") == 0) { if(++i == argc) { - ERROR("%s: -default-gid missing gid or group name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -default-gid missing gid or group name\n"); + mksquashfs_option_help(argv[i - 1]); } res = get_gid_from_arg(argv[i], &default_gid); if(res) { if(res == -2) - ERROR("%s: -default-gid gid out of range" - "\n", argv[0]); + ERROR("mksquashfs: -default-gid gid out of range\n"); else - ERROR("%s: -default-gid invalid gid or " - "unknown group name\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -default-gid invalid gid or " + "unknown group name\n"); + mksquashfs_option_help(argv[i - 1]); } root_gid = default_gid; default_gid_opt = root_gid_opt = TRUE; } else if(strcmp(argv[i], "-log") == 0) { if(++i == argc) { - ERROR("%s: -log missing log file\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -log missing log file\n"); + mksquashfs_option_help(argv[i - 1]); } open_log_file(argv[i]); } else if(strcmp(argv[i], "-action") == 0 || strcmp(argv[i], "-a") ==0) { if(++i == argc) { - ERROR("%s: %s missing action\n", - argv[0], argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing action\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } res = parse_action(argv[i], ACTION_LOG_NONE); if(res == 0) @@ -7548,9 +7593,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-log-action") == 0 || strcmp(argv[i], "-va") ==0) { if(++i == argc) { - ERROR("%s: %s missing action\n", - argv[0], argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing action\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } res = parse_action(argv[i], ACTION_LOG_VERBOSE); if(res == 0) @@ -7559,9 +7603,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-true-action") == 0 || strcmp(argv[i], "-ta") ==0) { if(++i == argc) { - ERROR("%s: %s missing action\n", - argv[0], argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing action\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } res = parse_action(argv[i], ACTION_LOG_TRUE); if(res == 0) @@ -7570,9 +7613,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-false-action") == 0 || strcmp(argv[i], "-fa") ==0) { if(++i == argc) { - ERROR("%s: %s missing action\n", - argv[0], argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing action\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } res = parse_action(argv[i], ACTION_LOG_FALSE); if(res == 0) @@ -7581,9 +7623,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-action-file") == 0 || strcmp(argv[i], "-af") ==0) { if(++i == argc) { - ERROR("%s: %s missing filename\n", argv[0], - argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing filename\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } if(read_action_file(argv[i], ACTION_LOG_NONE) == FALSE) exit(1); @@ -7591,9 +7632,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-log-action-file") == 0 || strcmp(argv[i], "-vaf") ==0) { if(++i == argc) { - ERROR("%s: %s missing filename\n", argv[0], - argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing filename\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } if(read_action_file(argv[i], ACTION_LOG_VERBOSE) == FALSE) exit(1); @@ -7601,9 +7641,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-true-action-file") == 0 || strcmp(argv[i], "-taf") ==0) { if(++i == argc) { - ERROR("%s: %s missing filename\n", argv[0], - argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing filename\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } if(read_action_file(argv[i], ACTION_LOG_TRUE) == FALSE) exit(1); @@ -7611,9 +7650,8 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-false-action-file") == 0 || strcmp(argv[i], "-faf") ==0) { if(++i == argc) { - ERROR("%s: %s missing filename\n", argv[0], - argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing filename\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } if(read_action_file(argv[i], ACTION_LOG_FALSE) == FALSE) exit(1); @@ -7623,14 +7661,12 @@ int main(int argc, char *argv[]) if(args < 0) { if(args == -1) { - ERROR("%s: Unrecognised compressor" - " option %s\n", argv[0], - argv[i]); + ERROR("mksquashfs: Unrecognised compressor" + " option %s\n", argv[i]); if(!compressor_opt_parsed) - ERROR("%s: Did you forget to" - " specify -comp?\n", - argv[0]); - print_selected_comp_options(stderr, comp, argv[0]); + ERROR("mksquashfs: Did you forget to" + " specify -comp?\n"); + print_selected_comp_options(stderr, comp, "mksquashfs"); } exit(1); } @@ -7641,17 +7677,16 @@ int main(int argc, char *argv[]) exit(1); } else if(strcmp(argv[i], "-p") == 0) { if(++i == argc) { - ERROR("%s: -p missing pseudo file definition\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -p missing pseudo file definition\n"); + mksquashfs_option_help(argv[i - 1]); } if(read_pseudo_definition(argv[i], destination_file) == FALSE) exit(1); } else if(strcmp(argv[i], "-pd") == 0 || strcmp(argv[i], "-pseudo-dir") == 0) { if(++i == argc) { - ERROR("%s: %s missing pseudo file definition\n", - argv[0], argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing pseudo file definition\n", + argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } pseudo_dir = read_pseudo_dir(argv[i]); @@ -7659,9 +7694,8 @@ int main(int argc, char *argv[]) exit(1); } else if(strcmp(argv[i], "-recover") == 0) { if(++i == argc) { - ERROR("%s: -recover missing recovery file\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -recover missing recovery file\n"); + mksquashfs_option_help(argv[i - 1]); } read_recovery_data(argv[i], destination_file); } else if(strcmp(argv[i], "-no-recovery") == 0) @@ -7686,54 +7720,53 @@ int main(int argc, char *argv[]) strcmp(argv[i], "-o") == 0) { if((++i == argc) || !parse_numberll(argv[i], &start_offset, 1)) { - ERROR("%s: %s missing or invalid offset " - "size\n", argv[0], argv[i - 1]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: %s missing or invalid offset " + "size\n", argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-processors") == 0) { if((++i == argc) || !parse_num(argv[i], &processors)) { - ERROR("%s: -processors missing or invalid " - "processor number\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -processors missing or invalid " + "processor number\n"); + mksquashfs_option_help(argv[i - 1]); } if(processors < 1) { - ERROR("%s: -processors should be 1 or larger\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -processors should be 1 or larger\n"); + mksquashfs_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-read-queue") == 0) { if((++i == argc) || !parse_num(argv[i], &readq)) { - ERROR("%s: -read-queue missing or invalid " - "queue size\n", argv[0]); + ERROR("mksquashfs: -read-queue missing or invalid " + "queue size\n"); exit(1); } if(readq < 1) { - ERROR("%s: -read-queue should be 1 megabyte or " - "larger\n", argv[0]); + ERROR("mksquashfs: -read-queue should be 1 megabyte or " + "larger\n"); exit(1); } } else if(strcmp(argv[i], "-write-queue") == 0) { if((++i == argc) || !parse_num(argv[i], &bwriteq)) { - ERROR("%s: -write-queue missing or invalid " - "queue size\n", argv[0]); + ERROR("mksquashfs: -write-queue missing or invalid " + "queue size\n"); exit(1); } if(bwriteq < 2) { - ERROR("%s: -write-queue should be 2 megabytes " - "or larger\n", argv[0]); + ERROR("mksquashfs: -write-queue should be 2 megabytes " + "or larger\n"); exit(1); } fwriteq = bwriteq >> 1; bwriteq -= fwriteq; } else if(strcmp(argv[i], "-fragment-queue") == 0) { if((++i == argc) || !parse_num(argv[i], &fragq)) { - ERROR("%s: -fragment-queue missing or invalid " - "queue size\n", argv[0]); + ERROR("mksquashfs: -fragment-queue missing or invalid " + "queue size\n"); exit(1); } if(fragq < 1) { - ERROR("%s: -fragment-queue should be 1 " - "megabyte or larger\n", argv[0]); + ERROR("mksquashfs: -fragment-queue should be 1 " + "megabyte or larger\n"); exit(1); } } else if(strcmp(argv[i], "-mem") == 0) { @@ -7747,9 +7780,8 @@ int main(int argc, char *argv[]) if((++i == argc) || !parse_numberll(argv[i], &number, 1)) { - ERROR("%s: -mem missing or invalid mem size\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -mem missing or invalid mem size\n"); + mksquashfs_option_help(argv[i - 1]); } /* @@ -7757,16 +7789,16 @@ int main(int argc, char *argv[]) * does not overflow a signed int */ if(number >= (1LL << 51)) { - ERROR("%s: -mem invalid mem size\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -mem invalid mem size\n"); + mksquashfs_option_help(argv[i - 1]); } total_mem = number / 1048576; if(total_mem < (SQUASHFS_LOWMEM / SQUASHFS_TAKE)) { - ERROR("%s: -mem should be %d Mbytes or " - "larger\n", argv[0], + ERROR("mksquashfs: -mem should be %d Mbytes or " + "larger\n", SQUASHFS_LOWMEM / SQUASHFS_TAKE); - mksquashfs_option_help(argv[0], argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } calculate_queue_sizes(total_mem, &readq, &fragq, &bwriteq, &fwriteq); @@ -7786,56 +7818,54 @@ int main(int argc, char *argv[]) if((++i == argc) || !parse_number(argv[i], &percent, 2) || (percent < 1)) { - ERROR("%s: -mem-percent missing or invalid " - "percentage: it should be 1 - 75%\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -mem-percent missing or invalid " + "percentage: it should be 1 - 75%\n"); + mksquashfs_option_help(argv[i - 1]); } phys_mem = get_physical_memory(); if(phys_mem == 0) { - ERROR("%s: -mem-percent unable to get physical " - "memory\n", argv[0]); + ERROR("mksquashfs: -mem-percent unable to get physical " + "memory\n"); exit(1); } if(multiply_overflow(phys_mem, percent)) { - ERROR("%s: -mem-percent requested phys mem too " - "large\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -mem-percent requested phys mem too " + "large\n"); + mksquashfs_option_help(argv[i - 1]); } total_mem = phys_mem * percent / 100; if(total_mem < (SQUASHFS_LOWMEM / SQUASHFS_TAKE)) { - ERROR("%s: -mem-percent mem too small, should " - "be %d Mbytes or larger\n", argv[0], + ERROR("mksquashfs: -mem-percent mem too small, should " + "be %d Mbytes or larger\n", SQUASHFS_LOWMEM / SQUASHFS_TAKE); - mksquashfs_option_help(argv[0], argv[i - 1]); + mksquashfs_option_help(argv[i - 1]); } calculate_queue_sizes(total_mem, &readq, &fragq, &bwriteq, &fwriteq); } else if(strcmp(argv[i], "-b") == 0) { if(++i == argc) { - ERROR("%s: -b missing block size\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -b missing block size\n"); + mksquashfs_option_help(argv[i - 1]); } if(!parse_number(argv[i], &block_size, 1)) { - ERROR("%s: -b invalid block size\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -b invalid block size\n"); + mksquashfs_option_help(argv[i - 1]); } if((block_log = slog(block_size)) == 0) { - ERROR("%s: -b block size not power of two or " - "not between 4096 and 1Mbyte\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -b block size not power of two or " + "not between 4096 and 1Mbyte\n"); + mksquashfs_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-ef") == 0) { if(++i == argc) { - ERROR("%s: -ef missing filename\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -ef missing filename\n"); + mksquashfs_option_help(argv[i - 1]); } exclude_option = TRUE; } else if(strcmp(argv[i], "-no-duplicates") == 0) @@ -7853,8 +7883,8 @@ int main(int argc, char *argv[]) else if(strcmp(argv[i], "-sort") == 0) { if(++i == argc) { - ERROR("%s: -sort missing filename\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -sort missing filename\n"); + mksquashfs_option_help(argv[i - 1]); } } else if(strcmp(argv[i], "-all-root") == 0 || strcmp(argv[i], "-root-owned") == 0) { @@ -7862,38 +7892,34 @@ int main(int argc, char *argv[]) global_uid_opt = global_gid_opt = TRUE; } else if(strcmp(argv[i], "-force-uid") == 0) { if(++i == argc) { - ERROR("%s: -force-uid missing uid or user name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -force-uid missing uid or user name\n"); + mksquashfs_option_help(argv[i - 1]); } res = get_uid_from_arg(argv[i], &global_uid); if(res) { if(res == -2) - ERROR("%s: -force-uid uid out of range\n", - argv[0]); + ERROR("mksquashfs: -force-uid uid out of range\n"); else - ERROR("%s: -force-uid invalid uid or " - "unknown user name\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -force-uid invalid uid or " + "unknown user name\n"); + mksquashfs_option_help(argv[i - 1]); } global_uid_opt = TRUE; } else if(strcmp(argv[i], "-force-gid") == 0) { if(++i == argc) { - ERROR("%s: -force-gid missing gid or group name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -force-gid missing gid or group name\n"); + mksquashfs_option_help(argv[i - 1]); } res = get_gid_from_arg(argv[i], &global_gid); if(res) { if(res == -2) - ERROR("%s: -force-gid gid out of range" - "\n", argv[0]); + ERROR("mksquashfs: -force-gid gid out of range\n"); else - ERROR("%s: -force-gid invalid gid or " - "unknown group name\n", argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -force-gid invalid gid or " + "unknown group name\n"); + mksquashfs_option_help(argv[i - 1]); } global_gid_opt = TRUE; } else if(strcmp(argv[i], "-pseudo-override") == 0) @@ -7924,10 +7950,9 @@ int main(int argc, char *argv[]) else if(strcmp(argv[i], "-no-xattrs") == 0) { if(xattr_exclude_preg || xattr_include_preg || add_xattrs()) { - ERROR("%s: -no-xattrs should not be used in " - "combination with -xattrs-* options\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -no-xattrs should not be used in " + "combination with -xattrs-* options\n"); + mksquashfs_option_help(argv[i - 1]); } no_xattrs = TRUE; @@ -7936,20 +7961,19 @@ int main(int argc, char *argv[]) if(xattrs_supported()) no_xattrs = FALSE; else { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("mksquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } } else if(strcmp(argv[i], "-xattrs-exclude") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("mksquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == argc) { - ERROR("%s: -xattrs-exclude missing regex pattern\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -xattrs-exclude missing regex pattern\n"); + mksquashfs_option_help(argv[i - 1]); } else { xattr_exclude_preg = xattr_regex(argv[i], "exclude"); no_xattrs = FALSE; @@ -7957,26 +7981,24 @@ int main(int argc, char *argv[]) } else if(strcmp(argv[i], "-xattrs-include") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("mksquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == argc) { - ERROR("%s: -xattrs-include missing regex pattern\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -xattrs-include missing regex pattern\n"); + mksquashfs_option_help(argv[i - 1]); } else { xattr_include_preg = xattr_regex(argv[i], "include"); no_xattrs = FALSE; } } else if(strcmp(argv[i], "-xattrs-add") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("mksquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == argc) { - ERROR("%s: -xattrs-add missing xattr argument\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -xattrs-add missing xattr argument\n"); + mksquashfs_option_help(argv[i - 1]); } else { xattrs_add(argv[i]); no_xattrs = FALSE; @@ -8005,9 +8027,8 @@ int main(int argc, char *argv[]) else if(strcmp(argv[i], "-root-becomes") == 0) { if(++i == argc) { - ERROR("%s: -root-becomes: missing name\n", - argv[0]); - mksquashfs_option_help(argv[0], argv[i - 1]); + ERROR("mksquashfs: -root-becomes: missing name\n"); + mksquashfs_option_help(argv[i - 1]); } root_name = argv[i]; } else if(strcmp(argv[i], "-percentage") == 0) { @@ -8023,7 +8044,7 @@ int main(int argc, char *argv[]) /* parsed previously */ i++; } else - mksquashfs_invalid_option(argv[0], argv[i]); + mksquashfs_invalid_option(argv[i]); } check_source_date_epoch(); @@ -8201,7 +8222,7 @@ int main(int argc, char *argv[]) if(i != argc) { if(++i == argc) { - ERROR("%s: -e missing arguments\n", argv[0]); + ERROR("mksquashfs: -e missing arguments\n"); EXIT_MKSQUASHFS(); } while(i < argc) @@ -8293,11 +8314,10 @@ int main(int argc, char *argv[]) sizeof(c_byte), &c_byte); write_destination(fd, sizeof(struct squashfs_super_block) + sizeof(c_byte), size, comp_data); - bytes = sizeof(struct squashfs_super_block) + sizeof(c_byte) - + size; + set_pos(sizeof(struct squashfs_super_block) + sizeof(c_byte) + size); comp_opts = TRUE; } else - bytes = sizeof(struct squashfs_super_block); + set_pos(sizeof(struct squashfs_super_block)); } else { unsigned int last_directory_block, inode_dir_file_size, root_inode_size, inode_dir_start_block, @@ -8308,8 +8328,7 @@ int main(int argc, char *argv[]) root_inode_offset = SQUASHFS_INODE_OFFSET(sBlk.root_inode); int inode_dir_offset, uncompressed_data; - - if((bytes = read_filesystem(root_name, fd, &sBlk, &inode_table, + long long bytes = read_filesystem(root_name, fd, &sBlk, &inode_table, &data_cache, &directory_table, &directory_data_cache, &last_directory_block, &inode_dir_offset, &inode_dir_file_size, @@ -8319,13 +8338,18 @@ int main(int argc, char *argv[]) &total_inode_bytes, &total_directory_bytes, &inode_dir_inode_number, &inode_dir_parent_inode, add_old_root_entry, - &fragment_table, &inode_lookup_table)) == 0) { + &fragment_table, &inode_lookup_table); + + if(bytes == 0) { ERROR("Failed to read existing filesystem - will not " "overwrite - ABORTING!\n"); ERROR("To force Mksquashfs to write to this block " "device or file use -noappend\n"); EXIT_MKSQUASHFS(); } + + set_pos(bytes); + if((fragments = sBlk.fragments)) { fragment_table = realloc((char *) fragment_table, ((fragments + FRAG_SIZE - 1) & ~(FRAG_SIZE - 1)) @@ -8485,9 +8509,9 @@ int main(int argc, char *argv[]) set_progressbar_state(FALSE); write_filesystem_tables(&sBlk); - if(!nopad && (i = bytes & (4096 - 1))) { + if(!nopad && (i = get_pos() & (4096 - 1))) { char temp[4096] = {0}; - write_destination(fd, bytes, 4096 - i, temp); + write_destination(fd, get_pos(), 4096 - i, temp); } res = close(fd); diff --git a/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.c b/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.c index 9ee61b51db6..c516594af55 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.c +++ b/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.c @@ -363,6 +363,7 @@ static char *mksquashfs_text[]={ "\"filename i mode uid gid [s|f]\"\t\tcreate a socket (s) or FIFO " "(f)\n", "\"filename x name=val\"\t\t\tcreate an extended attribute\n", + "\"filename h linkname\"\t\t\tcreate a hard-link to linkname, follows symlinks\n", "\"filename l linkname\"\t\t\tcreate a hard-link to linkname\n", "\"filename L pseudo_filename\"\t\tsame, but link to pseudo file\n", "\"filename D time mode uid gid\"\t\tcreate a directory with timestamp " @@ -584,6 +585,7 @@ static char *sqfstar_text[]={ "\"filename i mode uid gid [s|f]\"\t\tcreate a socket (s) or FIFO " "(f)\n", "\"filename x name=val\"\t\t\tcreate an extended attribute\n", + "\"filename h linkname\"\t\t\tcreate a hard-link to linkname, follows symlinks\n", "\"filename l linkname\"\t\t\tcreate a hard-link to linkname\n", "\"filename L pseudo_filename\"\t\tsame, but link to pseudo file\n", "\"filename D time mode uid gid\"\t\tcreate a directory with timestamp " @@ -782,7 +784,7 @@ static void handle_invalid_option(char *prog_name, char *opt_name, char **sectio } -static void print_help(int error, char *prog_name, char *syntax, char **sections, char **options_text) +static void print_help(char *prog_name, int error, char *syntax, char **sections, char **options_text) { FILE *stream = error ? stderr : stdout; int cols = get_column_width(); @@ -809,65 +811,65 @@ static void print_option_help(char *prog_name, char *option, char **sections, ch } -void mksquashfs_help_all(char *name) +void mksquashfs_help_all(void) { - print_help_all(name, MKSQUASHFS_SYNTAX, mksquashfs_text); + print_help_all("mksquashfs", MKSQUASHFS_SYNTAX, mksquashfs_text); } -void sqfstar_help_all(char *name) +void sqfstar_help_all(void) { - print_help_all(name, SQFSTAR_SYNTAX, sqfstar_text); + print_help_all("sqfstar", SQFSTAR_SYNTAX, sqfstar_text); } -void mksquashfs_option(char *prog_name, char *opt_name, char *pattern) +void mksquashfs_option(char *opt_name, char *pattern) { - print_option(prog_name, opt_name, pattern, mksquashfs_options, mksquashfs_args, mksquashfs_text); + print_option("mksquashfs", opt_name, pattern, mksquashfs_options, mksquashfs_args, mksquashfs_text); } -void sqfstar_option(char *prog_name, char *opt_name, char *pattern) +void sqfstar_option(char *opt_name, char *pattern) { - print_option(prog_name, opt_name, pattern, sqfstar_options, sqfstar_args, sqfstar_text); + print_option("sqfstar", opt_name, pattern, sqfstar_options, sqfstar_args, sqfstar_text); } -void mksquashfs_section(char *prog_name, char *opt_name, char *sec_name) +void mksquashfs_section(char *opt_name, char *sec_name) { - print_section(prog_name, opt_name, sec_name, mksquashfs_sections, mksquashfs_text); + print_section("mksquashfs", opt_name, sec_name, mksquashfs_sections, mksquashfs_text); } -void sqfstar_section(char *prog_name, char *opt_name, char *sec_name) +void sqfstar_section(char *opt_name, char *sec_name) { - print_section(prog_name, opt_name, sec_name, sqfstar_sections, sqfstar_text); + print_section("sqfstar", opt_name, sec_name, sqfstar_sections, sqfstar_text); } -void mksquashfs_help(int error, char *prog_name) +void mksquashfs_help(int error) { - print_help(error, prog_name, MKSQUASHFS_SYNTAX, mksquashfs_sections, mksquashfs_text); + print_help("mksquashfs", error, MKSQUASHFS_SYNTAX, mksquashfs_sections, mksquashfs_text); } -void sqfstar_help(int error, char *prog_name) +void sqfstar_help(int error) { - print_help(error, prog_name, SQFSTAR_SYNTAX, sqfstar_sections, sqfstar_text); + print_help("sqfstar", error, SQFSTAR_SYNTAX, sqfstar_sections, sqfstar_text); } -void mksquashfs_invalid_option(char *prog_name, char *opt_name) +void mksquashfs_invalid_option(char *opt_name) { - handle_invalid_option(prog_name, opt_name, mksquashfs_sections, mksquashfs_text); + handle_invalid_option("mksquashfs", opt_name, mksquashfs_sections, mksquashfs_text); } -void sqfstar_invalid_option(char *prog_name, char *opt_name) +void sqfstar_invalid_option(char *opt_name) { - handle_invalid_option(prog_name, opt_name, sqfstar_sections, sqfstar_text); + handle_invalid_option("sqfstar", opt_name, sqfstar_sections, sqfstar_text); } -void mksquashfs_option_help(char *prog_name, char *option) +void mksquashfs_option_help(char *option) { - print_option_help(prog_name, option, mksquashfs_sections, mksquashfs_text); + print_option_help("mksquashfs", option, mksquashfs_sections, mksquashfs_text); } -void sqfstar_option_help(char *prog_name, char *option) +void sqfstar_option_help(char *option) { - print_option_help(prog_name, option, sqfstar_sections, sqfstar_text); + print_option_help("sqfstar", option, sqfstar_sections, sqfstar_text); } diff --git a/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.h b/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.h index 7df3dff685d..e4b655c475a 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.h +++ b/trunk/tools/mksquashfs_xz/squashfs/mksquashfs_help.h @@ -59,16 +59,16 @@ #define TRUE 1 #define FALSE 0 -extern void mksquashfs_help_all(char *name); -extern void mksquashfs_option(char *prog_name, char *opt_name, char *pattern); -extern void mksquashfs_section(char *prog_name, char *opt_name, char *sec_name); -extern void mksquashfs_invalid_option(char *prog_name, char *opt_name); -extern void mksquashfs_help(int error, char *prog_name); -extern void mksquashfs_option_help(char *prog_name, char *option); -extern void sqfstar_help_all(char *name); -extern void sqfstar_option(char *prog_name, char *opt_name, char *pattern); -extern void sqfstar_section(char *prog_name, char *opt_name, char *sec_name); -extern void sqfstar_invalid_option(char *prog_name, char *opt_name); -extern void sqfstar_help(int error, char *prog_name); -extern void sqfstar_option_help(char *prog_name, char *option); +extern void mksquashfs_help_all(void); +extern void mksquashfs_option(char *opt_name, char *pattern); +extern void mksquashfs_section(char *opt_name, char *sec_name); +extern void mksquashfs_invalid_option(char *opt_name); +extern void mksquashfs_help(int error); +extern void mksquashfs_option_help(char *option); +extern void sqfstar_help_all(void); +extern void sqfstar_option(char *opt_name, char *pattern); +extern void sqfstar_section(char *opt_name, char *sec_name); +extern void sqfstar_invalid_option(char *opt_name); +extern void sqfstar_help(int error); +extern void sqfstar_option_help(char *option); #endif diff --git a/trunk/tools/mksquashfs_xz/squashfs/pseudo.c b/trunk/tools/mksquashfs_xz/squashfs/pseudo.c index 0c5c1b65756..1511ef2f755 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/pseudo.c +++ b/trunk/tools/mksquashfs_xz/squashfs/pseudo.c @@ -62,6 +62,7 @@ char *pseudo_definitions[] = { "s mode uid gid symlink", "i mode uid gid [s|f]", "x name=value", + "h filename", "l filename", "L pseudo_filename", "D time mode uid gid", @@ -469,7 +470,7 @@ static struct pseudo_dev *read_pseudo_def_pseudo_link(char *orig_def, char *def) } -static struct pseudo_dev *read_pseudo_def_link(char *orig_def, char *def, char *destination) +static struct pseudo_dev *read_pseudo_def_link(char *orig_def, char *def, char *destination, int follow) { char *linkname, *link; int quoted = FALSE; @@ -525,6 +526,18 @@ static struct pseudo_dev *read_pseudo_def_link(char *orig_def, char *def, char * goto error; } + if(follow) { + char *resolved_linkname = realpath(linkname, NULL); + + if (resolved_linkname == NULL) { + ERROR("Cannot resolve pseudo link file %s because %s\n", linkname, strerror(errno)); + goto error; + } + + free(linkname); + linkname = resolved_linkname; + } + dev = malloc(sizeof(struct pseudo_dev)); if(dev == NULL) MEM_ERROR(); @@ -1185,10 +1198,12 @@ static int read_pseudo_def(char *def, char *destination, char *pseudo_file, stru if(type == 'x') xattr = read_pseudo_xattr(def); else if(type == 'l') - dev = read_pseudo_def_link(orig_def, def, destination); + dev = read_pseudo_def_link(orig_def, def, destination, 0); + else if(type == 'h') + dev = read_pseudo_def_link(orig_def, def, destination, 1); else if(type == 'L') dev = read_pseudo_def_pseudo_link(orig_def, def); - if(is_original_def(type)) + else if(is_original_def(type)) dev = read_pseudo_def_original(type, orig_def, def); else if(is_extended_def(type)) dev = read_pseudo_def_extended(type, orig_def, def, pseudo_file, file); diff --git a/trunk/tools/mksquashfs_xz/squashfs/unsquashfs.c b/trunk/tools/mksquashfs_xz/squashfs/unsquashfs.c index 26445c7c1db..45b7b7510b8 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/unsquashfs.c +++ b/trunk/tools/mksquashfs_xz/squashfs/unsquashfs.c @@ -3936,23 +3936,23 @@ static int parse_cat_options(int argc, char *argv[]) if(*argv[i] != '-') break; if(strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) - sqfscat_help(FALSE, argv[0]); + sqfscat_help(FALSE); else if(strcmp(argv[i], "-help-all") == 0 || strcmp(argv[i], "-ha") == 0) - sqfscat_help_all(argv[0]); + sqfscat_help_all(); else if(strcmp(argv[i], "-help-option") == 0 || strcmp(argv[i], "-ho") == 0) { if(++i == argc) { ERROR("%s: %s missing regex\n", argv[0], argv[i - 1]); - exit(1); + sqfscat_option_help(argv[i - 1]); } - sqfscat_option(argv[0], argv[i - 1], argv[i]); + sqfscat_option(argv[i - 1], argv[i]); } else if(strcmp(argv[i], "-help-section") == 0 || strcmp(argv[i], "-hs") == 0) { if(++i == argc) { ERROR("%s: %s missing section\n", argv[0], argv[i - 1]); - exit(1); + sqfscat_option_help(argv[i - 1]); } - sqfscat_section(argv[0], argv[i - 1], argv[i]); + sqfscat_section(argv[i - 1], argv[i]); } else if(strcmp(argv[i], "-no-exit-code") == 0 || strcmp(argv[i], "-no-exit") == 0) set_exit_code = FALSE; @@ -3976,7 +3976,7 @@ static int parse_cat_options(int argc, char *argv[]) &processors)) { ERROR("%s: -processors missing or invalid " "processor number\n", argv[0]); - exit(1); + sqfscat_option_help(argv[i - 1]); } if(processors < 1) { ERROR("%s: -processors should be 1 or larger\n", @@ -3990,6 +3990,7 @@ static int parse_cat_options(int argc, char *argv[]) !parse_numberll(argv[i], &number, 1)) { ERROR("%s: -mem missing or invalid mem size\n", argv[0]); + sqfscat_option_help(argv[i - 1]); exit(1); } @@ -4024,7 +4025,7 @@ static int parse_cat_options(int argc, char *argv[]) ERROR("%s: -mem-percent missing or invalid " "percentage: it should be 1 - 75%\n", argv[0]); - exit(1); + sqfscat_option_help(argv[i - 1]); } phys_mem = get_physical_memory(); @@ -4089,10 +4090,10 @@ static int parse_cat_options(int argc, char *argv[]) 1)) { ERROR("%s: %s missing or invalid offset size\n", argv[0], argv[i - 1]); - exit(1); + sqfscat_option_help(argv[i - 1]); } } else - sqfscat_help(TRUE, argv[0]); + sqfscat_invalid_option(argv[i]); } if(strict_errors && ignore_errors) @@ -4108,12 +4109,12 @@ static int parse_cat_options(int argc, char *argv[]) if(i == argc) { if(!version) { ERROR("%s: fatal error: no input filesystem specified on command line\n\n", argv[0]); - sqfscat_help(TRUE, argv[0]); + sqfscat_help(TRUE); } else exit(1); } else if(i + 1 == argc) { ERROR("%s: fatal error: no files specified on command line\n\n", argv[0]); - sqfscat_help(TRUE, argv[0]); + sqfscat_help(TRUE); } return i; @@ -4128,29 +4129,28 @@ static int parse_options(int argc, char *argv[]) if(*argv[i] != '-') break; if(strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) - unsquashfs_help(FALSE, argv[0]); + unsquashfs_help(FALSE); else if(strcmp(argv[i], "-help-all") == 0 || strcmp(argv[i], "-ha") == 0) - unsquashfs_help_all(argv[0]); + unsquashfs_help_all(); else if(strcmp(argv[i], "-help-option") == 0 || strcmp(argv[i], "-ho") == 0) { if(++i == argc) { - ERROR("%s: %s missing regex\n", argv[0], argv[i - 1]); - unsquashfs_option_help(argv[0], argv[i - 1]); + ERROR("unsquashfs: %s missing regex\n", argv[i - 1]); + unsquashfs_option_help(argv[i - 1]); } - unsquashfs_option(argv[0], argv[i - 1], argv[i]); + unsquashfs_option(argv[i - 1], argv[i]); } else if(strcmp(argv[i], "-help-section") == 0 || strcmp(argv[i], "-hs") == 0) { if(++i == argc) { - ERROR("%s: %s missing section\n", argv[0], argv[i - 1]); - unsquashfs_option_help(argv[0], argv[i - 1]); + ERROR("unsquashfs: %s missing section\n", argv[i - 1]); + unsquashfs_option_help(argv[i - 1]); } - unsquashfs_section(argv[0], argv[i - 1], argv[i]); + unsquashfs_section(argv[i - 1], argv[i]); } else if(strcmp(argv[i], "-pseudo-file") == 0 || strcmp(argv[i], "-pf") == 0) { if(++i == argc) { - fprintf(stderr, "%s: -pf missing filename\n", - argv[0]); - unsquashfs_option_help(argv[0], argv[i - 1]); + fprintf(stderr, "unsquashfs: -pf missing filename\n"); + unsquashfs_option_help(argv[i - 1]); } pseudo_name = argv[i]; pseudo_file = TRUE; @@ -4162,9 +4162,9 @@ static int parse_options(int argc, char *argv[]) strcmp(argv[i], "-ex") == 0) { res = parse_excludes(argc - i - 1, argv + i + 1); if(res == 0) { - fprintf(stderr, "%s: -exclude-list missing " - "filenames or no ';' terminator\n", argv[0]); - unsquashfs_option_help(argv[0], "-exclude-list"); + fprintf(stderr, "unsquashfs: -exclude-list missing " + "filenames or no ';' terminator\n"); + unsquashfs_option_help("-exclude-list"); } i += res + 1; } else if(strcmp(argv[i], "-no-exit-code") == 0 || @@ -4219,15 +4219,15 @@ static int parse_options(int argc, char *argv[]) if(xattrs_supported()) no_xattrs = FALSE; else { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("unsquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } } else if(strcmp(argv[i], "-user-xattrs") == 0 || strcmp(argv[i], "-u") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("unsquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } else { xattr_include_preg = xattr_regex("^user.", "include"); @@ -4235,24 +4235,24 @@ static int parse_options(int argc, char *argv[]) } } else if(strcmp(argv[i], "-xattrs-exclude") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("unsquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == argc) { - ERROR("%s: -xattrs-exclude missing regex pattern\n", argv[0]); - unsquashfs_option_help(argv[0], "-xattrs-exclude"); + ERROR("unsquashfs: -xattrs-exclude missing regex pattern\n"); + unsquashfs_option_help("-xattrs-exclude"); } else { xattr_exclude_preg = xattr_regex(argv[i], "exclude"); no_xattrs = FALSE; } } else if(strcmp(argv[i], "-xattrs-include") == 0) { if(!xattrs_supported()) { - ERROR("%s: xattrs are unsupported in " - "this build\n", argv[0]); + ERROR("unsquashfs: xattrs are unsupported in " + "this build\n"); exit(1); } else if(++i == argc) { - ERROR("%s: -xattrs-include missing regex pattern\n", argv[0]); - unsquashfs_option_help(argv[0], "-xattrs-include"); + ERROR("unsquashfs: -xattrs-include missing regex pattern\n"); + unsquashfs_option_help("-xattrs-include"); } else { xattr_include_preg = xattr_regex(argv[i], "include"); no_xattrs = FALSE; @@ -4260,9 +4260,8 @@ static int parse_options(int argc, char *argv[]) } else if(strcmp(argv[i], "-dest") == 0 || strcmp(argv[i], "-d") == 0) { if(++i == argc) { - fprintf(stderr, "%s: -dest missing filename\n", - argv[0]); - unsquashfs_option_help(argv[0], "-dest"); + fprintf(stderr, "unsquashfs: -dest missing filename\n"); + unsquashfs_option_help("-dest"); } dest = argv[i]; } else if(strcmp(argv[i], "-processors") == 0 || @@ -4270,13 +4269,12 @@ static int parse_options(int argc, char *argv[]) if((++i == argc) || !parse_number(argv[i], &processors)) { - ERROR("%s: -processors missing or invalid " - "processor number\n", argv[0]); - unsquashfs_option_help(argv[0], "-processors"); + ERROR("unsquashfs: -processors missing or invalid " + "processor number\n"); + unsquashfs_option_help("-processors"); } if(processors < 1) { - ERROR("%s: -processors should be 1 or larger\n", - argv[0]); + ERROR("unsquashfs: -processors should be 1 or larger\n"); exit(1); } } else if(strcmp(argv[i], "-max-depth") == 0 || @@ -4284,18 +4282,17 @@ static int parse_options(int argc, char *argv[]) if((++i == argc) || !parse_number(argv[i], &max_depth)) { - ERROR("%s: -max-depth missing or invalid " - "levels\n", argv[0]); - unsquashfs_option_help(argv[0], "-max-depth"); + ERROR("unsquashfs: -max-depth missing or invalid " + "levels\n"); + unsquashfs_option_help("-max-depth"); } } else if(strcmp(argv[i], "-mem") == 0) { long long number; if((++i == argc) || !parse_numberll(argv[i], &number, 1)) { - ERROR("%s: -mem missing or invalid mem size\n", - argv[0]); - unsquashfs_option_help(argv[0], "-mem"); + ERROR("unsquashfs: -mem missing or invalid mem size\n"); + unsquashfs_option_help("-mem"); } /* @@ -4303,14 +4300,14 @@ static int parse_options(int argc, char *argv[]) * does not overflow a signed int */ if(number >= (1LL << 51)) { - ERROR("%s: -mem invalid mem size\n", argv[0]); + ERROR("unsquashfs: -mem invalid mem size\n"); exit(1); } number = number / 1048576; if(number < 2) { - ERROR("%s: -mem should be 2 Mbytes or " - "larger\n", argv[0]); + ERROR("unsquashfs: -mem should be 2 Mbytes or " + "larger\n"); exit(1); } data_buffer_size = number / 2; @@ -4326,31 +4323,30 @@ static int parse_options(int argc, char *argv[]) if((++i == argc) || !parse_number_percent(argv[i], &percent) || (percent < 1)) { - ERROR("%s: -mem-percent missing or invalid " - "percentage: it should be 1 - 75%\n", - argv[0]); - unsquashfs_option_help(argv[0], "-mem-percent"); + ERROR("unsquashfs: -mem-percent missing or invalid " + "percentage: it should be 1 - 75%\n"); + unsquashfs_option_help("-mem-percent"); } phys_mem = get_physical_memory(); if(phys_mem == 0) { - ERROR("%s: -mem-percent unable to get physical " - "memory\n", argv[0]); + ERROR("unsquashfs: -mem-percent unable to get physical " + "memory\n"); exit(1); } if(multiply_overflow(phys_mem, percent)) { - ERROR("%s: -mem-percent requested phys mem too " - "large\n", argv[0]); + ERROR("unsquashfs: -mem-percent requested phys mem too " + "large\n"); exit(1); } phys_mem = phys_mem * percent / 100; if(phys_mem < 2) { - ERROR("%s: -mem-percent mem too small, should " - "be 2 Mbytes or larger\n", argv[0]); + ERROR("unsquashfs: -mem-percent mem too small, should " + "be 2 Mbytes or larger\n"); exit(1); } @@ -4361,13 +4357,13 @@ static int parse_options(int argc, char *argv[]) if((++i == argc) || !parse_number(argv[i], &data_buffer_size)) { - ERROR("%s: -data-queue missing or invalid " - "queue size\n", argv[0]); + ERROR("unsquashfs: -data-queue missing or invalid " + "queue size\n"); exit(1); } if(data_buffer_size < 1) { - ERROR("%s: -data-queue should be 1 Mbyte or " - "larger\n", argv[0]); + ERROR("unsquashfs: -data-queue should be 1 Mbyte or " + "larger\n"); exit(1); } } else if(strcmp(argv[i], "-frag-queue") == 0 || @@ -4375,13 +4371,13 @@ static int parse_options(int argc, char *argv[]) if((++i == argc) || !parse_number(argv[i], &fragment_buffer_size)) { - ERROR("%s: -frag-queue missing or invalid " - "queue size\n", argv[0]); + ERROR("unsquashfs: -frag-queue missing or invalid " + "queue size\n"); exit(1); } if(fragment_buffer_size < 1) { - ERROR("%s: -frag-queue should be 1 Mbyte or " - "larger\n", argv[0]); + ERROR("unsquashfs: -frag-queue should be 1 Mbyte or " + "larger\n"); exit(1); } } else if(strcmp(argv[i], "-force") == 0 || @@ -4414,18 +4410,16 @@ static int parse_options(int argc, char *argv[]) strcmp(argv[i], "-ef") == 0 || strcmp(argv[i], "-e") == 0) { if(++i == argc) { - fprintf(stderr, "%s: -extract-file missing filename\n", - argv[0]); - unsquashfs_option_help(argv[0], "-extract-file"); + fprintf(stderr, "unsquashfs: -extract-file missing filename\n"); + unsquashfs_option_help("-extract-file"); } process_extract_files(argv[i]); } else if(strcmp(argv[i], "-exclude-file") == 0 || strcmp(argv[i], "-excf") == 0 || strcmp(argv[i], "-exc") == 0) { if(++i == argc) { - fprintf(stderr, "%s: -exclude-file missing filename\n", - argv[0]); - unsquashfs_option_help(argv[0], "-exclude-file"); + fprintf(stderr, "unsquashfs: -exclude-file missing filename\n"); + unsquashfs_option_help("-exclude-file"); } process_exclude_files(argv[i]); } else if(strcmp(argv[i], "-regex") == 0 || @@ -4436,25 +4430,25 @@ static int parse_options(int argc, char *argv[]) if((++i == argc) || !parse_numberll(argv[i], &start_offset, 1)) { - ERROR("%s: %s missing or invalid offset size\n", - argv[0], argv[i - 1]); - unsquashfs_option_help(argv[0], "-offset"); + ERROR("unsquashfs: %s missing or invalid offset size\n", + argv[i - 1]); + unsquashfs_option_help("-offset"); } } else if(strcmp(argv[i], "-all-time") == 0 || strcmp(argv[i], "-all") == 0) { if((++i == argc) || (!parse_number_unsigned(argv[i], &timeval) && !exec_date(argv[i], &timeval))) { - ERROR("%s: %s missing or invalid time value\n", - argv[0], argv[i - 1]); - unsquashfs_option_help(argv[0], "-all-time"); + ERROR("unsquashfs: %s missing or invalid time value\n", + argv[i - 1]); + unsquashfs_option_help("-all-time"); } time_opt = TRUE; } else if(strcmp(argv[i], "-full-precision") == 0 || strcmp(argv[i], "-full") == 0) full_precision = TRUE; else - unsquashfs_invalid_option(argv[0], argv[i]); + unsquashfs_invalid_option(argv[i]); } if(dest[0] == '\0' && !lsonly) @@ -4503,8 +4497,8 @@ static int parse_options(int argc, char *argv[]) if(i == argc) { if(!version) { - ERROR("%s: fatal error: no input filesystem specified on command line\n\n", argv[0]); - unsquashfs_help(TRUE, argv[0]); + ERROR("unsquashfs: fatal error: no input filesystem specified on command line\n\n"); + unsquashfs_help(TRUE); } else exit(1); } diff --git a/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.c b/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.c index df849f81fd1..19d259c0224 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.c +++ b/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.c @@ -57,7 +57,7 @@ static char *sqfscat_options[]={ "", "", "-version", "-processors", "-mem", "-mem-percent", "-offset", "-ignore-errors", "-strict-errors", "-no-exit-code", "", "", "","-no-wildcards", "-regex", "", "", "", "-help", "-help-option", "-help-section", "-help-all", "-ho", "-hs", - NULL, + "-ha", NULL, }; static char *unsquashfs_args[]={ @@ -73,7 +73,7 @@ static char *unsquashfs_args[]={ static char *sqfscat_args[]={ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "
", "", - "", "
" + "", "
", "" }; static char *unsquashfs_sections[]={ @@ -221,16 +221,24 @@ static char *unsquashfs_text[]={ static char *sqfscat_text[]={ "Runtime options:", "\n", "\t-v[ersion]\t\tprint version, licence and copyright information\n", - "\t-p[rocessors] \tuse processors. By default will use the number of processors available\n", - "\t-mem \t\tuse physical memory for caches. Use K, M or G to specify Kbytes, Mbytes or Gbytes respectively. Default 512 Mbytes\n", + "\t-p[rocessors] \tuse processors. By default will " + "use the number of processors available\n", + "\t-mem \t\tuse physical memory for caches. Use K, M or " + "G to specify Kbytes, Mbytes or Gbytes respectively. Default " + "512 Mbytes\n", "\t-mem-percent \tuse physical memory for caches.\n", - "\t-o[ffset] \tskip at start of FILESYSTEM. Optionally a suffix of K, M or G can be given to specify Kbytes, Mbytes or Gbytes respectively (default 0 bytes).\n", - "\t-ig[nore-errors]\ttreat errors writing files to stdout as non-fatal\n", + "\t-o[ffset] \tskip at start of FILESYSTEM. Optionally " + "a suffix of K, M or G can be given to specify Kbytes, Mbytes " + "or Gbytes respectively (default 0 bytes).\n", + "\t-ig[nore-errors]\ttreat errors writing files to stdout as " + "non-fatal\n", "\t-st[rict-errors]\ttreat all errors as fatal\n", - "\t-no-exit[-code]\t\tdon't set exit code (to nonzero) on non-fatal errors\n", + "\t-no-exit[-code]\t\tdon't set exit code (to nonzero) on non-fatal " + "errors\n", "\n", "Filter options:", "\n", "\t-no-wild[cards]\t\tdo not use wildcard matching in filenames\n", - "\t-r[egex]\t\ttreat filenames as POSIX regular expressions rather than use the default shell wildcard expansion (globbing)\n", + "\t-r[egex]\t\ttreat filenames as POSIX regular expressions rather " + "than use the default shell wildcard expansion (globbing)\n", "\n", "Help options:", "\n", "\t-h[elp]\t\t\tprint help summary information to stdout\n", "\t-help-option \tprint the help information for Sqfscat " @@ -243,18 +251,25 @@ static char *sqfscat_text[]={ "sections to pager (or stdout if not a terminal)\n", "\t-ho \t\tshorthand alternative to -help-option\n", "\t-hs
\t\tshorthand alternative to -help-section\n", + "\t-ha\t\t\tshorthand alternative to -help-all\n", "\n", "Environment:", "\n", "\tPAGER\t\t\tIf set, this is used as the name of the program used to " "display the help text. The value can be a simple command or " "a pathname. The default is /usr/bin/pager\n", "\n", "Exit status:", "\n", " 0\tThe file or files were output to stdout OK.\n", - " 1\tFATAL errors occurred, e.g. filesystem corruption, I/O errors. Sqfscat did not continue and aborted.\n", - " 2\tNon-fatal errors occurred, e.g. not a regular file, or failed to resolve pathname. Sqfscat continued and did not abort.\n", - "\nSee -ignore-errors, -strict-errors and -no-exit-code options for how they affect the exit status.\n", + " 1\tFATAL errors occurred, e.g. filesystem corruption, I/O errors. " + "Sqfscat did not continue and aborted.\n", + " 2\tNon-fatal errors occurred, e.g. not a regular file, or failed to " + "resolve pathname. Sqfscat continued and did not abort.\n", + "\nSee -ignore-errors, -strict-errors and -no-exit-code options for " + "how they affect the exit status.\n", "\n", "See also (extra information elsewhere):", "\n", - "The README for the Squashfs-tools 4.6.1 release describing the new features can be read here https://github.com/plougher/squashfs-tools/blob/master/README-4.6.1\n", - "\nThe Squashfs-tools USAGE guide can be read here https://github.com/plougher/squashfs-tools/blob/master/USAGE-4.6\n", + "The README for the Squashfs-tools 4.6.1 release describing the new " + "features can be read here https://github.com/plougher/" + "squashfs-tools/blob/master/README-4.6.1\n", + "\nThe Squashfs-tools USAGE guide can be read here https://github.com/" + "plougher/squashfs-tools/blob/master/USAGE-4.6\n", NULL, }; @@ -419,7 +434,7 @@ static void handle_invalid_option(char *prog_name, char *opt_name, char **sectio } -static void print_help(int error, char *prog_name, char *syntax, char **sections, char **options_text) +static void print_help(char *prog_name, int error, char *syntax, char **sections, char **options_text) { FILE *stream = error ? stderr : stdout; int cols = get_column_width(); @@ -446,61 +461,73 @@ static void print_option_help(char *prog_name, char *option, char **sections, ch } -void unsquashfs_help_all(char *name) +void unsquashfs_help_all(void) +{ + print_help_all("unsquashfs", UNSQUASHFS_SYNTAX, unsquashfs_text); +} + + +void unsquashfs_section(char *opt_name, char *sec_name) +{ + print_section("unsquashfs", opt_name, sec_name, unsquashfs_sections, unsquashfs_text); +} + + +void unsquashfs_option(char *opt_name, char *pattern) { - print_help_all(name, UNSQUASHFS_SYNTAX, unsquashfs_text); + print_option("unsquashfs", opt_name, pattern, unsquashfs_options, unsquashfs_args, unsquashfs_text); } -void unsquashfs_section(char *prog_name, char *opt_name, char *sec_name) +void unsquashfs_help(int error) { - print_section(prog_name, opt_name, sec_name, unsquashfs_sections, unsquashfs_text); + print_help("unsquashfs", error, UNSQUASHFS_SYNTAX, unsquashfs_sections, unsquashfs_text); } -void unsquashfs_option(char *prog_name, char *opt_name, char *pattern) +void unsquashfs_invalid_option(char *opt_name) { - print_option(prog_name, opt_name, pattern, unsquashfs_options, unsquashfs_args, unsquashfs_text); + handle_invalid_option("unsquashfs", opt_name, unsquashfs_sections, unsquashfs_text); } -void unsquashfs_help(int error, char *prog_name) +void unsquashfs_option_help(char *option) { - print_help(error, prog_name, UNSQUASHFS_SYNTAX, unsquashfs_sections, unsquashfs_text); + print_option_help("unsquashfs", option, unsquashfs_sections, unsquashfs_text); } -void unsquashfs_invalid_option(char *prog_name, char *opt_name) +void sqfscat_help_all(void) { - handle_invalid_option(prog_name, opt_name, unsquashfs_sections, unsquashfs_text); + print_help_all("sqfscat", SQFSCAT_SYNTAX, sqfscat_text); } -void unsquashfs_option_help(char *prog_name, char *option) +void sqfscat_section(char *opt_name, char *sec_name) { - print_option_help(prog_name, option, unsquashfs_sections, unsquashfs_text); + print_section("sqfscat", opt_name, sec_name, sqfscat_sections, sqfscat_text); } -void sqfscat_help_all(char *name) +void sqfscat_option(char *opt_name, char *pattern) { - print_help_all(name, SQFSCAT_SYNTAX, sqfscat_text); + print_option("sqfscat", opt_name, pattern, sqfscat_options, sqfscat_args, sqfscat_text); } -void sqfscat_section(char *prog_name, char *opt_name, char *sec_name) +void sqfscat_help(int error) { - print_section(prog_name, opt_name, sec_name, sqfscat_sections, sqfscat_text); + print_help("sqfscat", error, SQFSCAT_SYNTAX, sqfscat_sections, sqfscat_text); } -void sqfscat_option(char *prog_name, char *opt_name, char *pattern) +void sqfscat_invalid_option(char *opt_name) { - print_option(prog_name, opt_name, pattern, sqfscat_options, sqfscat_args, sqfscat_text); + handle_invalid_option("sqfscat", opt_name, sqfscat_sections, sqfscat_text); } -void sqfscat_help(int error, char *prog_name) +void sqfscat_option_help(char *option) { - print_help(error, prog_name, SQFSCAT_SYNTAX, sqfscat_sections, sqfscat_text); + print_option_help("sqfscat", option, sqfscat_sections, sqfscat_text); } diff --git a/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.h b/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.h index 835db137c02..655f27531ad 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.h +++ b/trunk/tools/mksquashfs_xz/squashfs/unsquashfs_help.h @@ -46,14 +46,16 @@ #define XOPT_STR " (unsupported)" #endif -extern void unsquashfs_help_all(char *name); -extern void unsquashfs_section(char *prog_name, char *opt_name, char *sec_name); -extern void unsquashfs_option(char *prog_name, char *opt_name, char *pattern); -extern void unsquashfs_help(int error, char *prog_name); -extern void unsquashfs_invalid_option(char *prog_name, char *opt_name); -extern void unsquashfs_option_help(char *prog_name, char *option); -extern void sqfscat_help_all(char *name); -extern void sqfscat_option(char *prog_name, char *opt_name, char *pattern); -extern void sqfscat_section(char *prog_name, char *opt_name, char *sec_name); -extern void sqfscat_help(int error, char *prog_name); +extern void unsquashfs_help_all(void); +extern void unsquashfs_section(char *opt_name, char *sec_name); +extern void unsquashfs_option(char *opt_name, char *pattern); +extern void unsquashfs_help(int error); +extern void unsquashfs_invalid_option(char *opt_name); +extern void unsquashfs_option_help(char *option); +extern void sqfscat_help_all(void); +extern void sqfscat_option(char *opt_name, char *pattern); +extern void sqfscat_section(char *opt_name, char *sec_name); +extern void sqfscat_help(int error); +extern void sqfscat_invalid_option(char *opt_name); +extern void sqfscat_option_help(char *option); #endif diff --git a/trunk/tools/mksquashfs_xz/squashfs/xattr.c b/trunk/tools/mksquashfs_xz/squashfs/xattr.c index f18f35cd3a5..ce9f4fb7659 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/xattr.c +++ b/trunk/tools/mksquashfs_xz/squashfs/xattr.c @@ -84,7 +84,6 @@ static int xattr_add_count = 0; /* file system globals from mksquashfs.c */ extern int no_xattrs, noX; -extern long long bytes; extern int fd; extern unsigned int xattr_bytes, total_xattr_bytes; extern regex_t *xattr_exclude_preg; @@ -96,6 +95,7 @@ extern void write_destination(int, long long, long long, void *); extern long long generic_write_table(long long, void *, int, void *, int); extern int mangle(char *, char *, int, int, int, int); extern char *pathname(struct dir_ent *); +extern long long get_and_inc_pos(long long value); /* helper functions and definitions from read_xattrs.c */ extern unsigned int read_xattrs_from_disk(int, struct squashfs_super_block *, int, long long *); @@ -332,7 +332,7 @@ long long write_xattrs() unsigned short c_byte; int i, avail_bytes; char *datap = data_cache; - long long start_bytes = bytes; + long long start_bytes; struct squashfs_xattr_table header = {}; if(xattr_ids == 0) @@ -365,8 +365,8 @@ long long write_xattrs() /* * Write compressed xattr table to file system */ - write_destination(fd, bytes, xattr_bytes, xattr_table); - bytes += xattr_bytes; + start_bytes = get_and_inc_pos(xattr_bytes); + write_destination(fd, start_bytes, xattr_bytes, xattr_table); /* * Swap if necessary the xattr id table diff --git a/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper.c b/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper.c index ba4a0537cb2..448978f5ee0 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper.c +++ b/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper.c @@ -19,7 +19,7 @@ * xz_wrapper.c * * Support for XZ (LZMA2) compression using XZ Utils liblzma - * http://tukaani.org/xz/ + * https://tukaani.org/xz/ */ #include @@ -32,6 +32,21 @@ #include "compressor.h" #include "print_pager.h" +/* + * ARM64 filter was added in liblzma 5.4.0. Keep the build working with + * older versions too. + */ +#ifndef LZMA_FILTER_ARM64 +#define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A) +#endif + +/* + * RISC-V filter was added in liblzma 5.6.0. + */ +#ifndef LZMA_FILTER_RISCV +#define LZMA_FILTER_RISCV LZMA_VLI_C(0x0B) +#endif + static struct bcj bcj[] = { { "x86", LZMA_FILTER_X86, 0 }, { "powerpc", LZMA_FILTER_POWERPC, 0 }, @@ -39,6 +54,8 @@ static struct bcj bcj[] = { { "arm", LZMA_FILTER_ARM, 0 }, { "armthumb", LZMA_FILTER_ARMTHUMB, 0 }, { "sparc", LZMA_FILTER_SPARC, 0 }, + { "arm64", LZMA_FILTER_ARM64, 0 }, + { "riscv", LZMA_FILTER_RISCV, 0 }, { NULL, LZMA_VLI_UNKNOWN, 0 } }; @@ -85,7 +102,7 @@ static int xz_options(char *argv[], int argc) (name[n] == '\0' || name[n] == ',')) { if(bcj[i].selected == 0) { - bcj[i].selected = 1; + bcj[i].selected = 1; filter_count++; } name += name[n] == ',' ? n + 1 : n; @@ -97,8 +114,14 @@ static int xz_options(char *argv[], int argc) "filter\n"); goto failed; } + if(!lzma_filter_encoder_is_supported(bcj[i].id)) { + fprintf(stderr, "xz: -Xbcj %s: This filter " + "is not supported by the liblzma " + "version in use\n", bcj[i].name); + goto failed; + } } - + return 1; } else if(strcmp(argv[0], "-Xdict-size") == 0) { char *b; @@ -145,7 +168,7 @@ static int xz_options(char *argv[], int argc) } return -1; - + failed: return -2; } @@ -189,9 +212,9 @@ static int xz_options_post(int block_size) /* * dictionary_size must be storable in xz header as either * 2^n or as 2^n+2^(n+1) - */ + */ n = ffs(dictionary_size) - 1; - if(dictionary_size != (1 << n) && + if(dictionary_size != (1 << n) && dictionary_size != ((1 << n) + (1 << (n + 1)))) { fprintf(stderr, "xz: -Xdict-size is an unsupported " "value, dict-size must be storable in xz " @@ -288,7 +311,7 @@ static int xz_extract_options(int block_size, void *buffer, int size) /* check passed comp opts struct is of the correct length */ if(size != sizeof(struct comp_opts)) goto failed; - + SQUASHFS_INSWAP_COMP_OPTS(comp_opts); dictionary_size = comp_opts->dictionary_size; @@ -299,7 +322,7 @@ static int xz_extract_options(int block_size, void *buffer, int size) * size should 2^n or 2^n+2^(n+1) */ n = ffs(dictionary_size) - 1; - if(dictionary_size != (1 << n) && + if(dictionary_size != (1 << n) && dictionary_size != ((1 << n) + (1 << (n + 1)))) goto failed; } @@ -343,7 +366,7 @@ static void xz_display_options(void *buffer, int size) * size should 2^n or 2^n+2^(n+1) */ n = ffs(dictionary_size) - 1; - if(dictionary_size != (1 << n) && + if(dictionary_size != (1 << n) && dictionary_size != ((1 << n) + (1 << (n + 1)))) goto failed; @@ -371,7 +394,7 @@ static void xz_display_options(void *buffer, int size) failed: fprintf(stderr, "xz: error reading stored compressor options from " "filesystem!\n"); -} +} /* @@ -452,11 +475,35 @@ static int xz_compress(void *strm, void *dest, void *src, int size, stream->opt.dict_size = stream->dictionary_size; + switch(filter->filter[0].id) { + case LZMA_FILTER_ARMTHUMB: + case LZMA_FILTER_RISCV: + /* 2-byte-aligned instructions */ + stream->opt.lp = 1; + break; + + case LZMA_FILTER_POWERPC: + case LZMA_FILTER_ARM: + case LZMA_FILTER_SPARC: + case LZMA_FILTER_ARM64: + /* 4-byte-aligned instructions */ + stream->opt.lp = 2; + stream->opt.lc = 2; + break; + + case LZMA_FILTER_IA64: + /* 16-byte-aligned instructions */ + stream->opt.pb = 4; + stream->opt.lp = 4; + stream->opt.lc = 0; + break; + } + filter->length = 0; res = lzma_stream_buffer_encode(filter->filter, LZMA_CHECK_CRC32, NULL, src, size, filter->buffer, &filter->length, block_size); - + if(res == LZMA_OK) { if(!selected || selected->length > filter->length) selected = filter; @@ -466,8 +513,8 @@ static int xz_compress(void *strm, void *dest, void *src, int size, if(!selected) /* - * Output buffer overflow. Return out of buffer space - */ + * Output buffer overflow. Return out of buffer space + */ return 0; if(selected->buffer != dest) @@ -509,8 +556,8 @@ static void xz_usage(FILE *stream, int cols) autowrap_print(stream, "\t -Xbcj filter1,filter2,...,filterN\n", cols); autowrap_print(stream, "\t\tCompress using filter1,filter2,...,filterN " "in turn (in addition to no filter), and choose the best " - "compression. Available filters: x86, arm, armthumb, powerpc, " - "sparc, ia64\n", cols); + "compression. Available filters: x86, arm, armthumb, arm64, " + "powerpc, sparc, ia64, riscv\n", cols); autowrap_print(stream, "\t -Xdict-size \n", cols); autowrap_print(stream, "\t\tUse as the XZ dictionary size." " The dictionary size can be specified as a percentage of the " diff --git a/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper_extended.c b/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper_extended.c index b059fe3b85c..07e0af122c2 100644 --- a/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper_extended.c +++ b/trunk/tools/mksquashfs_xz/squashfs/xz_wrapper_extended.c @@ -19,7 +19,7 @@ * xz_wrapper_extended.c * * Support for XZ (LZMA2) compression using XZ Utils liblzma - * http://tukaani.org/xz/ + * https://tukaani.org/xz/ * * This file supports OpenWrt extended XZ compression options. */ @@ -34,6 +34,21 @@ #include "compressor.h" #include "print_pager.h" +/* + * ARM64 filter was added in liblzma 5.4.0. Keep the build working with + * older versions too. + */ +#ifndef LZMA_FILTER_ARM64 +#define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A) +#endif + +/* + * RISC-V filter was added in liblzma 5.6.0. + */ +#ifndef LZMA_FILTER_RISCV +#define LZMA_FILTER_RISCV LZMA_VLI_C(0x0B) +#endif + static struct bcj bcj[] = { { "x86", LZMA_FILTER_X86, 0 }, { "powerpc", LZMA_FILTER_POWERPC, 0 }, @@ -41,6 +56,8 @@ static struct bcj bcj[] = { { "arm", LZMA_FILTER_ARM, 0 }, { "armthumb", LZMA_FILTER_ARMTHUMB, 0 }, { "sparc", LZMA_FILTER_SPARC, 0 }, + { "arm64", LZMA_FILTER_ARM64, 0 }, + { "riscv", LZMA_FILTER_RISCV, 0 }, { NULL, LZMA_VLI_UNKNOWN, 0 } }; @@ -107,6 +124,12 @@ static int xz_options(char *argv[], int argc) "filter\n"); goto failed; } + if(!lzma_filter_encoder_is_supported(bcj[i].id)) { + fprintf(stderr, "xz: -Xbcj %s: This filter " + "is not supported by the liblzma " + "version in use\n", bcj[i].name); + goto failed; + } } return 1; @@ -541,6 +564,30 @@ static int xz_compress(void *strm, void *dest, void *src, int size, stream->opt.dict_size = stream->dictionary_size; + switch(filter->filter[0].id) { + case LZMA_FILTER_ARMTHUMB: + case LZMA_FILTER_RISCV: + /* 2-byte-aligned instructions */ + stream->opt.lp = 1; + break; + + case LZMA_FILTER_POWERPC: + case LZMA_FILTER_ARM: + case LZMA_FILTER_SPARC: + case LZMA_FILTER_ARM64: + /* 4-byte-aligned instructions */ + stream->opt.lp = 2; + stream->opt.lc = 2; + break; + + case LZMA_FILTER_IA64: + /* 16-byte-aligned instructions */ + stream->opt.pb = 4; + stream->opt.lp = 4; + stream->opt.lc = 0; + break; + } + if (lc >= 0) stream->opt.lc = lc; @@ -607,8 +654,8 @@ static void xz_usage(FILE *stream, int cols) autowrap_print(stream, "\t -Xbcj filter1,filter2,...,filterN\n", cols); autowrap_print(stream, "\t\tCompress using filter1,filter2,...,filterN " "in turn (in addition to no filter), and choose the best " - "compression. Available filters: x86, arm, armthumb, powerpc, " - "sparc, ia64\n", cols); + "compression. Available filters: x86, arm, armthumb, arm64, " + "powerpc, sparc, ia64, riscv\n", cols); autowrap_print(stream, "\t -Xdict-size \n", cols); autowrap_print(stream, "\t\tUse as the XZ dictionary size." " The dictionary size can be specified as a percentage of the " diff --git a/trunk/user/dns2tcp/Makefile b/trunk/user/dns2tcp/Makefile index e13e41401ee..b470576f843 100644 --- a/trunk/user/dns2tcp/Makefile +++ b/trunk/user/dns2tcp/Makefile @@ -1,11 +1,11 @@ include $(ROOTDIR)/rules.mk PKG_NAME:=dns2tcp -PKG_VERSION:=1.1.1 +PKG_VERSION:=1.1.2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/zfl9/dns2tcp/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=35251fbe1645601086f21cdbd5a2f75471d812f99ed8017bb05158840456b43c +PKG_HASH:=5e8c6302a1d32c16ae7d4b8e39cd9aad1f2d7e68fe18813e76cb1e48ec5940d2 include $(INCLUDE_DIR)/package.mk diff --git a/trunk/user/frp/Makefile b/trunk/user/frp/Makefile index 470b8914f28..a2f5971dc25 100644 --- a/trunk/user/frp/Makefile +++ b/trunk/user/frp/Makefile @@ -1,5 +1,5 @@ THISDIR := $(shell pwd) -FRP_VER := 0.58.1 +FRP_VER := 0.60.0 FRP_URL_BASE := https://github.com/fatedier/frp/releases/download FRP_NAME := frp_$(FRP_VER)_linux_mipsle diff --git a/trunk/user/frp/frp_0.60.0_linux_mipsle.tar.gz b/trunk/user/frp/frp_0.60.0_linux_mipsle.tar.gz new file mode 100644 index 00000000000..d3c9e577fdf Binary files /dev/null and b/trunk/user/frp/frp_0.60.0_linux_mipsle.tar.gz differ diff --git a/trunk/user/sing-box/Makefile b/trunk/user/sing-box/Makefile index c8cd454a1ba..d16bbfb3617 100644 --- a/trunk/user/sing-box/Makefile +++ b/trunk/user/sing-box/Makefile @@ -1,11 +1,11 @@ include $(ROOTDIR)/rules.mk PKG_NAME:=sing-box -PKG_VERSION:=1.5.3 +PKG_VERSION:=1.10.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/SagerNet/sing-box/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=e050f8a588d92547ba277fc8980af8ede544c345684c20e4b008fbc1b1371fb8 +PKG_HASH:=eb7af91189122bcb748912e205cdddb8b434c69bea67cfbe1a4082a577380814 include $(INCLUDE_DIR)/package.mk diff --git a/trunk/user/v2ray/Makefile b/trunk/user/v2ray/Makefile index 7f294aa6111..eeda8816636 100644 --- a/trunk/user/v2ray/Makefile +++ b/trunk/user/v2ray/Makefile @@ -1,11 +1,11 @@ include $(ROOTDIR)/rules.mk PKG_NAME:=v2ray -PKG_VERSION:=5.17.1 +PKG_VERSION:=5.21.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/v2fly/v2ray-core/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=e6798d1a29f6a52a3c0cc7176803b73e292427bc7858d534d0529a278936b8b0 +PKG_HASH:=880a929caff7b72ef9d3b9a3262cec0dff6566c2481989822a6b27fdaaeed975 PKG_BUILD_DIR:=$(BUILD_DIR)/v2ray-core-$(PKG_VERSION)