tools/squashfs4: bump to 4.6.1

Changelogs:
https://github.com/plougher/squashfs-tools/blob/4.6.1/CHANGES

Removed upstreamed patches:
- 001-Unsquashfs-Add-and-make-some-header-includes-conditi.patch
- 002-Mksquashfs-Make-sysinfo-conditional.patch
- 003-Only-use-available-CPUs.patch
- 004-action-rework-strdupa-with-POSIX-strdup-and-free.patch
- 005-Don-t-use-sigwaitinfo-sigtimedwait-if-not-supported.patch
- 006-Move-sysinfo.h-into-the-linux-only-section-should-fi.patch
- 007-Unsquashfs-fix-compilation-error-for-missing-sysctl..patch
- 100-portability.patch

Signed-off-by: Linhui Liu <liulinhui36@gmail.com>
This commit is contained in:
Linhui Liu 2023-03-31 21:42:09 +08:00 committed by Hauke Mehrtens
parent 3efd49a588
commit f0103c78d8
10 changed files with 4 additions and 506 deletions

View File

@ -8,14 +8,14 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=squashfs4 PKG_NAME:=squashfs4
PKG_CPE_ID:=cpe:/a:phillip_lougher:squashfs PKG_CPE_ID:=cpe:/a:phillip_lougher:squashfs
PKG_VERSION:=4.5.1 PKG_VERSION:=4.6.1
PKG_RELEASE=1 PKG_RELEASE=1
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/plougher/squashfs-tools PKG_SOURCE_URL:=https://github.com/plougher/squashfs-tools
PKG_SOURCE_DATE:=2022-03-17 PKG_SOURCE_DATE:=2023-03-26
PKG_SOURCE_VERSION:=afdd63fc386919b4aa40d573b0a6069414d14317 PKG_SOURCE_VERSION:=d8cb82d9840330f9344ec37b992595b5d7b44184
PKG_MIRROR_HASH:=59c294e00ddfc1f4bda658c7567584ce35fdd479c413ebdb1376981b27737be1 PKG_MIRROR_HASH:=fc625af657ca284d69fbc32e3bb572d0afd566cf816b7c1c1b66dda0a0c2760a
HOST_BUILD_PARALLEL:=1 HOST_BUILD_PARALLEL:=1

View File

@ -1,39 +0,0 @@
From a9119c969af0a5aa961d56978d5dd4f3eb952667 Mon Sep 17 00:00:00 2001
From: Phillip Lougher <phillip@squashfs.org.uk>
Date: Mon, 15 Aug 2022 17:04:43 +0100
Subject: [PATCH 1/1] Unsquashfs: Add and make some header includes conditional
Fixes https://github.com/plougher/squashfs-tools/issues/122
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
squashfs-tools/reader.c | 1 +
squashfs-tools/unsquashfs.c | 5 +++++
2 files changed, 6 insertions(+)
--- a/squashfs-tools/reader.c
+++ b/squashfs-tools/reader.c
@@ -38,6 +38,7 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
+#include <signal.h>
#include "squashfs_fs.h"
#include "mksquashfs.h"
#include "caches-queues-lists.h"
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -32,8 +32,13 @@
#include "stdarg.h"
#include "fnmatch_compat.h"
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#elif defined __FreeBSD__
+#include <sys/sysctl.h>
+#endif
+
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>

View File

@ -1,30 +0,0 @@
From 374e39a786a5acda841056bec26fd0e0c4d40dac Mon Sep 17 00:00:00 2001
From: Phillip Lougher <phillip@squashfs.org.uk>
Date: Mon, 15 Aug 2022 17:09:05 +0100
Subject: [PATCH 1/1] Mksquashfs: Make sysinfo() conditional
Fixes https://github.com/plougher/squashfs-tools/issues/123
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
squashfs-tools/mksquashfs.c | 2 ++
1 file changed, 2 insertions(+)
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -5802,6 +5802,7 @@ static int get_physical_memory()
long long page_size = sysconf(_SC_PAGESIZE);
int phys_mem;
+#ifdef __linux__
if(num_pages == -1 || page_size == -1) {
struct sysinfo sys;
int res = sysinfo(&sys);
@@ -5812,6 +5813,7 @@ static int get_physical_memory()
num_pages = sys.totalram;
page_size = sys.mem_unit;
}
+#endif
phys_mem = num_pages * page_size >> 20;

