Files
haikuports/sys-fs/squashfs_tools/patches/squashfs_tools-4.6.1.patchset

120 lines
3.5 KiB
Plaintext

From ab99a3f89407d5946a420e7b693a9437bc68ecde Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
Date: Fri, 29 Mar 2024 18:46:59 -0300
Subject: Initial Haiku patch.
Based on original patch by @dshynkev (Dmytro Shynkevych).
diff --git a/squashfs-tools/Makefile b/squashfs-tools/Makefile
index 9aa4381..02fa546 100755
--- a/squashfs-tools/Makefile
+++ b/squashfs-tools/Makefile
@@ -219,7 +219,7 @@ CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \
-D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \
-Wall
-LIBS = -lpthread -lm
+LIBS = -lpthread -lm -lbsd -lgnu
ifeq ($(GZIP_SUPPORT),1)
CFLAGS += -DGZIP_SUPPORT
MKSQUASHFS_OBJS += gzip_wrapper.o
diff --git a/squashfs-tools/endian_compat.h b/squashfs-tools/endian_compat.h
index c416f7f..0aa4815 100644
--- a/squashfs-tools/endian_compat.h
+++ b/squashfs-tools/endian_compat.h
@@ -23,7 +23,7 @@
*
* endian_compat.h
*/
-#ifndef linux
+#if !defined(linux) && ! defined(__HAIKU__)
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
diff --git a/squashfs-tools/haiku_macros.h b/squashfs-tools/haiku_macros.h
new file mode 100644
index 0000000..a643394
--- /dev/null
+++ b/squashfs-tools/haiku_macros.h
@@ -0,0 +1,9 @@
+#ifndef HAIKU_MACROS_H
+#define HAIKU_MACROS_H
+
+/* Haiku does not provide these */
+#define major(x) ((int)(0x00ff & ((x) >> 8)))
+#define minor(x) ((int)(0xffff00ff & (x)))
+#define makedev(maj,min) ((0xff00 & ((maj)<<8))|(0xffff00ff & (min)))
+
+#endif /* HAIKU_MACROS_H */
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index ba28d65..20e2aee 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -53,6 +53,9 @@
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
#include <sched.h>
+#elif __HAIKU__
+#include <OS.h>
+#include "haiku_macros.h"
#else
#include <sys/sysctl.h>
#endif
@@ -5257,6 +5260,12 @@ static void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
processors = sysconf(_SC_NPROCESSORS_ONLN);
else
processors = CPU_COUNT(&cpu_set);
+#elif __HAIKU__
+ system_info sysinfo;
+ if (get_system_info(&sysinfo) == B_OK)
+ processors = sysinfo.cpu_count;
+ else
+ processors = 1;
#else
int mib[2];
size_t len = sizeof(processors);
@@ -5664,8 +5673,13 @@ static void write_recovery_data(struct squashfs_super_block *sBlk)
BAD_ERROR("Could not read $HOME, use -recovery-path or -no-recovery options\n");
}
+#if __HAIKU__
+ res = asprintf(&recovery_file, "%s/squashfs_recovery_%s_%" B_PRId32, recovery_pathname,
+ getbase(destination_file), pid);
+#else
res = asprintf(&recovery_file, "%s/squashfs_recovery_%s_%d", recovery_pathname,
getbase(destination_file), pid);
+#endif
if(res == -1)
MEM_ERROR();
diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
index 0ac6356..227ad52 100644
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -36,6 +36,9 @@
#include <sched.h>
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#elif __HAIKU__
+#include <OS.h>
+#include "haiku_macros.h"
#else
#include <sys/sysctl.h>
#endif
@@ -2775,6 +2778,12 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size, int cat_
processors = sysconf(_SC_NPROCESSORS_ONLN);
else
processors = CPU_COUNT(&cpu_set);
+#elif __HAIKU__
+ system_info sysinfo;
+ if (get_system_info(&sysinfo) == B_OK)
+ processors = sysinfo.cpu_count;
+ else
+ processors = 1;
#else
int mib[2];
size_t len = sizeof(processors);
--
2.43.2