tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
squashfs: support darwin
Matthew Bauer
7 years ago
6cd58630
33a418e2
+433
-2
2 changed files
expand all
collapse all
unified
split
pkgs
tools
filesystems
squashfs
darwin.patch
default.nix
+431
pkgs/tools/filesystems/squashfs/darwin.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
2
+
index 4b06ccb..26365e7 100644
3
+
--- a/squashfs-tools/action.c
4
+
+++ b/squashfs-tools/action.c
5
+
@@ -38,6 +38,10 @@
6
+
#include <limits.h>
7
+
#include <errno.h>
8
+
9
+
+#ifndef FNM_EXTMATCH /* glibc extension */
10
+
+ #define FNM_EXTMATCH 0
11
+
+#endif
12
+
+
13
+
#include "squashfs_fs.h"
14
+
#include "mksquashfs.h"
15
+
#include "action.h"
16
+
@@ -2284,9 +2288,12 @@ static char *get_start(char *s, int n)
17
+
18
+
static int subpathname_fn(struct atom *atom, struct action_data *action_data)
19
+
{
20
+
- return fnmatch(atom->argv[0], get_start(strdupa(action_data->subpath),
21
+
+ char *path = strdup(action_data->subpath);
22
+
+ int is_match = fnmatch(atom->argv[0], get_start(path,
23
+
count_components(atom->argv[0])),
24
+
FNM_PATHNAME|FNM_PERIOD|FNM_EXTMATCH) == 0;
25
+
+ free(path);
26
+
+ return is_match;
27
+
}
28
+
29
+
/*
30
+
diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
31
+
index 7968c77..c8e4c52 100644
32
+
--- a/squashfs-tools/info.c
33
+
+++ b/squashfs-tools/info.c
34
+
@@ -134,31 +134,22 @@ void dump_state()
35
+
void *info_thrd(void *arg)
36
+
{
37
+
sigset_t sigmask;
38
+
- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
39
+
- int sig, waiting = 0;
40
+
+ int sig, err, waiting = 0;
41
+
42
+
sigemptyset(&sigmask);
43
+
sigaddset(&sigmask, SIGQUIT);
44
+
sigaddset(&sigmask, SIGHUP);
45
+
+ sigaddset(&sigmask, SIGALRM);
46
+
47
+
while(1) {
48
+
- if(waiting)
49
+
- sig = sigtimedwait(&sigmask, NULL, ×pec);
50
+
- else
51
+
- sig = sigwaitinfo(&sigmask, NULL);
52
+
+ err = sigwait(&sigmask, &sig);
53
+
54
+
- if(sig == -1) {
55
+
+ if(err == -1) {
56
+
switch(errno) {
57
+
- case EAGAIN:
58
+
- /* interval timed out */
59
+
- waiting = 0;
60
+
- /* FALLTHROUGH */
61
+
case EINTR:
62
+
- /* if waiting, the wait will be longer, but
63
+
- that's OK */
64
+
continue;
65
+
default:
66
+
- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
67
+
+ BAD_ERROR("sigwaitfailed "
68
+
"because %s\n", strerror(errno));
69
+
}
70
+
}
71
+
@@ -169,8 +160,12 @@ void *info_thrd(void *arg)
72
+
/* set one second interval period, if ^\ received
73
+
within then, dump queue and cache status */
74
+
waiting = 1;
75
+
- } else
76
+
+ alarm(1);
77
+
+ } else if (sig == SIGQUIT) {
78
+
dump_state();
79
+
+ } else if (sig == SIGALRM) {
80
+
+ waiting = 0;
81
+
+ }
82
+
}
83
+
}
84
+
85
+
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
86
+
index d696a51..c86d1b3 100644
87
+
--- a/squashfs-tools/mksquashfs.c
88
+
+++ b/squashfs-tools/mksquashfs.c
89
+
@@ -50,6 +50,10 @@
90
+
#include <limits.h>
91
+
#include <ctype.h>
92
+
93
+
+#ifndef FNM_EXTMATCH /* glibc extension */
94
+
+ #define FNM_EXTMATCH 0
95
+
+#endif
96
+
+
97
+
#ifndef linux
98
+
#define __BYTE_ORDER BYTE_ORDER
99
+
#define __BIG_ENDIAN BIG_ENDIAN
100
+
@@ -831,13 +835,13 @@ char *subpathname(struct dir_ent *dir_ent)
101
+
}
102
+
103
+
104
+
-inline unsigned int get_inode_no(struct inode_info *inode)
105
+
+static inline unsigned int get_inode_no(struct inode_info *inode)
106
+
{
107
+
return inode->inode_number;
108
+
}
109
+
110
+
111
+
-inline unsigned int get_parent_no(struct dir_info *dir)
112
+
+static inline unsigned int get_parent_no(struct dir_info *dir)
113
+
{
114
+
return dir->depth ? get_inode_no(dir->dir_ent->inode) : inode_no;
115
+
}
116
+
@@ -2030,7 +2034,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
117
+
}
118
+
119
+
120
+
-inline int is_fragment(struct inode_info *inode)
121
+
+static inline int is_fragment(struct inode_info *inode)
122
+
{
123
+
off_t file_size = inode->buf.st_size;
124
+
125
+
@@ -2999,13 +3003,13 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
126
+
}
127
+
128
+
129
+
-inline struct inode_info *lookup_inode(struct stat *buf)
130
+
+static inline struct inode_info *lookup_inode(struct stat *buf)
131
+
{
132
+
return lookup_inode2(buf, 0, 0);
133
+
}
134
+
135
+
136
+
-inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
137
+
+static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
138
+
{
139
+
if (inode->inode_number == 0) {
140
+
inode->inode_number = use_this ? : inode_no ++;
141
+
@@ -3016,7 +3020,7 @@ inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
142
+
}
143
+
144
+
145
+
-inline struct dir_ent *create_dir_entry(char *name, char *source_name,
146
+
+static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
147
+
char *nonstandard_pathname, struct dir_info *dir)
148
+
{
149
+
struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
150
+
@@ -3034,7 +3038,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
151
+
}
152
+
153
+
154
+
-inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
155
+
+static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
156
+
struct inode_info *inode_info)
157
+
{
158
+
struct dir_info *dir = dir_ent->our_dir;
159
+
@@ -3050,7 +3054,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
160
+
}
161
+
162
+
163
+
-inline void add_dir_entry2(char *name, char *source_name,
164
+
+static inline void add_dir_entry2(char *name, char *source_name,
165
+
char *nonstandard_pathname, struct dir_info *sub_dir,
166
+
struct inode_info *inode_info, struct dir_info *dir)
167
+
{
168
+
@@ -3062,7 +3066,7 @@ inline void add_dir_entry2(char *name, char *source_name,
169
+
}
170
+
171
+
172
+
-inline void free_dir_entry(struct dir_ent *dir_ent)
173
+
+static inline void free_dir_entry(struct dir_ent *dir_ent)
174
+
{
175
+
if(dir_ent->name)
176
+
free(dir_ent->name);
177
+
@@ -3083,7 +3087,7 @@ inline void free_dir_entry(struct dir_ent *dir_ent)
178
+
}
179
+
180
+
181
+
-inline void add_excluded(struct dir_info *dir)
182
+
+static inline void add_excluded(struct dir_info *dir)
183
+
{
184
+
dir->excluded ++;
185
+
}
186
+
@@ -4200,6 +4204,7 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
187
+
sigemptyset(&sigmask);
188
+
sigaddset(&sigmask, SIGQUIT);
189
+
sigaddset(&sigmask, SIGHUP);
190
+
+ sigaddset(&sigmask, SIGALRM);
191
+
if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == -1)
192
+
BAD_ERROR("Failed to set signal mask in intialise_threads\n");
193
+
194
+
@@ -4987,6 +4992,36 @@ int parse_num(char *arg, int *res)
195
+
196
+
int get_physical_memory()
197
+
{
198
+
+ int phys_mem;
199
+
+#ifndef linux
200
+
+ #ifdef HW_MEMSIZE
201
+
+ #define SYSCTL_PHYSMEM HW_MEMSIZE
202
+
+ #elif defined(HW_PHYSMEM64)
203
+
+ #define SYSCTL_PHYSMEM HW_PHYSMEM64
204
+
+ #else
205
+
+ #define SYSCTL_PHYSMEM HW_PHYSMEM
206
+
+ #endif
207
+
+
208
+
+ int mib[2];
209
+
+ uint64_t sysctl_physmem = 0;
210
+
+ size_t sysctl_len = sizeof(sysctl_physmem);
211
+
+
212
+
+ mib[0] = CTL_HW;
213
+
+ mib[1] = SYSCTL_PHYSMEM;
214
+
+
215
+
+ if(sysctl(mib, 2, &sysctl_physmem, &sysctl_len, NULL, 0) == 0) {
216
+
+ /* some systems use 32-bit values, work with what we're given */
217
+
+ if (sysctl_len == 4)
218
+
+ sysctl_physmem = *(uint32_t*)&sysctl_physmem;
219
+
+ phys_mem = sysctl_physmem >> 20;
220
+
+ } else {
221
+
+ ERROR_START("Failed to get amount of available "
222
+
+ "memory.");
223
+
+ ERROR_EXIT(" Defaulting to least viable amount\n");
224
+
+ phys_mem = SQUASHFS_LOWMEM;
225
+
+ }
226
+
+ #undef SYSCTL_PHYSMEM
227
+
+#else
228
+
/*
229
+
* Long longs are used here because with PAE, a 32-bit
230
+
* machine can have more than 4GB of physical memory
231
+
@@ -4996,10 +5031,11 @@ int get_physical_memory()
232
+
*/
233
+
long long num_pages = sysconf(_SC_PHYS_PAGES);
234
+
long long page_size = sysconf(_SC_PAGESIZE);
235
+
- int phys_mem = num_pages * page_size >> 20;
236
+
+ phys_mem = num_pages * page_size >> 20;
237
+
238
+
if(num_pages == -1 || page_size == -1)
239
+
return 0;
240
+
+#endif
241
+
242
+
if(phys_mem < SQUASHFS_LOWMEM)
243
+
BAD_ERROR("Mksquashfs requires more physical memory than is "
244
+
diff --git a/squashfs-tools/mksquashfs.h b/squashfs-tools/mksquashfs.h
245
+
index 55708a3..d44d1fd 100644
246
+
--- a/squashfs-tools/mksquashfs.h
247
+
+++ b/squashfs-tools/mksquashfs.h
248
+
@@ -24,6 +24,7 @@
249
+
* mksquashfs.h
250
+
*
251
+
*/
252
+
+#include <pthread.h>
253
+
254
+
struct dir_info {
255
+
char *pathname;
256
+
diff --git a/squashfs-tools/pseudo.c b/squashfs-tools/pseudo.c
257
+
index cb74cf6..fe2b4bc 100644
258
+
--- a/squashfs-tools/pseudo.c
259
+
+++ b/squashfs-tools/pseudo.c
260
+
@@ -30,6 +30,7 @@
261
+
#include <errno.h>
262
+
#include <string.h>
263
+
#include <stdlib.h>
264
+
+#include <sys/stat.h>
265
+
#include <sys/types.h>
266
+
#include <sys/wait.h>
267
+
#include <sys/stat.h>
268
+
diff --git a/squashfs-tools/read_xattrs.c b/squashfs-tools/read_xattrs.c
269
+
index 42106f5..837d3fb 100644
270
+
--- a/squashfs-tools/read_xattrs.c
271
+
+++ b/squashfs-tools/read_xattrs.c
272
+
@@ -39,13 +39,13 @@
273
+
#include <endian.h>
274
+
#endif
275
+
276
+
+#include <stdlib.h>
277
+
+
278
+
#include "squashfs_fs.h"
279
+
#include "squashfs_swap.h"
280
+
#include "xattr.h"
281
+
#include "error.h"
282
+
283
+
-#include <stdlib.h>
284
+
-
285
+
extern int read_fs_bytes(int, long long, int, void *);
286
+
extern int read_block(int, long long, long long *, int, void *);
287
+
288
+
diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
289
+
index f190e96..927e441 100644
290
+
--- a/squashfs-tools/unsquashfs.c
291
+
+++ b/squashfs-tools/unsquashfs.c
292
+
@@ -32,7 +32,12 @@
293
+
#include "stdarg.h"
294
+
#include "fnmatch_compat.h"
295
+
296
+
+#ifndef linux
297
+
+#include <sys/sysctl.h>
298
+
+#else
299
+
#include <sys/sysinfo.h>
300
+
+#endif
301
+
+
302
+
#include <sys/types.h>
303
+
#include <sys/time.h>
304
+
#include <sys/resource.h>
305
+
@@ -2185,6 +2190,7 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size)
306
+
sigemptyset(&sigmask);
307
+
sigaddset(&sigmask, SIGQUIT);
308
+
sigaddset(&sigmask, SIGHUP);
309
+
+ sigaddset(&sigmask, SIGALRM);
310
+
if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == -1)
311
+
EXIT_UNSQUASH("Failed to set signal mask in initialise_threads"
312
+
"\n");
313
+
diff --git a/squashfs-tools/unsquashfs.h b/squashfs-tools/unsquashfs.h
314
+
index 0edbd25..cea9caa 100644
315
+
--- a/squashfs-tools/unsquashfs.h
316
+
+++ b/squashfs-tools/unsquashfs.h
317
+
@@ -46,6 +46,10 @@
318
+
#include <sys/ioctl.h>
319
+
#include <sys/time.h>
320
+
321
+
+#ifndef FNM_EXTMATCH /* glibc extension */
322
+
+ #define FNM_EXTMATCH 0
323
+
+#endif
324
+
+
325
+
#ifndef linux
326
+
#define __BYTE_ORDER BYTE_ORDER
327
+
#define __BIG_ENDIAN BIG_ENDIAN
328
+
diff --git a/squashfs-tools/unsquashfs_info.c b/squashfs-tools/unsquashfs_info.c
329
+
index c8e2b9b..7d4f7af 100644
330
+
--- a/squashfs-tools/unsquashfs_info.c
331
+
+++ b/squashfs-tools/unsquashfs_info.c
332
+
@@ -97,31 +97,22 @@ void dump_state()
333
+
void *info_thrd(void *arg)
334
+
{
335
+
sigset_t sigmask;
336
+
- struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
337
+
- int sig, waiting = 0;
338
+
+ int sig, err, waiting = 0;
339
+
340
+
sigemptyset(&sigmask);
341
+
sigaddset(&sigmask, SIGQUIT);
342
+
sigaddset(&sigmask, SIGHUP);
343
+
+ sigaddset(&sigmask, SIGALRM);
344
+
345
+
while(1) {
346
+
- if(waiting)
347
+
- sig = sigtimedwait(&sigmask, NULL, ×pec);
348
+
- else
349
+
- sig = sigwaitinfo(&sigmask, NULL);
350
+
+ err = sigwait(&sigmask, &sig);
351
+
352
+
- if(sig == -1) {
353
+
+ if(err == -1) {
354
+
switch(errno) {
355
+
- case EAGAIN:
356
+
- /* interval timed out */
357
+
- waiting = 0;
358
+
- /* FALLTHROUGH */
359
+
case EINTR:
360
+
- /* if waiting, the wait will be longer, but
361
+
- that's OK */
362
+
continue;
363
+
default:
364
+
- BAD_ERROR("sigtimedwait/sigwaitinfo failed "
365
+
+ BAD_ERROR("sigwait failed "
366
+
"because %s\n", strerror(errno));
367
+
}
368
+
}
369
+
@@ -133,8 +124,12 @@ void *info_thrd(void *arg)
370
+
/* set one second interval period, if ^\ received
371
+
within then, dump queue and cache status */
372
+
waiting = 1;
373
+
- } else
374
+
+ alarm(1);
375
+
+ } else if (sig == SIGQUIT) {
376
+
dump_state();
377
+
+ } else if (sig == SIGALRM) {
378
+
+ waiting = 0;
379
+
+ }
380
+
}
381
+
}
382
+
383
+
diff --git a/squashfs-tools/unsquashfs_xattr.c b/squashfs-tools/unsquashfs_xattr.c
384
+
index 59f4aae..13f0e35 100644
385
+
--- a/squashfs-tools/unsquashfs_xattr.c
386
+
+++ b/squashfs-tools/unsquashfs_xattr.c
387
+
@@ -27,6 +27,11 @@
388
+
389
+
#include <sys/xattr.h>
390
+
391
+
+#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
392
+
+ #define lsetxattr(path_, name_, val_, sz_, flags_) \
393
+
+ setxattr(path_, name_, val_, sz_, 0, flags_ | XATTR_NOFOLLOW)
394
+
+#endif
395
+
+
396
+
#define NOSPACE_MAX 10
397
+
398
+
extern int root_process;
399
+
diff --git a/squashfs-tools/xattr.c b/squashfs-tools/xattr.c
400
+
index b46550c..5b32eca 100644
401
+
--- a/squashfs-tools/xattr.c
402
+
+++ b/squashfs-tools/xattr.c
403
+
@@ -22,6 +22,14 @@
404
+
* xattr.c
405
+
*/
406
+
407
+
+#ifndef linux
408
+
+#define __BYTE_ORDER BYTE_ORDER
409
+
+#define __BIG_ENDIAN BIG_ENDIAN
410
+
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
411
+
+#else
412
+
+#include <endian.h>
413
+
+#endif
414
+
+
415
+
#define TRUE 1
416
+
#define FALSE 0
417
+
418
+
@@ -36,6 +44,13 @@
419
+
#include <stdlib.h>
420
+
#include <sys/xattr.h>
421
+
422
+
+#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
423
+
+ #define llistxattr(path_, buf_, sz_) \
424
+
+ listxattr(path_, buf_, sz_, XATTR_NOFOLLOW)
425
+
+ #define lgetxattr(path_, name_, val_, sz_) \
426
+
+ getxattr(path_, name_, val_, sz_, 0, XATTR_NOFOLLOW)
427
+
+#endif
428
+
+
429
+
#include "squashfs_fs.h"
430
+
#include "squashfs_swap.h"
431
+
#include "mksquashfs.h"
+2
-2
pkgs/tools/filesystems/squashfs/default.nix
···
22
./0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch
23
./0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch
24
./0003-remove-frag-deflator-thread.patch
25
-
];
26
27
buildInputs = [ zlib xz ]
28
++ stdenv.lib.optional lz4Support lz4;
···
37
meta = {
38
homepage = http://squashfs.sourceforge.net/;
39
description = "Tool for creating and unpacking squashfs filesystems";
40
-
platforms = stdenv.lib.platforms.linux;
41
license = stdenv.lib.licenses.gpl2Plus;
42
maintainers = with stdenv.lib.maintainers; [ ruuda ];
43
};
···
22
./0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch
23
./0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch
24
./0003-remove-frag-deflator-thread.patch
25
+
] ++ stdenv.lib.optional stdenv.isDarwin ./darwin.patch;
26
27
buildInputs = [ zlib xz ]
28
++ stdenv.lib.optional lz4Support lz4;
···
37
meta = {
38
homepage = http://squashfs.sourceforge.net/;
39
description = "Tool for creating and unpacking squashfs filesystems";
40
+
platforms = stdenv.lib.platforms.unix;
41
license = stdenv.lib.licenses.gpl2Plus;
42
maintainers = with stdenv.lib.maintainers; [ ruuda ];
43
};