summaryrefslogtreecommitdiff
path: root/target/tools/squashfs/patches/squashfs-bsd.patch
blob: 578b9017f10f4fe33d59c3e3b1280a0a25f970da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
--- squashfs4.0~/squashfs-tools/mksquashfs.c	Sun Apr  5 21:22:24 2009
+++ squashfs4.0/squashfs-tools/mksquashfs.c	Fri Jan  7 20:36:08 2011
@@ -24,6 +24,7 @@
 #define FALSE 0
 #define TRUE 1
 
+#include <sys/param.h>
 #include <pwd.h>
 #include <grp.h>
 #include <time.h>
@@ -3688,23 +3689,9 @@ void initialise_threads()
 	signal(SIGUSR1, sigusr1_handler);
 
 	if(processors == -1) {
-#ifndef linux
-		int mib[2];
-		size_t len = sizeof(processors);
-
-		mib[0] = CTL_HW;
-#ifdef HW_AVAILCPU
-		mib[1] = HW_AVAILCPU;
+#if defined(BSD)
+		processors = 1;
 #else
-		mib[1] = HW_NCPU;
-#endif
-
-		if(sysctl(mib, 2, &processors, &len, NULL, 0) == -1) {
-			ERROR("Failed to get number of available processors.  "
-				"Defaulting to 1\n");
-			processors = 1;
-		}
-#else
 		processors = get_nprocs();
 #endif
 	}
@@ -3974,9 +3961,15 @@ int excluded(struct pathnames *paths, ch
 			int match = use_regex ?
 				regexec(path->name[i].preg, name, (size_t) 0,
 					NULL, 0) == 0 :
+#if defined(BSD)
 				fnmatch(path->name[i].name, name,
+					FNM_PATHNAME|FNM_PERIOD) ==
+					 0;
+#else
+				fnmatch(path->name[i].name, name,
 					FNM_PATHNAME|FNM_PERIOD|FNM_EXTMATCH) ==
 					 0;
+#endif
 
 			if(match && path->name[i].paths == NULL) {
 				/* match on a leaf component, any subdirectories
--- squashfs4.0~/squashfs-tools/mksquashfs.h	Thu Feb 19 18:30:44 2009
+++ squashfs4.0/squashfs-tools/mksquashfs.h	Fri Jan  7 20:40:01 2011
@@ -24,7 +24,9 @@
  *
  */
 
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifndef __BYTE_ORDER
+#error Which endianness? __BYTE_ORDER is not defined.
+#elif __BYTE_ORDER == __BIG_ENDIAN
 #define SQUASHFS_SWAP_SHORTS(s, d, n) swap_le16_num(s, d, n)
 #define SQUASHFS_SWAP_INTS(s, d, n) swap_le32_num(s, d, n)
 #define SQUASHFS_SWAP_LONG_LONGS(s, d, n) swap_le64_num(s, d, n)
@@ -34,11 +36,13 @@
 #define SWAP_LE64(s, d, field)	swap_le64(&((s)->field), &((d)->field))
 #define SWAP_LES16(s, d, field)	swap_le16((unsigned short *) &((s)->field), \
 				(unsigned short *) &((d)->field))
-#else
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
 #define SQUASHFS_MEMCPY(s, d, n)	memcpy(d, s, n)
 #define SQUASHFS_SWAP_SHORTS(s, d, n)	memcpy(d, s, n * sizeof(short))
 #define SQUASHFS_SWAP_INTS(s, d, n)	memcpy(d, s, n * sizeof(int))
 #define SQUASHFS_SWAP_LONG_LONGS(s, d, n) \
 					memcpy(d, s, n * sizeof(long long))
+#else
+#error Which endianness (PDP endian? Worse?)
 #endif
 #endif
--- squashfs4.0~/squashfs-tools/pseudo.c	Sun Apr  5 02:01:34 2009
+++ squashfs4.0/squashfs-tools/pseudo.c	Fri Jan  7 20:35:31 2011
@@ -30,6 +30,11 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <sys/param.h>
+
+#if defined(BSD)
+#include <sys/stat.h>
+#endif
 
 #include "pseudo.h"
 
--- squashfs4.0~/squashfs-tools/read_fs.h	Thu Feb 19 18:28:56 2009
+++ squashfs4.0/squashfs-tools/read_fs.h	Fri Jan  7 20:40:00 2011
@@ -24,7 +24,9 @@
  *
  */
 
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifndef __BYTE_ORDER
+#error Which endianness? __BYTE_ORDER is not defined.
+#elif __BYTE_ORDER == __BIG_ENDIAN
 #define SQUASHFS_SWAP_SHORTS(d, s, n) swap_le16_num(s, d, n)
 #define SQUASHFS_SWAP_INTS(d, s, n) swap_le32_num(s, d, n)
 #define SQUASHFS_SWAP_LONG_LONGS(d, s, n) swap_le64_num(s, d, n)
@@ -34,11 +36,13 @@
 #define SWAP_LE64(d, s, field)	swap_le64(&((s)->field), &((d)->field))
 #define SWAP_LES16(d, s, field)	swap_le16((unsigned short *) &((s)->field), \
 				(unsigned short *) &((d)->field))
-#else
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
 #define SQUASHFS_MEMCPY(d, s, n)	memcpy(d, s, n)
 #define SQUASHFS_SWAP_SHORTS(d, s, n)	memcpy(d, s, n * sizeof(short))
 #define SQUASHFS_SWAP_INTS(d, s, n)	memcpy(d, s, n * sizeof(int))
 #define SQUASHFS_SWAP_LONG_LONGS(d, s, n) \
 					memcpy(d, s, n * sizeof(long long))
