1
- From ab99a3f89407d5946a420e7b693a9437bc68ecde Mon Sep 17 00:00:00 2001
1
+ From 4eefd6ddcde271f0f29777928584227b4f4c9885 Mon Sep 17 00:00:00 2001
2
2
From: Oscar Lesta <oscar.lesta@gmail.com>
3
3
Date: Fri, 29 Mar 2024 18:46:59 -0300
4
4
Subject: Initial Haiku patch.
5
5
6
6
Based on original patch by @dshynkev (Dmytro Shynkevych).
7
7
8
8
diff --git a/squashfs-tools/Makefile b/squashfs-tools/Makefile
9
- index 9aa4381..02fa546 100755
9
+ index f894328..37d25c5 100644
10
10
--- a/squashfs-tools/Makefile
11
11
+++ b/squashfs-tools/Makefile
12
- @@ -219 ,7 +219 ,7 @@ CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \
12
+ @@ -268 ,7 +268 ,7 @@ CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \
13
13
-D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \
14
14
-Wall
15
15
@@ -19,14 +19,15 @@ index 9aa4381..02fa546 100755
19
19
CFLAGS += -DGZIP_SUPPORT
20
20
MKSQUASHFS_OBJS += gzip_wrapper.o
21
21
diff --git a/squashfs-tools/endian_compat.h b/squashfs-tools/endian_compat.h
22
- index c416f7f..0aa4815 100644
22
+ index 65787e2..053a80b 100644
23
23
--- a/squashfs-tools/endian_compat.h
24
24
+++ b/squashfs-tools/endian_compat.h
25
- @@ -23,7 +23,7 @@
25
+ @@ -23,8 +23,7 @@
26
26
*
27
27
* endian_compat.h
28
28
*/
29
29
-#ifndef linux
30
+ -#include <sys/types.h>
30
31
+#if !defined(linux) && ! defined(__HAIKU__)
31
32
#define __BYTE_ORDER BYTE_ORDER
32
33
#define __BIG_ENDIAN BIG_ENDIAN
@@ -47,73 +48,93 @@ index 0000000..a643394
47
48
+
48
49
+#endif /* HAIKU_MACROS_H */
49
50
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
50
- index ba28d65..20e2aee 100644
51
+ index 263343c..f02bcb0 100644
51
52
--- a/squashfs-tools/mksquashfs.c
52
53
+++ b/squashfs-tools/mksquashfs.c
53
- @@ -53,6 +53,9 @@
54
- #include <sys/sysinfo.h>
54
+ @@ -49,8 +49,10 @@
55
+ #include <limits.h>
56
+ #include <ctype.h>
57
+
58
+ -#ifdef __linux__
59
+ +#if defined(__linux__)
55
60
#include <sys/sysmacros.h>
56
- #include <sched.h>
57
- +#elif __HAIKU__
58
- +#include <OS.h>
61
+ +#elif defined(__HAIKU__)
59
62
+#include "haiku_macros.h"
60
- #else
61
- #include <sys/sysctl.h>
62
63
#endif
63
- @@ -5257,6 +5260,12 @@ static void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
64
- processors = sysconf(_SC_NPROCESSORS_ONLN);
65
- else
66
- processors = CPU_COUNT(&cpu_set);
67
- +#elif __HAIKU__
68
- + system_info sysinfo;
69
- + if (get_system_info(&sysinfo) == B_OK)
70
- + processors = sysinfo.cpu_count;
71
- + else
72
- + processors = 1;
73
- #else
74
- int mib[2];
75
- size_t len = sizeof(processors);
76
- @@ -5664,8 +5673,13 @@ static void write_recovery_data(struct squashfs_super_block *sBlk)
64
+
65
+ #include "squashfs_fs.h"
66
+ @@ -5724,8 +5726,13 @@ static void write_recovery_data(struct squashfs_super_block *sBlk)
77
67
BAD_ERROR("Could not read $HOME, use -recovery-path or -no-recovery options\n");
78
68
}
79
69
80
- +#if __HAIKU__
81
- + res = asprintf (&recovery_file, "%s/squashfs_recovery_%s_%" B_PRId32 , recovery_pathname,
70
+ +#ifdef B_HAIKU_32_BIT
71
+ + ASPRINTF (&recovery_file, "%s/squashfs_recovery_%s_%ld" , recovery_pathname,
82
72
+ getbase(destination_file), pid);
83
73
+#else
84
- res = asprintf (&recovery_file, "%s/squashfs_recovery_%s_%d", recovery_pathname,
74
+ ASPRINTF (&recovery_file, "%s/squashfs_recovery_%s_%d", recovery_pathname,
85
75
getbase(destination_file), pid);
86
76
+#endif
87
- if(res == -1)
88
- MEM_ERROR();
77
+ metadata = MALLOC(bytes);
78
+ res = read_fs_bytes(fd, sBlk->inode_table_start, bytes, metadata);
79
+ if(res == 0) {
80
+ diff --git a/squashfs-tools/nprocessors_compat.c b/squashfs-tools/nprocessors_compat.c
81
+ index 4aa1282..0ade3d8 100644
82
+ --- a/squashfs-tools/nprocessors_compat.c
83
+ +++ b/squashfs-tools/nprocessors_compat.c
84
+ @@ -23,7 +23,8 @@
89
85
90
- diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
91
- index 0ac6356..227ad52 100644
92
- --- a/squashfs-tools/unsquashfs.c
93
- +++ b/squashfs-tools/unsquashfs.c
94
- @@ -36,6 +36,9 @@
86
+ static int processors = -1;
87
+
88
+ -#ifdef __linux__
89
+ +#if defined(__linux__)
90
+ +
95
91
#include <sched.h>
96
- #include <sys/sysinfo.h>
97
- #include <sys/sysmacros.h>
98
- +#elif __HAIKU__
92
+ #include <unistd.h>
93
+
94
+ @@ -41,7 +42,22 @@ int get_nprocessors(void)
95
+ else
96
+ return processors = sysconf(_SC_NPROCESSORS_ONLN);
97
+ }
98
+ +
99
+ +#elif defined(__HAIKU__)
100
+ +
99
101
+#include <OS.h>
100
- +#include "haiku_macros.h"
102
+ +
103
+ +int get_nprocessors(void)
104
+ +{
105
+ + system_info sysinfo;
106
+ + if (get_system_info(&sysinfo) == B_OK)
107
+ + return sysinfo.cpu_count;
108
+ +
109
+ + return 1;
110
+ +}
111
+ +
101
112
#else
113
+ +
102
114
#include <sys/sysctl.h>
115
+ #include "error.h"
116
+
117
+ @@ -67,4 +83,5 @@ int get_nprocessors(void)
118
+
119
+ return processors;
120
+ }
121
+ +
103
122
#endif
104
- @@ -2775,6 +2778,12 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size, int cat_
105
- processors = sysconf(_SC_NPROCESSORS_ONLN);
106
- else
107
- processors = CPU_COUNT(&cpu_set);
108
- +#elif __HAIKU__
109
- + system_info sysinfo;
110
- + if (get_system_info(&sysinfo) == B_OK)
111
- + processors = sysinfo.cpu_count;
112
- + else
113
- + processors = 1;
114
- #else
115
- int mib[2];
116
- size_t len = sizeof(processors);
123
+ diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
124
+ index bde1460..b2fed82 100644
125
+ --- a/squashfs-tools/unsquashfs.c
126
+ +++ b/squashfs-tools/unsquashfs.c
127
+ @@ -44,6 +44,10 @@
128
+ #include <sys/sysmacros.h>
129
+ #endif
130
+
131
+ +#ifdef __HAIKU__
132
+ +#include "haiku_macros.h"
133
+ +#endif
134
+ +
135
+ #include <sys/types.h>
136
+ #include <sys/time.h>
137
+ #include <limits.h>
117
138
--
118
- 2.43.2
139
+ 2.50.1
119
140
0 commit comments