chromium,chromedriver: 129.0.6668.91 -> 129.0.6668.100
[NixPkgs.git] / pkgs / by-name / sa / sasquatch / darwin.patch
blob657971c5b0abb79bc091067da38ee97691a02962
1 Patch based on commits by Dave Vasilevsky <dave@vasilevsky.ca> and
2 Blake Riley <blake.riley@gmail.com>, squashed into a single patch,
3 with BSD-specific changes omitted.
5 See also https://github.com/plougher/squashfs-tools/pull/69.
7 diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
8 index ea2f604..9c979f8 100644
9 --- a/squashfs-tools/action.c
10 +++ b/squashfs-tools/action.c
11 @@ -39,6 +39,10 @@
12 #include <errno.h>
13 #include <ctype.h>
15 +#ifndef FNM_EXTMATCH /* glibc extension */
16 + #define FNM_EXTMATCH 0
17 +#endif
19 #include "squashfs_fs.h"
20 #include "mksquashfs.h"
21 #include "action.h"
22 @@ -2415,9 +2419,12 @@ static char *get_start(char *s, int n)
24 static int subpathname_fn(struct atom *atom, struct action_data *action_data)
26 - return fnmatch(atom->argv[0], get_start(strdupa(action_data->subpath),
27 + char *path = strdup(action_data->subpath);
28 + int is_match = fnmatch(atom->argv[0], get_start(path,
29 count_components(atom->argv[0])),
30 FNM_PATHNAME|FNM_EXTMATCH) == 0;
31 + free(path);
32 + return is_match;
36 diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
37 index 216b979..eea2ec9 100644
38 --- a/squashfs-tools/info.c
39 +++ b/squashfs-tools/info.c
40 @@ -144,31 +144,22 @@ void dump_state()
41 void *info_thrd(void *arg)
43 sigset_t sigmask;
44 - struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
45 - int sig, waiting = 0;
46 + int sig, err, waiting = 0;
48 sigemptyset(&sigmask);
49 sigaddset(&sigmask, SIGQUIT);
50 sigaddset(&sigmask, SIGHUP);
51 + sigaddset(&sigmask, SIGALRM);
53 while(1) {
54 - if(waiting)
55 - sig = sigtimedwait(&sigmask, NULL, &timespec);
56 - else
57 - sig = sigwaitinfo(&sigmask, NULL);
58 + err = sigwait(&sigmask, &sig);
60 - if(sig == -1) {
61 + if(err == -1) {
62 switch(errno) {
63 - case EAGAIN:
64 - /* interval timed out */
65 - waiting = 0;
66 - /* FALLTHROUGH */
67 case EINTR:
68 - /* if waiting, the wait will be longer, but
69 - that's OK */
70 continue;
71 default:
72 - BAD_ERROR("sigtimedwait/sigwaitinfo failed "
73 + BAD_ERROR("sigwait failed "
74 "because %s\n", strerror(errno));
77 @@ -179,8 +170,12 @@ void *info_thrd(void *arg)
78 /* set one second interval period, if ^\ received
79 within then, dump queue and cache status */
80 waiting = 1;
81 - } else
82 + alarm(1);
83 + } else if (sig == SIGQUIT) {
84 dump_state();
85 + } else if (sig == SIGALRM) {
86 + waiting = 0;
87 + }
91 diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
92 index 843f9f4..ed2c3a6 100644
93 --- a/squashfs-tools/mksquashfs.c
94 +++ b/squashfs-tools/mksquashfs.c
95 @@ -35,7 +35,12 @@
96 #include <stddef.h>
97 #include <sys/types.h>
98 #include <sys/stat.h>
99 +#ifndef linux
100 +#include <sys/sysctl.h>
101 +#else
102 +#include <sys/sysinfo.h>
103 #include <sys/sysmacros.h>
104 +#endif
105 #include <fcntl.h>
106 #include <errno.h>
107 #include <dirent.h>
108 @@ -50,7 +55,10 @@
109 #include <sys/wait.h>
110 #include <limits.h>
111 #include <ctype.h>
112 -#include <sys/sysinfo.h>
114 +#ifndef FNM_EXTMATCH /* glibc extension */
115 + #define FNM_EXTMATCH 0
116 +#endif
118 #ifndef linux
119 #include <sys/sysctl.h>
120 @@ -5064,6 +5072,7 @@ static void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
121 sigemptyset(&sigmask);
122 sigaddset(&sigmask, SIGQUIT);
123 sigaddset(&sigmask, SIGHUP);
124 + sigaddset(&sigmask, SIGALRM);
125 if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) != 0)
126 BAD_ERROR("Failed to set signal mask in intialise_threads\n");
128 @@ -5802,6 +5811,35 @@ static int get_physical_memory()
129 long long page_size = sysconf(_SC_PAGESIZE);
130 int phys_mem;
132 +#ifndef linux
133 + #ifdef HW_MEMSIZE
134 + #define SYSCTL_PHYSMEM HW_MEMSIZE
135 + #elif defined(HW_PHYSMEM64)
136 + #define SYSCTL_PHYSMEM HW_PHYSMEM64
137 + #else
138 + #define SYSCTL_PHYSMEM HW_PHYSMEM
139 + #endif
141 + int mib[2];
142 + uint64_t sysctl_physmem = 0;
143 + size_t sysctl_len = sizeof(sysctl_physmem);
145 + mib[0] = CTL_HW;
146 + mib[1] = SYSCTL_PHYSMEM;
148 + if(sysctl(mib, 2, &sysctl_physmem, &sysctl_len, NULL, 0) == 0) {
149 + /* some systems use 32-bit values, work with what we're given */
150 + if (sysctl_len == 4)
151 + sysctl_physmem = *(uint32_t*)&sysctl_physmem;
152 + phys_mem = sysctl_physmem >> 20;
153 + } else {
154 + ERROR_START("Failed to get amount of available "
155 + "memory.");
156 + ERROR_EXIT(" Defaulting to least viable amount\n");
157 + phys_mem = SQUASHFS_LOWMEM;
159 + #undef SYSCTL_PHYSMEM
160 +#else
161 if(num_pages == -1 || page_size == -1) {
162 struct sysinfo sys;
163 int res = sysinfo(&sys);
164 @@ -5814,6 +5852,7 @@ static int get_physical_memory()
167 phys_mem = num_pages * page_size >> 20;
168 +#endif
170 if(phys_mem < SQUASHFS_LOWMEM)
171 BAD_ERROR("Mksquashfs requires more physical memory than is "
172 diff --git a/squashfs-tools/read_xattrs.c b/squashfs-tools/read_xattrs.c
173 index 2067f80..ca8b7f4 100644
174 --- a/squashfs-tools/read_xattrs.c
175 +++ b/squashfs-tools/read_xattrs.c
176 @@ -31,13 +31,13 @@
177 #include <stdio.h>
178 #include <string.h>
180 +#include <stdlib.h>
182 #include "squashfs_fs.h"
183 #include "squashfs_swap.h"
184 #include "xattr.h"
185 #include "error.h"
187 -#include <stdlib.h>
189 extern int read_fs_bytes(int, long long, long long, void *);
190 extern int read_block(int, long long, long long *, int, void *);
192 diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
193 index d434b42..1208e45 100644
194 --- a/squashfs-tools/unsquashfs.c
195 +++ b/squashfs-tools/unsquashfs.c
196 @@ -32,8 +32,12 @@
197 #include "stdarg.h"
198 #include "fnmatch_compat.h"
200 +#ifndef linux
201 +#include <sys/sysctl.h>
202 +#else
203 #include <sys/sysinfo.h>
204 #include <sys/sysmacros.h>
205 +#endif
206 #include <sys/types.h>
207 #include <sys/time.h>
208 #include <sys/resource.h>
209 @@ -1182,7 +1186,7 @@ int create_inode(char *pathname, struct inode *i)
210 break;
211 case SQUASHFS_SYMLINK_TYPE:
212 case SQUASHFS_LSYMLINK_TYPE: {
213 - struct timespec times[2] = {
214 + struct timeval times[2] = {
215 { i->time, 0 },
216 { i->time, 0 }
218 @@ -1201,8 +1205,7 @@ int create_inode(char *pathname, struct inode *i)
219 goto failed;
222 - res = utimensat(AT_FDCWD, pathname, times,
223 - AT_SYMLINK_NOFOLLOW);
224 + res = lutimes(pathname, times);
225 if(res == -1) {
226 EXIT_UNSQUASH_STRICT("create_inode: failed to"
227 " set time on %s, because %s\n",
228 @@ -2687,6 +2690,7 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size, int cat_
229 sigemptyset(&sigmask);
230 sigaddset(&sigmask, SIGQUIT);
231 sigaddset(&sigmask, SIGHUP);
232 + sigaddset(&sigmask, SIGALRM);
233 if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) != 0)
234 EXIT_UNSQUASH("Failed to set signal mask in initialise_threads\n");
236 diff --git a/squashfs-tools/unsquashfs.h b/squashfs-tools/unsquashfs.h
237 index 1099678..5b6a038 100644
238 --- a/squashfs-tools/unsquashfs.h
239 +++ b/squashfs-tools/unsquashfs.h
240 @@ -46,6 +46,10 @@
241 #include <sys/ioctl.h>
242 #include <sys/time.h>
244 +#ifndef FNM_EXTMATCH /* glibc extension */
245 + #define FNM_EXTMATCH 0
246 +#endif
248 #include "endian_compat.h"
249 #include "squashfs_fs.h"
250 #include "unsquashfs_error.h"
251 diff --git a/squashfs-tools/unsquashfs_info.c b/squashfs-tools/unsquashfs_info.c
252 index e906eaf..f1e68c2 100644
253 --- a/squashfs-tools/unsquashfs_info.c
254 +++ b/squashfs-tools/unsquashfs_info.c
255 @@ -96,31 +96,22 @@ void dump_state()
256 void *info_thrd(void *arg)
258 sigset_t sigmask;
259 - struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
260 - int sig, waiting = 0;
261 + int sig, err, waiting = 0;
263 sigemptyset(&sigmask);
264 sigaddset(&sigmask, SIGQUIT);
265 sigaddset(&sigmask, SIGHUP);
266 + sigaddset(&sigmask, SIGALRM);
268 while(1) {
269 - if(waiting)
270 - sig = sigtimedwait(&sigmask, NULL, &timespec);
271 - else
272 - sig = sigwaitinfo(&sigmask, NULL);
273 + err = sigwait(&sigmask, &sig);
275 - if(sig == -1) {
276 + if(err == -1) {
277 switch(errno) {
278 - case EAGAIN:
279 - /* interval timed out */
280 - waiting = 0;
281 - /* FALLTHROUGH */
282 case EINTR:
283 - /* if waiting, the wait will be longer, but
284 - that's OK */
285 continue;
286 default:
287 - BAD_ERROR("sigtimedwait/sigwaitinfo failed "
288 + BAD_ERROR("sigwait failed "
289 "because %s\n", strerror(errno));
292 @@ -132,8 +123,12 @@ void *info_thrd(void *arg)
293 /* set one second interval period, if ^\ received
294 within then, dump queue and cache status */
295 waiting = 1;
296 - } else
297 + alarm(1);
298 + } else if (sig == SIGQUIT) {
299 dump_state();
300 + } else if (sig == SIGALRM) {
301 + waiting = 0;
306 diff --git a/squashfs-tools/unsquashfs_xattr.c b/squashfs-tools/unsquashfs_xattr.c
307 index 61910e1..73e0090 100644
308 --- a/squashfs-tools/unsquashfs_xattr.c
309 +++ b/squashfs-tools/unsquashfs_xattr.c
310 @@ -27,6 +27,11 @@
312 #include <sys/xattr.h>
314 +#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
315 + #define lsetxattr(path_, name_, val_, sz_, flags_) \
316 + setxattr(path_, name_, val_, sz_, 0, flags_ | XATTR_NOFOLLOW)
317 +#endif
319 #define NOSPACE_MAX 10
321 extern int root_process;
322 diff --git a/squashfs-tools/xattr.c b/squashfs-tools/xattr.c
323 index b1c0089..6d7ed98 100644
324 --- a/squashfs-tools/xattr.c
325 +++ b/squashfs-tools/xattr.c
326 @@ -22,6 +22,14 @@
327 * xattr.c
330 +#ifndef linux
331 +#define __BYTE_ORDER BYTE_ORDER
332 +#define __BIG_ENDIAN BIG_ENDIAN
333 +#define __LITTLE_ENDIAN LITTLE_ENDIAN
334 +#else
335 +#include <endian.h>
336 +#endif
338 #define TRUE 1
339 #define FALSE 0
341 @@ -36,6 +44,13 @@
342 #include <stdlib.h>
343 #include <sys/xattr.h>
345 +#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
346 + #define llistxattr(path_, buf_, sz_) \
347 + listxattr(path_, buf_, sz_, XATTR_NOFOLLOW)
348 + #define lgetxattr(path_, name_, val_, sz_) \
349 + getxattr(path_, name_, val_, sz_, 0, XATTR_NOFOLLOW)
350 +#endif
352 #include "squashfs_fs.h"
353 #include "squashfs_swap.h"
354 #include "mksquashfs.h"
356 2.35.1