View File

@ -1,92 +0,0 @@
From bc8e655a420d2f62bb0597947e96dce7b4d3fb36 Mon Sep 17 00:00:00 2001
From: Wessel Dankers <wsl@fruit.je>
Date: Sun, 30 Oct 2022 19:29:28 +0100
Subject: [PATCH] Only use available CPUs
Not all online CPUs may be available for the current process,
especially when CPU affinity is involved. In such cases too many
threads will be created, which will then compete unnecessarily
for CPU time.
Use sched_getaffinity() to determine the correct number of threads
to create.
---
squashfs-tools/mksquashfs.c | 16 ++++++++++++----
squashfs-tools/unsquashfs.c | 13 ++++++++++---
2 files changed, 22 insertions(+), 7 deletions(-)
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -52,7 +52,9 @@
#include <ctype.h>
#include <sys/sysinfo.h>
-#ifndef linux
+#ifdef linux
+#include <sched.h>
+#else
#include <sys/sysctl.h>
#endif
@@ -5079,7 +5081,15 @@ static void initialise_threads(int readq
BAD_ERROR("Failed to set signal mask in intialise_threads\n");
if(processors == -1) {
-#ifndef linux
+#ifdef linux
+ cpu_set_t cpu_set;
+ CPU_ZERO(&cpu_set);
+
+ if(sched_getaffinity(0, sizeof cpu_set, &cpu_set) == -1)
+ processors = sysconf(_SC_NPROCESSORS_ONLN);
+ else
+ processors = CPU_COUNT(&cpu_set);
+#else
int mib[2];
size_t len = sizeof(processors);
@@ -5096,8 +5106,6 @@ static void initialise_threads(int readq
ERROR_EXIT(" Defaulting to 1\n");
processors = 1;
}
-#else
- processors = sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -33,6 +33,7 @@
#include "fnmatch_compat.h"
#ifdef __linux__
+#include <sched.h>
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
#elif defined __FreeBSD__
@@ -2719,7 +2720,15 @@ void initialise_threads(int fragment_buf
}
if(processors == -1) {
-#ifndef linux
+#ifdef linux
+ cpu_set_t cpu_set;
+ CPU_ZERO(&cpu_set);
+
+ if(sched_getaffinity(0, sizeof cpu_set, &cpu_set) == -1)
+ processors = sysconf(_SC_NPROCESSORS_ONLN);
+ else
+ processors = CPU_COUNT(&cpu_set);
+#else
int mib[2];
size_t len = sizeof(processors);
@@ -2735,8 +2744,6 @@ void initialise_threads(int fragment_buf
"Defaulting to 1\n");
processors = 1;
}
-#else
- processors = sysconf(_SC_NPROCESSORS_ONLN);
#endif
}

View File

@ -1,37 +0,0 @@
From 92e628ec0e26cf091d82356e3b74f73bedf4cfc8 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sat, 15 Oct 2022 00:11:20 +0200
Subject: [PATCH] action: rework strdupa with POSIX strdup and free
strdupa is not POSIX and cause compilation error on macos.
Fix this by using strdup and free.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
squashfs-tools/action.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--- a/squashfs-tools/action.c
+++ b/squashfs-tools/action.c
@@ -2415,9 +2415,17 @@ static char *get_start(char *s, int n)
static int subpathname_fn(struct atom *atom, struct action_data *action_data)
{
- return fnmatch(atom->argv[0], get_start(strdupa(action_data->subpath),
- count_components(atom->argv[0])),
- FNM_PATHNAME|FNM_EXTMATCH) == 0;
+ char *s, *tmp;
+ int ret;
+
+ s = tmp = strdup(action_data->subpath);
+ tmp = get_start(tmp, count_components(atom->argv[0]));
+
+ ret = fnmatch(atom->argv[0], tmp, FNM_PATHNAME|FNM_EXTMATCH);
+
+ free(s);
+
+ return ret == 0;
}
/*

View File

@ -1,192 +0,0 @@
From dbe9747b4f09bd2f4d63af06e55c2c3ed35bfca1 Mon Sep 17 00:00:00 2001
From: Phillip Lougher <phillip@squashfs.org.uk>
Date: Tue, 7 Feb 2023 23:09:30 +0000
Subject: [PATCH] Don't use sigwaitinfo()/sigtimedwait() if not supported
If sigwaitinfo() and sigtimedwait() are not supported,
use sigwait() instead.
This will disable the queue/caches dump if ^\ (SIGQUIT)
is hit twice within a second.
But the queue/caches dump is still available if SIGHUP
is sent to the program.
Currently this check is applied to MAC OS X. FreeBSD and
NetBSD appear to have these functions.
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
squashfs-tools/info.c | 25 ++-------------
squashfs-tools/signals.h | 54 ++++++++++++++++++++++++++++++++
squashfs-tools/unsquashfs_info.c | 25 ++-------------
3 files changed, 60 insertions(+), 44 deletions(-)
create mode 100644 squashfs-tools/signals.h
--- a/squashfs-tools/info.c
+++ b/squashfs-tools/info.c
@@ -2,7 +2,7 @@
* Create a squashfs filesystem. This is a highly compressed read only
* filesystem.
*
- * Copyright (c) 2013, 2014, 2019, 2021
+ * Copyright (c) 2013, 2014, 2019, 2021, 2022, 2023
* Phillip Lougher <phillip@squashfs.org.uk>
*
* This program is free software; you can redistribute it and/or
@@ -42,6 +42,7 @@
#include "mksquashfs_error.h"
#include "progressbar.h"
#include "caches-queues-lists.h"
+#include "signals.h"
static int silent = 0;
static struct dir_ent *ent = NULL;
@@ -144,7 +145,6 @@ void dump_state()
void *info_thrd(void *arg)
{
sigset_t sigmask;
- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
int sig, waiting = 0;
sigemptyset(&sigmask);
@@ -152,26 +152,7 @@ void *info_thrd(void *arg)
sigaddset(&sigmask, SIGHUP);
while(1) {
- if(waiting)
- sig = sigtimedwait(&sigmask, NULL, &timespec);
- else
- sig = sigwaitinfo(&sigmask, NULL);
-
- if(sig == -1) {
- switch(errno) {
- case EAGAIN:
- /* interval timed out */
- waiting = 0;
- /* FALLTHROUGH */
- case EINTR:
- /* if waiting, the wait will be longer, but
- that's OK */
- continue;
- default:
- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
- "because %s\n", strerror(errno));
- }
- }
+ sig = wait_for_signal(&sigmask, &waiting);
if(sig == SIGQUIT && !waiting) {
print_filename();
--- /dev/null
+++ b/squashfs-tools/signals.h
@@ -0,0 +1,54 @@
+#ifndef SIGNALS_H
+#define SIGNALS_H
+/*
+ * Create a squashfs filesystem. This is a highly compressed read only
+ * filesystem.
+ *
+ * Copyright (c) 2023
+ * Phillip Lougher <phillip@squashfs.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * signals.h
+ */
+
+static inline int wait_for_signal(sigset_t *sigmask, int *waiting)
+{
+ int sig;
+
+#if defined(__APPLE__) && defined(__MACH__)
+ sigwait(sigmask, &sig);
+ *waiting = 0;
+#else
+ struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
+
+ while(1) {
+ if(*waiting)
+ sig = sigtimedwait(sigmask, NULL, &timespec);
+ else
+ sig = sigwaitinfo(sigmask, NULL);
+
+ if(sig != -1)
+ break;
+
+ if(errno == EAGAIN)
+ *waiting = 0;
+ else if(errno != EINTR)
+ BAD_ERROR("sigtimedwait/sigwaitinfo failed because %s\n", strerror(errno));
+ }
+#endif
+ return sig;
+}
+#endif
--- a/squashfs-tools/unsquashfs_info.c
+++ b/squashfs-tools/unsquashfs_info.c
@@ -2,7 +2,7 @@
* Create a squashfs filesystem. This is a highly compressed read only
* filesystem.
*
- * Copyright (c) 2013, 2021
+ * Copyright (c) 2013, 2021, 2023
* Phillip Lougher <phillip@squashfs.org.uk>
*
* This program is free software; you can redistribute it and/or
@@ -40,6 +40,7 @@
#include "squashfs_fs.h"
#include "unsquashfs.h"
#include "unsquashfs_error.h"
+#include "signals.h"
char *pathname = NULL;
@@ -96,7 +97,6 @@ void dump_state()
void *info_thrd(void *arg)
{
sigset_t sigmask;
- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
int sig, waiting = 0;
sigemptyset(&sigmask);
@@ -104,26 +104,7 @@ void *info_thrd(void *arg)
sigaddset(&sigmask, SIGHUP);
while(1) {
- if(waiting)
- sig = sigtimedwait(&sigmask, NULL, &timespec);
- else
- sig = sigwaitinfo(&sigmask, NULL);
-
- if(sig == -1) {
- switch(errno) {
- case EAGAIN:
- /* interval timed out */
- waiting = 0;
- /* FALLTHROUGH */
- case EINTR:
- /* if waiting, the wait will be longer, but
- that's OK */
- continue;
- default:
- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
- "because %s\n", strerror(errno));
- }
- }
+ sig = wait_for_signal(&sigmask, &waiting);
if(sig == SIGQUIT && !waiting) {
if(pathname)

View File

@ -1,49 +0,0 @@
From b2f6454a2b2517cfba7a24cf02e9bdf3b959c86a Mon Sep 17 00:00:00 2001
From: Tony Butler <spudz76@gmail.com>
Date: Sat, 18 Feb 2023 13:20:48 -0800
Subject: [PATCH] Move sysinfo.h into the linux-only section, should fix build
on MacOS.
All compilers set `__linux__`, but `linux` may not be defined, and usage
was mixed. Use `__linux__` everywhere instead.
Signed-off-by: Tony Butler <spudz76@gmail.com>
---
squashfs-tools/mksquashfs.c | 6 +++---
squashfs-tools/unsquashfs.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -50,9 +50,9 @@
#include <sys/wait.h>
#include <limits.h>
#include <ctype.h>
-#include <sys/sysinfo.h>
-#ifdef linux
+#ifdef __linux__
+#include <sys/sysinfo.h>
#include <sched.h>
#else
#include <sys/sysctl.h>
@@ -5081,7 +5081,7 @@ static void initialise_threads(int readq
BAD_ERROR("Failed to set signal mask in intialise_threads\n");
if(processors == -1) {
-#ifdef linux
+#ifdef __linux__
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -2720,7 +2720,7 @@ void initialise_threads(int fragment_buf
}
if(processors == -1) {
-#ifdef linux
+#ifdef __linux__
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);

View File

@ -1,26 +0,0 @@
From dcf492077ef10ed7550b6e2b38b81318645bbdd5 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 19 Feb 2023 04:36:01 +0100
Subject: [PATCH] Unsquashfs: fix compilation error for missing sysctl.h on
macos
Currently the include of sys/sysctl.h is guarded and done only for
FreeBSD system. Remove this to fix compilation error on macos following
the same pattern done in mksquashfs.c
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
squashfs-tools/unsquashfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -36,7 +36,7 @@
#include <sched.h>
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
-#elif defined __FreeBSD__
+#else
#include <sys/sysctl.h>
#endif

View File

@ -1,37 +0,0 @@
--- a/squashfs-tools/xattr.c
+++ b/squashfs-tools/xattr.c
@@ -115,6 +115,7 @@ int xattr_get_prefix(struct xattr_list *
static int read_xattrs_from_system(char *filename, struct xattr_list **xattrs)
{
+#if defined(linux)
ssize_t size, vsize;
char *xattr_names, *p;
int i;
@@ -227,6 +228,10 @@ failed:
free(xattr_list);
free(xattr_names);
return 0;
+#else
+ *xattrs = NULL;
+ return 0;
+#endif
}
--- a/squashfs-tools/unsquashfs_xattr.c
+++ b/squashfs-tools/unsquashfs_xattr.c
@@ -36,6 +36,7 @@ extern int strict_errors;
int write_xattr(char *pathname, unsigned int xattr)
{
+#if defined(linux)
unsigned int count;
struct xattr_list *xattr_list;
int i;
@@ -147,4 +148,5 @@ int write_xattr(char *pathname, unsigned
free_xattr(xattr_list, count);
return !failed;
+#endif
}