+#else
+#error Which endianness (PDP endian? Worse?)
 #endif
 #endif
--- squashfs4.0~/squashfs-tools/squashfs_compat.h	Mon Mar 16 04:27:03 2009
+++ squashfs4.0/squashfs-tools/squashfs_compat.h	Fri Jan  7 20:39:59 2011
@@ -768,12 +768,16 @@ typedef union squashfs_inode_header_2 sq
  * macros used to swap each structure entry, taking into account
  * bitfields and different bitfield placing conventions on differing architectures
  */
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifndef __BYTE_ORDER
+#error Which endianness? __BYTE_ORDER is not defined.
+#elif __BYTE_ORDER == __BIG_ENDIAN
 	/* convert from big endian to little endian */
 #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
-#else
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
 	/* convert from little endian to big endian */ 
 #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)
+#else
+#error Which endianness (PDP endian? Worse?)
 #endif
 
 #define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
--- squashfs4.0~/squashfs-tools/squashfs_swap.h	Fri Feb 20 19:41:56 2009
+++ squashfs4.0/squashfs-tools/squashfs_swap.h	Fri Jan  7 20:39:59 2011
@@ -27,7 +27,9 @@
  * macros to convert each stucture from big endian to little endian
  */
 
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifndef __BYTE_ORDER
+#error Which endianness? __BYTE_ORDER is not defined.
+#elif __BYTE_ORDER == __BIG_ENDIAN
 extern void swap_le16(unsigned short *, unsigned short *);
 extern void swap_le32(unsigned int *, unsigned int *);
 extern void swap_le64(long long *, long long *);
@@ -256,7 +258,7 @@ extern void inswap_le64_num(long long *,
 #define SQUASHFS_INSWAP_SHORTS(s, n) inswap_le16_num(s, n)
 #define SQUASHFS_INSWAP_INTS(s, n) inswap_le32_num(s, n)
 #define SQUASHFS_INSWAP_LONG_LONGS(s, n) inswap_le64_num(s, n)
-#else
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
 #define SQUASHFS_SWAP_SUPER_BLOCK(s, d)	\
 		SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
 #define SQUASHFS_SWAP_DIR_INDEX(s, d) \
@@ -308,5 +310,7 @@ extern void inswap_le64_num(long long *,
 #define SQUASHFS_INSWAP_SHORTS(s, n)
 #define SQUASHFS_INSWAP_INTS(s, n)
 #define SQUASHFS_INSWAP_LONG_LONGS(s, n)
+#else
+#error Which endianness (PDP endian? Worse?)
 #endif
 #endif
--- squashfs4.0~/squashfs-tools/swap.c	Thu Mar 26 04:39:52 2009
+++ squashfs4.0/squashfs-tools/swap.c	Fri Jan  7 20:40:00 2011
@@ -27,7 +27,9 @@
 #include <endian.h>
 #endif
 
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifndef __BYTE_ORDER
+#error Which endianness? __BYTE_ORDER is not defined.
+#elif __BYTE_ORDER == __BIG_ENDIAN
 void swap_le16(unsigned short *src, unsigned short *dest)
 {
 	unsigned char *s = (unsigned char *) src;
@@ -120,4 +122,6 @@ void inswap_le##BITS##_num(TYPE *s, int 
 INSWAP_LE_NUM(16, unsigned short)
 INSWAP_LE_NUM(32, unsigned int)
 INSWAP_LE_NUM(64, long long)
+#elif __BYTE_ORDER != __LITTLE_ENDIAN
+#error Which endianness (PDP endian? Worse?)
 #endif
--- squashfs4.0~/squashfs-tools/unsquashfs.c	Sun Apr  5 21:22:42 2009
+++ squashfs4.0/squashfs-tools/unsquashfs.c	Fri Jan  7 20:35:31 2011
@@ -21,6 +21,8 @@
  * unsquashfs.c
  */
 
+#include <sys/param.h>
+
 #include "unsquashfs.h"
 #include "squashfs_swap.h"
 #include "squashfs_compat.h"
@@ -1193,10 +1195,17 @@ int matches(struct pathnames *paths, cha
 		struct pathname *path = paths->path[n];
 		for(i = 0; i < path->names; i++) {
 			int match = use_regex ?
+#if defined(BSD)
 				regexec(path->name[i].preg, name, (size_t) 0,
 				NULL, 0) == 0 : fnmatch(path->name[i].name,
+				name, FNM_PATHNAME|FNM_PERIOD) ==
+				0;
+#else
+				regexec(path->name[i].preg, name, (size_t) 0,
+				NULL, 0) == 0 : fnmatch(path->name[i].name,
 				name, FNM_PATHNAME|FNM_PERIOD|FNM_EXTMATCH) ==
 				0;
+#endif
 			if(match && path->name[i].paths == NULL)
 				/*
 				 * match on a leaf component, any subdirectories
@@ -1795,21 +1804,7 @@ void initialise_threads(int fragment_buf
 
 	if(processors == -1) {
 #ifndef linux
-		int mib[2];
-		size_t len = sizeof(processors);
-
-		mib[0] = CTL_HW;
-#ifdef HW_AVAILCPU
-		mib[1] = HW_AVAILCPU;
-#else
-		mib[1] = HW_NCPU;
-#endif
-
-		if(sysctl(mib, 2, &processors, &len, NULL, 0) == -1) {
-			ERROR("Failed to get number of available processors.  "
-				"Defaulting to 1\n");
-			processors = 1;
-		}
+		processors = 1;
 #else
 		processors = get_nprocs();
 #endif