Files
haikuports/sys-fs/squashfs_tools/patches/squashfs_tools-4.7.2.patchset
2025-08-20 03:18:33 -03:00

141 lines
3.6 KiB
Plaintext

From 4eefd6ddcde271f0f29777928584227b4f4c9885 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 f894328..37d25c5 100644
--- a/squashfs-tools/Makefile
+++ b/squashfs-tools/Makefile
@@ -268,7 +268,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 65787e2..053a80b 100644
--- a/squashfs-tools/endian_compat.h
+++ b/squashfs-tools/endian_compat.h
@@ -23,8 +23,7 @@
*
* endian_compat.h
*/
-#ifndef linux
-#include <sys/types.h>
+#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 263343c..f02bcb0 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -49,8 +49,10 @@
#include <limits.h>
#include <ctype.h>
-#ifdef __linux__
+#if defined(__linux__)
#include <sys/sysmacros.h>
+#elif defined(__HAIKU__)
+#include "haiku_macros.h"
#endif
#include "squashfs_fs.h"
@@ -5724,8 +5726,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");
}
+#ifdef B_HAIKU_32_BIT
+ ASPRINTF(&recovery_file, "%s/squashfs_recovery_%s_%ld", recovery_pathname,
+ getbase(destination_file), pid);
+#else
ASPRINTF(&recovery_file, "%s/squashfs_recovery_%s_%d", recovery_pathname,
getbase(destination_file), pid);
+#endif
metadata = MALLOC(bytes);
res = read_fs_bytes(fd, sBlk->inode_table_start, bytes, metadata);
if(res == 0) {
diff --git a/squashfs-tools/nprocessors_compat.c b/squashfs-tools/nprocessors_compat.c
index 4aa1282..0ade3d8 100644
--- a/squashfs-tools/nprocessors_compat.c
+++ b/squashfs-tools/nprocessors_compat.c
@@ -23,7 +23,8 @@
static int processors = -1;
-#ifdef __linux__
+#if defined(__linux__)
+
#include <sched.h>
#include <unistd.h>
@@ -41,7 +42,22 @@ int get_nprocessors(void)
else
return processors = sysconf(_SC_NPROCESSORS_ONLN);
}
+
+#elif defined(__HAIKU__)
+
+#include <OS.h>
+
+int get_nprocessors(void)
+{
+ system_info sysinfo;
+ if (get_system_info(&sysinfo) == B_OK)
+ return sysinfo.cpu_count;
+
+ return 1;
+}
+
#else
+
#include <sys/sysctl.h>
#include "error.h"
@@ -67,4 +83,5 @@ int get_nprocessors(void)
return processors;
}
+
#endif
diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
index bde1460..b2fed82 100644
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -44,6 +44,10 @@
#include <sys/sysmacros.h>
#endif
+#ifdef __HAIKU__
+#include "haiku_macros.h"
+#endif
+
#include <sys/types.h>
#include <sys/time.h>
#include <limits.h>
--
2.50.1