rev |
line source |
pascal@4702
|
1 --- squashfs-4.0/squashfs-tools/Makefile
|
pascal@4702
|
2 +++ squashfs-4.0/squashfs-tools/Makefile
|
pascal@4702
|
3 @@ -1,40 +1,76 @@
|
pascal@4702
|
4 +#
|
pascal@4702
|
5 +# Building LZMA support
|
pascal@4702
|
6 +# Download LZMA sdk (4.65 used in development, other versions may work),
|
pascal@4702
|
7 +# set LZMA_DIR to unpacked source, and uncomment next line
|
pascal@4702
|
8 +LZMA_SUPPORT = 1
|
pascal@4702
|
9 +LZMA_DIR = ../LZMA/lzma465
|
pascal@4702
|
10 +
|
pascal@4702
|
11 +#Compression default.
|
pascal@4702
|
12 +COMP_DEFAULT = gzip
|
pascal@4702
|
13 +
|
pascal@4702
|
14 +INCLUDEDIR = -I.
|
pascal@4702
|
15 INSTALL_DIR = /usr/local/bin
|
pascal@4702
|
16
|
pascal@4702
|
17 -INCLUDEDIR = .
|
pascal@4702
|
18 +MKSQUASHFS_OBJS = mksquashfs.o read_fs.o sort.o swap.o pseudo.o compressor.o \
|
pascal@4702
|
19 + gzip_wrapper.o
|
pascal@4702
|
20
|
pascal@4702
|
21 -CFLAGS := -I$(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -O2
|
pascal@4702
|
22 +UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \
|
pascal@4702
|
23 + unsquash-4.o swap.o compressor.o gzip_wrapper.o
|
pascal@4702
|
24
|
pascal@4702
|
25 +CFLAGS = $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
|
pascal@4702
|
26 + -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" -O2 -Wall
|
pascal@4702
|
27 +
|
pascal@4702
|
28 +ifdef LZMA_SUPPORT
|
pascal@4702
|
29 +LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \
|
pascal@4702
|
30 + $(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o
|
pascal@4702
|
31 +INCLUDEDIR += -I$(LZMA_DIR)/C
|
pascal@4702
|
32 +CFLAGS += -DLZMA_SUPPORT
|
pascal@4702
|
33 +MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
|
pascal@4702
|
34 +UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
|
pascal@4702
|
35 +endif
|
pascal@4702
|
36 +
|
pascal@4702
|
37 +.PHONY: all
|
pascal@4702
|
38 all: mksquashfs unsquashfs
|
pascal@4702
|
39
|
pascal@4702
|
40 -mksquashfs: mksquashfs.o read_fs.o sort.o swap.o pseudo.o
|
pascal@4702
|
41 - $(CC) mksquashfs.o read_fs.o sort.o swap.o pseudo.o -lz -lpthread -lm -o $@
|
pascal@4702
|
42 +mksquashfs: $(MKSQUASHFS_OBJS)
|
pascal@4702
|
43 + $(CC) $(MKSQUASHFS_OBJS) -lz -lpthread -lm -o $@
|
pascal@4702
|
44
|
pascal@4702
|
45 -mksquashfs.o: mksquashfs.c squashfs_fs.h mksquashfs.h global.h sort.h squashfs_swap.h Makefile
|
pascal@4702
|
46 +mksquashfs.o: mksquashfs.c squashfs_fs.h mksquashfs.h global.h sort.h \
|
pascal@4702
|
47 + squashfs_swap.h
|
pascal@4702
|
48
|
pascal@4702
|
49 -read_fs.o: read_fs.c squashfs_fs.h read_fs.h global.h squashfs_swap.h Makefile
|
pascal@4702
|
50 +read_fs.o: read_fs.c squashfs_fs.h read_fs.h global.h squashfs_swap.h
|
pascal@4702
|
51
|
pascal@4702
|
52 -sort.o: sort.c squashfs_fs.h global.h sort.h Makefile
|
pascal@4702
|
53 +sort.o: sort.c squashfs_fs.h global.h sort.h
|
pascal@4702
|
54
|
pascal@4702
|
55 -swap.o: swap.c Makefile
|
pascal@4702
|
56 +swap.o: swap.c
|
pascal@4702
|
57
|
pascal@4702
|
58 -pseudo.o: pseudo.c pseudo.h Makefile
|
pascal@4702
|
59 +pseudo.o: pseudo.c pseudo.h
|
pascal@4702
|
60
|
pascal@4702
|
61 -unsquashfs: unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o unsquash-4.o swap.o
|
pascal@4702
|
62 - $(CC) unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o unsquash-4.o swap.o -lz -lpthread -lm -o $@
|
pascal@4702
|
63 +compressor.o: compressor.c compressor.h
|
pascal@4702
|
64
|
pascal@4702
|
65 -unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h squashfs_compat.h global.h Makefile
|
pascal@4702
|
66 +unsquashfs: $(UNSQUASHFS_OBJS)
|
pascal@4702
|
67 + $(CC) $(UNSQUASHFS_OBJS) -lz -lpthread -lm -o $@
|
pascal@4702
|
68
|
pascal@4702
|
69 -unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h global.h Makefile
|
pascal@4702
|
70 +unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \
|
pascal@4702
|
71 + squashfs_compat.h global.h
|
pascal@4702
|
72
|
pascal@4702
|
73 -unsquash-2.o: unsquashfs.h unsquash-2.c unsquashfs.h squashfs_fs.h squashfs_compat.h global.h Makefile
|
pascal@4702
|
74 +unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h \
|
pascal@4702
|
75 + global.h
|
pascal@4702
|
76
|
pascal@4702
|
77 -unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h global.h Makefile
|
pascal@4702
|
78 +unsquash-2.o: unsquashfs.h unsquash-2.c unsquashfs.h squashfs_fs.h \
|
pascal@4702
|
79 + squashfs_compat.h global.h
|
pascal@4702
|
80
|
pascal@4702
|
81 -unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h global.h Makefile
|
pascal@4702
|
82 +unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h \
|
pascal@4702
|
83 + global.h
|
pascal@4702
|
84
|
pascal@4702
|
85 +unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \
|
pascal@4702
|
86 + global.h
|
pascal@4702
|
87 +
|
pascal@4702
|
88 +.PHONY: clean
|
pascal@4702
|
89 clean:
|
pascal@4702
|
90 -rm -f *.o mksquashfs unsquashfs
|
pascal@4702
|
91
|
pascal@4702
|
92 +.PHONY: install
|
pascal@4702
|
93 install: mksquashfs unsquashfs
|
pascal@4702
|
94 mkdir -p $(INSTALL_DIR)
|
pascal@4702
|
95 cp mksquashfs $(INSTALL_DIR)
|
pascal@4702
|
96
|
pascal@4702
|
97 --- squashfs-4.0/squashfs-tools/compressor.c Thu Jan 1 01:00:00 1970
|
pascal@4702
|
98 +++ squashfs-4.0/squashfs-tools/compressor.c Sat Aug 29 03:05:34 2009
|
pascal@4702
|
99 @@ -0,0 +1,78 @@
|
pascal@4702
|
100 +/*
|
pascal@4702
|
101 + *
|
pascal@4702
|
102 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
pascal@4702
|
103 + * Phillip Lougher <phillip@lougher.demon.co.uk>
|
pascal@4702
|
104 + *
|
pascal@4702
|
105 + * This program is free software; you can redistribute it and/or
|
pascal@4702
|
106 + * modify it under the terms of the GNU General Public License
|
pascal@4702
|
107 + * as published by the Free Software Foundation; either version 2,
|
pascal@4702
|
108 + * or (at your option) any later version.
|
pascal@4702
|
109 + *
|
pascal@4702
|
110 + * This program is distributed in the hope that it will be useful,
|
pascal@4702
|
111 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
pascal@4702
|
112 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
pascal@4702
|
113 + * GNU General Public License for more details.
|
pascal@4702
|
114 + *
|
pascal@4702
|
115 + * You should have received a copy of the GNU General Public License
|
pascal@4702
|
116 + * along with this program; if not, write to the Free Software
|
pascal@4702
|
117 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
pascal@4702
|
118 + *
|
pascal@4702
|
119 + * compressor.c
|
pascal@4702
|
120 + */
|
pascal@4702
|
121 +
|
pascal@4702
|
122 +#include <stdio.h>
|
pascal@4702
|
123 +#include <string.h>
|
pascal@4702
|
124 +#include "compressor.h"
|
pascal@4702
|
125 +#include "squashfs_fs.h"
|
pascal@4702
|
126 +
|
pascal@4702
|
127 +extern int gzip_compress(void **, char *, char *, int, int, int *);
|
pascal@4702
|
128 +extern int gzip_uncompress(char *, char *, int, int, int *);
|
pascal@4702
|
129 +extern int lzma_compress(void **, char *, char *, int, int, int *);
|
pascal@4702
|
130 +extern int lzma_uncompress(char *, char *, int, int, int *);
|
pascal@4702
|
131 +
|
pascal@4702
|
132 +struct compressor compressor[] = {
|
pascal@4702
|
133 + { gzip_compress, gzip_uncompress, ZLIB_COMPRESSION, "gzip", 1 },
|
pascal@4702
|
134 +#ifdef LZMA_SUPPORT
|
pascal@4702
|
135 + { lzma_compress, lzma_uncompress, LZMA_COMPRESSION, "lzma", 1 },
|
pascal@4702
|
136 +#else
|
pascal@4702
|
137 + { NULL, NULL, LZMA_COMPRESSION, "lzma", 0 },
|
pascal@4702
|
138 +#endif
|
pascal@4702
|
139 + { NULL, NULL , 0, "unknown", 0}
|
pascal@4702
|
140 +};
|
pascal@4702
|
141 +
|
pascal@4702
|
142 +
|
pascal@4702
|
143 +struct compressor *lookup_compressor(char *name)
|
pascal@4702
|
144 +{
|
pascal@4702
|
145 + int i;
|
pascal@4702
|
146 +
|
pascal@4702
|
147 + for(i = 0; compressor[i].id; i++)
|
pascal@4702
|
148 + if(strcmp(compressor[i].name, name) == 0)
|
pascal@4702
|
149 + break;
|
pascal@4702
|
150 +
|
pascal@4702
|
151 + return &compressor[i];
|
pascal@4702
|
152 +}
|
pascal@4702
|
153 +
|
pascal@4702
|
154 +
|
pascal@4702
|
155 +struct compressor *lookup_compressor_id(int id)
|
pascal@4702
|
156 +{
|
pascal@4702
|
157 + int i;
|
pascal@4702
|
158 +
|
pascal@4702
|
159 + for(i = 0; compressor[i].id; i++)
|
pascal@4702
|
160 + if(id == compressor[i].id)
|
pascal@4702
|
161 + break;
|
pascal@4702
|
162 +
|
pascal@4702
|
163 + return &compressor[i];
|
pascal@4702
|
164 +}
|
pascal@4702
|
165 +
|
pascal@4702
|
166 +
|
pascal@4702
|
167 +void display_compressors(char *indent, char *def_comp)
|
pascal@4702
|
168 +{
|
pascal@4702
|
169 + int i;
|
pascal@4702
|
170 +
|
pascal@4702
|
171 + for(i = 0; compressor[i].id; i++)
|
pascal@4702
|
172 + if(compressor[i].supported)
|
pascal@4702
|
173 + fprintf(stderr, "%s\t%s%s\n", indent,
|
pascal@4702
|
174 + compressor[i].name,
|
pascal@4702
|
175 + strcmp(compressor[i].name, def_comp) == 0 ?
|
pascal@4702
|
176 + " (default)" : "");
|
pascal@4702
|
177 +}
|
pascal@4702
|
178
|
pascal@4702
|
179 --- squashfs-4.0/squashfs-tools/compressor.h Thu Jan 1 01:00:00 1970
|
pascal@4702
|
180 +++ squashfs-4.0/squashfs-tools/compressor.h Mon Aug 24 20:28:04 2009
|
pascal@4702
|
181 @@ -0,0 +1,33 @@
|
pascal@4702
|
182 +/*
|
pascal@4702
|
183 + *
|
pascal@4702
|
184 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
pascal@4702
|
185 + * Phillip Lougher <phillip@lougher.demon.co.uk>
|
pascal@4702
|
186 + *
|
pascal@4702
|
187 + * This program is free software; you can redistribute it and/or
|
pascal@4702
|
188 + * modify it under the terms of the GNU General Public License
|
pascal@4702
|
189 + * as published by the Free Software Foundation; either version 2,
|
pascal@4702
|
190 + * or (at your option) any later version.
|
pascal@4702
|
191 + *
|
pascal@4702
|
192 + * This program is distributed in the hope that it will be useful,
|
pascal@4702
|
193 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
pascal@4702
|
194 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
pascal@4702
|
195 + * GNU General Public License for more details.
|
pascal@4702
|
196 + *
|
pascal@4702
|
197 + * You should have received a copy of the GNU General Public License
|
pascal@4702
|
198 + * along with this program; if not, write to the Free Software
|
pascal@4702
|
199 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
pascal@4702
|
200 + *
|
pascal@4702
|
201 + * compressor.h
|
pascal@4702
|
202 + */
|
pascal@4702
|
203 +
|
pascal@4702
|
204 +struct compressor {
|
pascal@4702
|
205 + int (*compress)(void **, char *, char *, int, int, int *);
|
pascal@4702
|
206 + int (*uncompress)(char *, char *, int, int, int *);
|
pascal@4702
|
207 + int id;
|
pascal@4702
|
208 + char *name;
|
pascal@4702
|
209 + int supported;
|
pascal@4702
|
210 +};
|
pascal@4702
|
211 +
|
pascal@4702
|
212 +extern struct compressor *lookup_compressor(char *);
|
pascal@4702
|
213 +extern struct compressor *lookup_compressor_id(int);
|
pascal@4702
|
214 +extern void display_compressors(char *, char *);
|
pascal@4702
|
215
|
pascal@4702
|
216 --- squashfs-4.0/squashfs-tools/gzip_wrapper.c Thu Jan 1 01:00:00 1970
|
pascal@4702
|
217 +++ squashfs-4.0/squashfs-tools/gzip_wrapper.c Fri Aug 7 22:12:53 2009
|
pascal@4702
|
218 @@ -0,0 +1,80 @@
|
pascal@4702
|
219 +/*
|
pascal@4702
|
220 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
pascal@4702
|
221 + * Phillip Lougher <phillip@lougher.demon.co.uk>
|
pascal@4702
|
222 + *
|
pascal@4702
|
223 + * This program is free software; you can redistribute it and/or
|
pascal@4702
|
224 + * modify it under the terms of the GNU General Public License
|
pascal@4702
|
225 + * as published by the Free Software Foundation; either version 2,
|
pascal@4702
|
226 + * or (at your option) any later version.
|
pascal@4702
|
227 + *
|
pascal@4702
|
228 + * This program is distributed in the hope that it will be useful,
|
pascal@4702
|
229 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
pascal@4702
|
230 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
pascal@4702
|
231 + * GNU General Public License for more details.
|
pascal@4702
|
232 + *
|
pascal@4702
|
233 + * You should have received a copy of the GNU General Public License
|
pascal@4702
|
234 + * along with this program; if not, write to the Free Software
|
pascal@4702
|
235 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
pascal@4702
|
236 + *
|
pascal@4702
|
237 + * gzip_wrapper.c
|
pascal@4702
|
238 + */
|
pascal@4702
|
239 +
|
pascal@4702
|
240 +#include <stdlib.h>
|
pascal@4702
|
241 +#include <zlib.h>
|
pascal@4702
|
242 +
|
pascal@4702
|
243 +int gzip_compress(void **strm, char *d, char *s, int size, int block_size,
|
pascal@4702
|
244 + int *error)
|
pascal@4702
|
245 +{
|
pascal@4702
|
246 + int res = 0;
|
pascal@4702
|
247 + z_stream *stream = *strm;
|
pascal@4702
|
248 +
|
pascal@4702
|
249 + if(stream == NULL) {
|
pascal@4702
|
250 + if((stream = *strm = malloc(sizeof(z_stream))) == NULL)
|
pascal@4702
|
251 + goto failed;
|
pascal@4702
|
252 +
|
pascal@4702
|
253 + stream->zalloc = Z_NULL;
|
pascal@4702
|
254 + stream->zfree = Z_NULL;
|
pascal@4702
|
255 + stream->opaque = 0;
|
pascal@4702
|
256 +
|
pascal@4702
|
257 + if((res = deflateInit(stream, 9)) != Z_OK)
|
pascal@4702
|
258 + goto failed;
|
pascal@4702
|
259 + } else if((res = deflateReset(stream)) != Z_OK)
|
pascal@4702
|
260 + goto failed;
|
pascal@4702
|
261 +
|
pascal@4702
|
262 + stream->next_in = (unsigned char *) s;
|
pascal@4702
|
263 + stream->avail_in = size;
|
pascal@4702
|
264 + stream->next_out = (unsigned char *) d;
|
pascal@4702
|
265 + stream->avail_out = block_size;
|
pascal@4702
|
266 +
|
pascal@4702
|
267 + res = deflate(stream, Z_FINISH);
|
pascal@4702
|
268 + if(res == Z_STREAM_END)
|
pascal@4702
|
269 + /*
|
pascal@4702
|
270 + * Success, return the compressed size.
|
pascal@4702
|
271 + */
|
pascal@4702
|
272 + return (int) stream->total_out;
|
pascal@4702
|
273 + if(res == Z_OK)
|
pascal@4702
|
274 + /*
|
pascal@4702
|
275 + * Output buffer overflow. Return out of buffer space
|
pascal@4702
|
276 + */
|
pascal@4702
|
277 + return 0;
|
pascal@4702
|
278 +failed:
|
pascal@4702
|
279 + /*
|
pascal@4702
|
280 + * All other errors return failure, with the compressor
|
pascal@4702
|
281 + * specific error code in *error
|
pascal@4702
|
282 + */
|
pascal@4702
|
283 + *error = res;
|
pascal@4702
|
284 + return -1;
|
pascal@4702
|
285 +}
|
pascal@4702
|
286 +
|
pascal@4702
|
287 +
|
pascal@4702
|
288 +int gzip_uncompress(char *d, char *s, int size, int block_size, int *error)
|
pascal@4702
|
289 +{
|
pascal@4702
|
290 + int res;
|
pascal@4702
|
291 + unsigned long bytes = block_size;
|
pascal@4702
|
292 +
|
pascal@4702
|
293 + res = uncompress((unsigned char *) d, &bytes,
|
pascal@4702
|
294 + (const unsigned char *) s, size);
|
pascal@4702
|
295 +
|
pascal@4702
|
296 + *error = res;
|
pascal@4702
|
297 + return res == Z_OK ? (int) bytes : -1;
|
pascal@4702
|
298 +}
|
pascal@4702
|
299
|
pascal@4702
|
300 --- squashfs-4.0/squashfs-tools/lzma_wrapper.c Thu Jan 1 01:00:00 1970
|
pascal@4702
|
301 +++ squashfs-4.0/squashfs-tools/lzma_wrapper.c Wed Oct 14 05:32:57 2009
|
pascal@4702
|
302 @@ -0,0 +1,93 @@
|
pascal@4702
|
303 +/*
|
pascal@4702
|
304 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
pascal@4702
|
305 + * Phillip Lougher <phillip@lougher.demon.co.uk>
|
pascal@4702
|
306 + *
|
pascal@4702
|
307 + * This program is free software; you can redistribute it and/or
|
pascal@4702
|
308 + * modify it under the terms of the GNU General Public License
|
pascal@4702
|
309 + * as published by the Free Software Foundation; either version 2,
|
pascal@4702
|
310 + * or (at your option) any later version.
|
pascal@4702
|
311 + *
|
pascal@4702
|
312 + * This program is distributed in the hope that it will be useful,
|
pascal@4702
|
313 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
pascal@4702
|
314 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
pascal@4702
|
315 + * GNU General Public License for more details.
|
pascal@4702
|
316 + *
|
pascal@4702
|
317 + * You should have received a copy of the GNU General Public License
|
pascal@4702
|
318 + * along with this program; if not, write to the Free Software
|
pascal@4702
|
319 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
pascal@4702
|
320 + *
|
pascal@4702
|
321 + * lzma_wrapper.c
|
pascal@4702
|
322 + */
|
pascal@4702
|
323 +
|
pascal@4702
|
324 +#include <LzmaLib.h>
|
pascal@4702
|
325 +
|
pascal@4702
|
326 +#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
|
pascal@4702
|
327 +
|
pascal@4702
|
328 +int lzma_compress(void **strm, char *dest, char *src, int size,int block_size,
|
pascal@4702
|
329 + int *error)
|
pascal@4702
|
330 +{
|
pascal@4702
|
331 + unsigned char *d = (unsigned char *) dest, *s = (unsigned char *) src;
|
pascal@4702
|
332 + size_t props_size = LZMA_PROPS_SIZE,
|
pascal@4702
|
333 + outlen = block_size - LZMA_HEADER_SIZE;
|
pascal@4702
|
334 + int res;
|
pascal@4702
|
335 +
|
pascal@4702
|
336 + res = LzmaCompress(d + LZMA_HEADER_SIZE, &outlen, s, size, d,
|
pascal@4702
|
337 + &props_size, 5, block_size, 3, 0, 2, 32, 1);
|
pascal@4702
|
338 +
|
pascal@4702
|
339 + if(res == SZ_ERROR_OUTPUT_EOF) {
|
pascal@4702
|
340 + /*
|
pascal@4702
|
341 + * Output buffer overflow. Return out of buffer space error
|
pascal@4702
|
342 + */
|
pascal@4702
|
343 + return 0;
|
pascal@4702
|
344 + }
|
pascal@4702
|
345 +
|
pascal@4702
|
346 + if(res != SZ_OK) {
|
pascal@4702
|
347 + /*
|
pascal@4702
|
348 + * All other errors return failure, with the compressor
|
pascal@4702
|
349 + * specific error code in *error
|
pascal@4702
|
350 + */
|
pascal@4702
|
351 + *error = res;
|
pascal@4702
|
352 + return -1;
|
pascal@4702
|
353 + }
|
pascal@4702
|
354 +
|
pascal@4702
|
355 + /*
|
pascal@4702
|
356 + * Fill in the 8 byte little endian uncompressed size field in the
|
pascal@4702
|
357 + * LZMA header. 8 bytes is excessively large for squashfs but
|
pascal@4702
|
358 + * this is the standard LZMA header and which is expected by the kernel
|
pascal@4702
|
359 + * code
|
pascal@4702
|
360 + */
|
pascal@4702
|
361 + d[LZMA_PROPS_SIZE] = size & 255;
|
pascal@4702
|
362 + d[LZMA_PROPS_SIZE + 1] = (size >> 8) & 255;
|
pascal@4702
|
363 + d[LZMA_PROPS_SIZE + 2] = (size >> 16) & 255;
|
pascal@4702
|
364 + d[LZMA_PROPS_SIZE + 3] = (size >> 24) & 255;
|
pascal@4702
|
365 + d[LZMA_PROPS_SIZE + 4] = 0;
|
pascal@4702
|
366 + d[LZMA_PROPS_SIZE + 5] = 0;
|
pascal@4702
|
367 + d[LZMA_PROPS_SIZE + 6] = 0;
|
pascal@4702
|
368 + d[LZMA_PROPS_SIZE + 7] = 0;
|
pascal@4702
|
369 +
|
pascal@4702
|
370 + /*
|
pascal@4702
|
371 + * Success, return the compressed size. Outlen returned by the LZMA
|
pascal@4702
|
372 + * compressor does not include the LZMA header space
|
pascal@4702
|
373 + */
|
pascal@4702
|
374 + return outlen + LZMA_HEADER_SIZE;
|
pascal@4702
|
375 +}
|
pascal@4702
|
376 +
|
pascal@4702
|
377 +
|
pascal@4702
|
378 +int lzma_uncompress(char *dest, char *src, int size, int block_size,
|
pascal@4702
|
379 + int *error)
|
pascal@4702
|
380 +{
|
pascal@4702
|
381 + unsigned char *d = (unsigned char *) dest, *s = (unsigned char *) src;
|
pascal@4702
|
382 + size_t outlen, inlen = size - LZMA_HEADER_SIZE;
|
pascal@4702
|
383 + int res;
|
pascal@4702
|
384 +
|
pascal@4702
|
385 + outlen = s[LZMA_PROPS_SIZE] |
|
pascal@4702
|
386 + (s[LZMA_PROPS_SIZE + 1] << 8) |
|
pascal@4702
|
387 + (s[LZMA_PROPS_SIZE + 2] << 16) |
|
pascal@4702
|
388 + (s[LZMA_PROPS_SIZE + 3] << 24);
|
pascal@4702
|
389 +
|
pascal@4702
|
390 + res = LzmaUncompress(d, &outlen, s + LZMA_HEADER_SIZE, &inlen,
|
pascal@4702
|
391 + s, LZMA_PROPS_SIZE);
|
pascal@4702
|
392 +
|
pascal@4702
|
393 + *error = res;
|
pascal@4702
|
394 + return res == SZ_OK ? outlen : -1;
|
pascal@4702
|
395 +}
|
pascal@4702
|
396
|
pascal@4702
|
397 --- squashfs-4.0/squashfs-tools/mksquashfs.c Sun Apr 5 23:22:48 2009
|
pascal@4702
|
398 +++ squashfs-4.0/squashfs-tools/mksquashfs.c Tue Dec 8 19:02:54 2009
|
pascal@4702
|
399 @@ -36,7 +36,6 @@
|
pascal@4702
|
400 #include <errno.h>
|
pascal@4702
|
401 #include <dirent.h>
|
pascal@4702
|
402 #include <string.h>
|
pascal@4702
|
403 -#include <zlib.h>
|
pascal@4702
|
404 #include <stdlib.h>
|
pascal@4702
|
405 #include <signal.h>
|
pascal@4702
|
406 #include <setjmp.h>
|
pascal@4702
|
407 @@ -47,6 +46,7 @@
|
pascal@4702
|
408 #include <math.h>
|
pascal@4702
|
409 #include <regex.h>
|
pascal@4702
|
410 #include <fnmatch.h>
|
pascal@4702
|
411 +#include <sys/wait.h>
|
pascal@4702
|
412
|
pascal@4702
|
413 #ifndef linux
|
pascal@4702
|
414 #define __BYTE_ORDER BYTE_ORDER
|
pascal@4702
|
415 @@ -64,6 +64,7 @@
|
pascal@4702
|
416 #include "global.h"
|
pascal@4702
|
417 #include "sort.h"
|
pascal@4702
|
418 #include "pseudo.h"
|
pascal@4702
|
419 +#include "compressor.h"
|
pascal@4702
|
420
|
pascal@4702
|
421 #ifdef SQUASHFS_TRACE
|
pascal@4702
|
422 #define TRACE(s, args...) do { \
|
pascal@4702
|
423 @@ -245,10 +246,8 @@
|
pascal@4702
|
424 /* list of root directory entries read from original filesystem */
|
pascal@4702
|
425 int old_root_entries = 0;
|
pascal@4702
|
426 struct old_root_entry_info {
|
pascal@4702
|
427 - char name[SQUASHFS_NAME_LEN + 1];
|
pascal@4702
|
428 - squashfs_inode inode;
|
pascal@4702
|
429 - int type;
|
pascal@4702
|
430 - int inode_number;
|
pascal@4702
|
431 + char *name;
|
pascal@4702
|
432 + struct inode_info inode;
|
pascal@4702
|
433 };
|
pascal@4702
|
434 struct old_root_entry_info *old_root_entry;
|
pascal@4702
|
435
|
pascal@4702
|
436 @@ -371,10 +370,15 @@
|
pascal@4702
|
437 int reader_buffer_size;
|
pascal@4702
|
438 int fragment_buffer_size;
|
pascal@4702
|
439
|
pascal@4702
|
440 +/* compression operations structure */
|
pascal@4702
|
441 +static struct compressor *comp;
|
pascal@4702
|
442 +char *comp_name = COMP_DEFAULT;
|
pascal@4702
|
443 +
|
pascal@4702
|
444 char *read_from_disk(long long start, unsigned int avail_bytes);
|
pascal@4702
|
445 void add_old_root_entry(char *name, squashfs_inode inode, int inode_number,
|
pascal@4702
|
446 int type);
|
pascal@4702
|
447 -extern int read_super(int fd, squashfs_super_block *sBlk, char *source);
|
pascal@4702
|
448 +extern struct compressor *read_super(int fd, squashfs_super_block *sBlk,
|
pascal@4702
|
449 + char *source);
|
pascal@4702
|
450 extern long long read_filesystem(char *root_name, int fd,
|
pascal@4702
|
451 squashfs_super_block *sBlk, char **cinode_table, char **data_cache,
|
pascal@4702
|
452 char **cdirectory_table, char **directory_data_cache,
|
pascal@4702
|
453 @@ -831,83 +835,32 @@
|
pascal@4702
|
454 }
|
pascal@4702
|
455
|
pascal@4702
|
456
|
pascal@4702
|
457 -unsigned int mangle2(z_stream **strm, char *d, char *s, int size,
|
pascal@4702
|
458 +int mangle2(void **strm, char *d, char *s, int size,
|
pascal@4702
|
459 int block_size, int uncompressed, int data_block)
|
pascal@4702
|
460 {
|
pascal@4702
|
461 - unsigned long c_byte;
|
pascal@4702
|
462 - unsigned int res;
|
pascal@4702
|
463 - z_stream *stream = *strm;
|
pascal@4702
|
464 + int error, c_byte = 0;
|
pascal@4702
|
465
|
pascal@4702
|
466 - if(uncompressed)
|
pascal@4702
|
467 - goto notcompressed;
|
pascal@4702
|
468 -
|
pascal@4702
|
469 - if(stream == NULL) {
|
pascal@4702
|
470 - if((stream = *strm = malloc(sizeof(z_stream))) == NULL)
|
pascal@4702
|
471 - BAD_ERROR("mangle::compress failed, not enough "
|
pascal@4702
|
472 - "memory\n");
|
pascal@4702
|
473 -
|
pascal@4702
|
474 - stream->zalloc = Z_NULL;
|
pascal@4702
|
475 - stream->zfree = Z_NULL;
|
pascal@4702
|
476 - stream->opaque = 0;
|
pascal@4702
|
477 -
|
pascal@4702
|
478 - if((res = deflateInit(stream, 9)) != Z_OK) {
|
pascal@4702
|
479 - if(res == Z_MEM_ERROR)
|
pascal@4702
|
480 - BAD_ERROR("zlib::compress failed, not enough "
|
pascal@4702
|
481 - "memory\n");
|
pascal@4702
|
482 - else if(res == Z_STREAM_ERROR)
|
pascal@4702
|
483 - BAD_ERROR("zlib::compress failed, not a valid "
|
pascal@4702
|
484 - "compression level\n");
|
pascal@4702
|
485 - else if(res == Z_VERSION_ERROR)
|
pascal@4702
|
486 - BAD_ERROR("zlib::compress failed, incorrect "
|
pascal@4702
|
487 - "zlib version\n");
|
pascal@4702
|
488 - else
|
pascal@4702
|
489 - BAD_ERROR("zlib::compress failed, unknown "
|
pascal@4702
|
490 - "error %d\n", res);
|
pascal@4702
|
491 - }
|
pascal@4702
|
492 - } else if((res = deflateReset(stream)) != Z_OK) {
|
pascal@4702
|
493 - if(res == Z_STREAM_ERROR)
|
pascal@4702
|
494 - BAD_ERROR("zlib::compress failed, stream state "
|
pascal@4702
|
495 - "inconsistent\n");
|
pascal@4702
|
496 - else
|
pascal@4702
|
497 - BAD_ERROR("zlib::compress failed, unknown error %d\n",
|
pascal@4702
|
498 - res);
|
pascal@4702
|
499 + if(!uncompressed) {
|
pascal@4702
|
500 + c_byte = comp->compress(strm, d, s, size, block_size, &error);
|
pascal@4702
|
501 + if(c_byte == -1)
|
pascal@4702
|
502 + BAD_ERROR("mangle2:: %s compress failed with error "
|
pascal@4702
|
503 + "code %d\n", comp->name, error);
|
pascal@4702
|
504 }
|
pascal@4702
|
505
|
pascal@4702
|
506 - stream->next_in = (unsigned char *) s;
|
pascal@4702
|
507 - stream->avail_in = size;
|
pascal@4702
|
508 - stream->next_out = (unsigned char *) d;
|
pascal@4702
|
509 - stream->avail_out = block_size;
|
pascal@4702
|
510 -
|
pascal@4702
|
511 - res = deflate(stream, Z_FINISH);
|
pascal@4702
|
512 - if(res != Z_STREAM_END && res != Z_OK) {
|
pascal@4702
|
513 - if(res == Z_STREAM_ERROR)
|
pascal@4702
|
514 - BAD_ERROR("zlib::compress failed, stream state "
|
pascal@4702
|
515 - "inconsistent\n");
|
pascal@4702
|
516 - else if(res == Z_BUF_ERROR)
|
pascal@4702
|
517 - BAD_ERROR("zlib::compress failed, no progress possible"
|
pascal@4702
|
518 - "\n");
|
pascal@4702
|
519 - else
|
pascal@4702
|
520 - BAD_ERROR("zlib::compress failed, unknown error %d\n",
|
pascal@4702
|
521 - res);
|
pascal@4702
|
522 - }
|
pascal@4702
|
523 -
|
pascal@4702
|
524 - c_byte = stream->total_out;
|
pascal@4702
|
525 -
|
pascal@4702
|
526 - if(res != Z_STREAM_END || c_byte >= size) {
|
pascal@4702
|
527 -notcompressed:
|
pascal@4702
|
528 + if(c_byte == 0 || c_byte >= size) {
|
pascal@4702
|
529 memcpy(d, s, size);
|
pascal@4702
|
530 return size | (data_block ? SQUASHFS_COMPRESSED_BIT_BLOCK :
|
pascal@4702
|
531 SQUASHFS_COMPRESSED_BIT);
|
pascal@4702
|
532 }
|
pascal@4702
|
533
|
pascal@4702
|
534 - return (unsigned int) c_byte;
|
pascal@4702
|
535 + return c_byte;
|
pascal@4702
|
536 }
|
pascal@4702
|
537
|
pascal@4702
|
538
|
pascal@4702
|
539 -unsigned int mangle(char *d, char *s, int size, int block_size,
|
pascal@4702
|
540 +int mangle(char *d, char *s, int size, int block_size,
|
pascal@4702
|
541 int uncompressed, int data_block)
|
pascal@4702
|
542 {
|
pascal@4702
|
543 - static z_stream *stream = NULL;
|
pascal@4702
|
544 + static void *stream = NULL;
|
pascal@4702
|
545
|
pascal@4702
|
546 return mangle2(&stream, d, s, size, block_size, uncompressed,
|
pascal@4702
|
547 data_block);
|
pascal@4702
|
548 @@ -1660,8 +1613,7 @@
|
pascal@4702
|
549 pthread_mutex_unlock(&fragment_mutex);
|
pascal@4702
|
550
|
pascal@4702
|
551 if(SQUASHFS_COMPRESSED_BLOCK(disk_fragment->size)) {
|
pascal@4702
|
552 - int res;
|
pascal@4702
|
553 - unsigned long bytes = block_size;
|
pascal@4702
|
554 + int error, res;
|
pascal@4702
|
555 char *data;
|
pascal@4702
|
556
|
pascal@4702
|
557 if(compressed_buffer)
|
pascal@4702
|
558 @@ -1669,19 +1621,11 @@
|
pascal@4702
|
559 else
|
pascal@4702
|
560 data = read_from_disk(start_block, size);
|
pascal@4702
|
561
|
pascal@4702
|
562 - res = uncompress((unsigned char *) buffer->data, &bytes,
|
pascal@4702
|
563 - (const unsigned char *) data, size);
|
pascal@4702
|
564 - if(res != Z_OK) {
|
pascal@4702
|
565 - if(res == Z_MEM_ERROR)
|
pascal@4702
|
566 - BAD_ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
567 - "memory\n");
|
pascal@4702
|
568 - else if(res == Z_BUF_ERROR)
|
pascal@4702
|
569 - BAD_ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
570 - "room in output buffer\n");
|
pascal@4702
|
571 - else
|
pascal@4702
|
572 - BAD_ERROR("zlib::uncompress failed,"
|
pascal@4702
|
573 - " unknown error %d\n", res);
|
pascal@4702
|
574 - }
|
pascal@4702
|
575 + res = comp->uncompress(buffer->data, data, size, block_size,
|
pascal@4702
|
576 + &error);
|
pascal@4702
|
577 + if(res == -1)
|
pascal@4702
|
578 + BAD_ERROR("%s uncompress failed with error code %d\n",
|
pascal@4702
|
579 + comp->name, error);
|
pascal@4702
|
580 } else if(compressed_buffer)
|
pascal@4702
|
581 memcpy(buffer->data, compressed_buffer->data, size);
|
pascal@4702
|
582 else
|
pascal@4702
|
583 @@ -1733,9 +1677,7 @@
|
pascal@4702
|
584 entry->buffer->block = bytes;
|
pascal@4702
|
585 bytes += compressed_size;
|
pascal@4702
|
586 fragments_outstanding --;
|
pascal@4702
|
587 - pthread_mutex_unlock(&fragment_mutex);
|
pascal@4702
|
588 queue_put(to_writer, entry->buffer);
|
pascal@4702
|
589 - pthread_mutex_lock(&fragment_mutex);
|
pascal@4702
|
590 TRACE("fragment_locked writing fragment %d, compressed size %d"
|
pascal@4702
|
591 "\n", entry->fragment, compressed_size);
|
pascal@4702
|
592 free(entry);
|
pascal@4702
|
593 @@ -1758,6 +1700,8 @@
|
pascal@4702
|
594 pthread_mutex_lock(&fragment_mutex);
|
pascal@4702
|
595 insert_fragment_list(&frag_locked_list, entry);
|
pascal@4702
|
596 pthread_mutex_unlock(&fragment_mutex);
|
pascal@4702
|
597 +
|
pascal@4702
|
598 + return TRUE;
|
pascal@4702
|
599 }
|
pascal@4702
|
600
|
pascal@4702
|
601
|
pascal@4702
|
602 @@ -1824,7 +1768,9 @@
|
pascal@4702
|
603 unsigned short c_byte;
|
pascal@4702
|
604 char cbuffer[(SQUASHFS_METADATA_SIZE << 2) + 2];
|
pascal@4702
|
605
|
pascal@4702
|
606 +#ifdef SQUASHFS_TRACE
|
pascal@4702
|
607 long long obytes = bytes;
|
pascal@4702
|
608 +#endif
|
pascal@4702
|
609
|
pascal@4702
|
610 for(i = 0; i < meta_blocks; i++) {
|
pascal@4702
|
611 int avail_bytes = length > SQUASHFS_METADATA_SIZE ?
|
pascal@4702
|
612 @@ -2170,11 +2116,85 @@
|
pascal@4702
|
613 }
|
pascal@4702
|
614
|
pascal@4702
|
615
|
pascal@4702
|
616 +static int seq = 0;
|
pascal@4702
|
617 +void reader_read_process(struct dir_ent *dir_ent)
|
pascal@4702
|
618 +{
|
pascal@4702
|
619 + struct file_buffer *prev_buffer = NULL, *file_buffer;
|
pascal@4702
|
620 + int status, res, byte, count = 0;
|
pascal@4702
|
621 + int file = get_pseudo_file(dir_ent->inode->pseudo_id)->fd;
|
pascal@4702
|
622 + int child = get_pseudo_file(dir_ent->inode->pseudo_id)->child;
|
pascal@4702
|
623 + long long bytes = 0;
|
pascal@4702
|
624 +
|
pascal@4702
|
625 + while(1) {
|
pascal@4702
|
626 + file_buffer = cache_get(reader_buffer, 0, 0);
|
pascal@4702
|
627 + file_buffer->sequence = seq ++;
|
pascal@4702
|
628 +
|
pascal@4702
|
629 + byte = read_bytes(file, file_buffer->data, block_size);
|
pascal@4702
|
630 + if(byte == -1)
|
pascal@4702
|
631 + goto read_err;
|
pascal@4702
|
632 +
|
pascal@4702
|
633 + file_buffer->size = byte;
|
pascal@4702
|
634 + file_buffer->file_size = -1;
|
pascal@4702
|
635 + file_buffer->block = count ++;
|
pascal@4702
|
636 + file_buffer->error = FALSE;
|
pascal@4702
|
637 + file_buffer->fragment = FALSE;
|
pascal@4702
|
638 + bytes += byte;
|
pascal@4702
|
639 +
|
pascal@4702
|
640 + if(byte == 0)
|
pascal@4702
|
641 + break;
|
pascal@4702
|
642 +
|
pascal@4702
|
643 + /*
|
pascal@4702
|
644 + * Update estimated_uncompressed block count. This is done
|
pascal@4702
|
645 + * on every block rather than waiting for all blocks to be
|
pascal@4702
|
646 + * read incase write_file_process() is running in parallel
|
pascal@4702
|
647 + * with this. Otherwise cur uncompressed block count may
|
pascal@4702
|
648 + * get ahead of the total uncompressed block count.
|
pascal@4702
|
649 + */
|
pascal@4702
|
650 + estimated_uncompressed ++;
|
pascal@4702
|
651 +
|
pascal@4702
|
652 + if(prev_buffer)
|
pascal@4702
|
653 + queue_put(from_reader, prev_buffer);
|
pascal@4702
|
654 + prev_buffer = file_buffer;
|
pascal@4702
|
655 + }
|
pascal@4702
|
656 +
|
pascal@4702
|
657 + /*
|
pascal@4702
|
658 + * Update inode file size now that the size of the dynamic pseudo file
|
pascal@4702
|
659 + * is known. This is needed for the -info option.
|
pascal@4702
|
660 + */
|
pascal@4702
|
661 + dir_ent->inode->buf.st_size = bytes;
|
pascal@4702
|
662 +
|
pascal@4702
|
663 + res = waitpid(child, &status, 0);
|
pascal@4702
|
664 + if(res == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
pascal@4702
|
665 + goto read_err;
|
pascal@4702
|
666 +
|
pascal@4702
|
667 + if(prev_buffer == NULL)
|
pascal@4702
|
668 + prev_buffer = file_buffer;
|
pascal@4702
|
669 + else {
|
pascal@4702
|
670 + cache_block_put(file_buffer);
|
pascal@4702
|
671 + seq --;
|
pascal@4702
|
672 + }
|
pascal@4702
|
673 + prev_buffer->file_size = bytes;
|
pascal@4702
|
674 + prev_buffer->fragment = !no_fragments &&
|
pascal@4702
|
675 + (count == 2 || always_use_fragments) && (byte < block_size);
|
pascal@4702
|
676 + queue_put(from_reader, prev_buffer);
|
pascal@4702
|
677 +
|
pascal@4702
|
678 + return;
|
pascal@4702
|
679 +
|
pascal@4702
|
680 +read_err:
|
pascal@4702
|
681 + if(prev_buffer) {
|
pascal@4702
|
682 + cache_block_put(file_buffer);
|
pascal@4702
|
683 + seq --;
|
pascal@4702
|
684 + file_buffer = prev_buffer;
|
pascal@4702
|
685 + }
|
pascal@4702
|
686 + file_buffer->error = TRUE;
|
pascal@4702
|
687 + queue_put(from_deflate, file_buffer);
|
pascal@4702
|
688 +}
|
pascal@4702
|
689 +
|
pascal@4702
|
690 +
|
pascal@4702
|
691 void reader_read_file(struct dir_ent *dir_ent)
|
pascal@4702
|
692 {
|
pascal@4702
|
693 struct stat *buf = &dir_ent->inode->buf, buf2;
|
pascal@4702
|
694 struct file_buffer *file_buffer;
|
pascal@4702
|
695 - static int index = 0;
|
pascal@4702
|
696 int blocks, byte, count, expected, file, frag_block;
|
pascal@4702
|
697 long long bytes, read_size;
|
pascal@4702
|
698
|
pascal@4702
|
699 @@ -2202,7 +2222,7 @@
|
pascal@4702
|
700 if(file_buffer)
|
pascal@4702
|
701 queue_put(from_reader, file_buffer);
|
pascal@4702
|
702 file_buffer = cache_get(reader_buffer, 0, 0);
|
pascal@4702
|
703 - file_buffer->sequence = index ++;
|
pascal@4702
|
704 + file_buffer->sequence = seq ++;
|
pascal@4702
|
705
|
pascal@4702
|
706 byte = file_buffer->size = read_bytes(file, file_buffer->data,
|
pascal@4702
|
707 block_size);
|
pascal@4702
|
708 @@ -2238,7 +2258,7 @@
|
pascal@4702
|
709
|
pascal@4702
|
710 read_err:
|
pascal@4702
|
711 file_buffer = cache_get(reader_buffer, 0, 0);
|
pascal@4702
|
712 - file_buffer->sequence = index ++;
|
pascal@4702
|
713 + file_buffer->sequence = seq ++;
|
pascal@4702
|
714 read_err2:
|
pascal@4702
|
715 file_buffer->error = TRUE;
|
pascal@4702
|
716 queue_put(from_deflate, file_buffer);
|
pascal@4702
|
717 @@ -2262,9 +2282,14 @@
|
pascal@4702
|
718 for(i = 0; i < dir->count; i++) {
|
pascal@4702
|
719 struct dir_ent *dir_ent = dir->list[i];
|
pascal@4702
|
720 struct stat *buf = &dir_ent->inode->buf;
|
pascal@4702
|
721 - if(dir_ent->data)
|
pascal@4702
|
722 + if(dir_ent->inode->root_entry)
|
pascal@4702
|
723 continue;
|
pascal@4702
|
724
|
pascal@4702
|
725 + if(dir_ent->inode->pseudo_file) {
|
pascal@4702
|
726 + reader_read_process(dir_ent);
|
pascal@4702
|
727 + continue;
|
pascal@4702
|
728 + }
|
pascal@4702
|
729 +
|
pascal@4702
|
730 switch(buf->st_mode & S_IFMT) {
|
pascal@4702
|
731 case S_IFREG:
|
pascal@4702
|
732 reader_read_file(dir_ent);
|
pascal@4702
|
733 @@ -2365,7 +2390,7 @@
|
pascal@4702
|
734
|
pascal@4702
|
735 void *deflator(void *arg)
|
pascal@4702
|
736 {
|
pascal@4702
|
737 - z_stream *stream = NULL;
|
pascal@4702
|
738 + void *stream = NULL;
|
pascal@4702
|
739 int oldstate;
|
pascal@4702
|
740
|
pascal@4702
|
741 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
pascal@4702
|
742 @@ -2402,7 +2427,7 @@
|
pascal@4702
|
743
|
pascal@4702
|
744 void *frag_deflator(void *arg)
|
pascal@4702
|
745 {
|
pascal@4702
|
746 - z_stream *stream = NULL;
|
pascal@4702
|
747 + void *stream = NULL;
|
pascal@4702
|
748 int oldstate;
|
pascal@4702
|
749
|
pascal@4702
|
750 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
pascal@4702
|
751 @@ -2426,8 +2451,8 @@
|
pascal@4702
|
752 write_buffer->block = bytes;
|
pascal@4702
|
753 bytes += compressed_size;
|
pascal@4702
|
754 fragments_outstanding --;
|
pascal@4702
|
755 - pthread_mutex_unlock(&fragment_mutex);
|
pascal@4702
|
756 queue_put(to_writer, write_buffer);
|
pascal@4702
|
757 + pthread_mutex_unlock(&fragment_mutex);
|
pascal@4702
|
758 TRACE("Writing fragment %lld, uncompressed size %d, "
|
pascal@4702
|
759 "compressed size %d\n", file_buffer->block,
|
pascal@4702
|
760 file_buffer->size, compressed_size);
|
pascal@4702
|
761 @@ -2674,6 +2699,98 @@
|
pascal@4702
|
762 }
|
pascal@4702
|
763
|
pascal@4702
|
764
|
pascal@4702
|
765 +int write_file_process(squashfs_inode *inode, struct dir_ent *dir_ent,
|
pascal@4702
|
766 + struct file_buffer *read_buffer, int *duplicate_file)
|
pascal@4702
|
767 +{
|
pascal@4702
|
768 + long long read_size, file_bytes, start;
|
pascal@4702
|
769 + struct fragment *fragment;
|
pascal@4702
|
770 + unsigned int *block_list = NULL;
|
pascal@4702
|
771 + int block = 0, status;
|
pascal@4702
|
772 + long long sparse = 0;
|
pascal@4702
|
773 + struct file_buffer *fragment_buffer = NULL;
|
pascal@4702
|
774 +
|
pascal@4702
|
775 + *duplicate_file = FALSE;
|
pascal@4702
|
776 +
|
pascal@4702
|
777 + lock_fragments();
|
pascal@4702
|
778 +
|
pascal@4702
|
779 + file_bytes = 0;
|
pascal@4702
|
780 + start = bytes;
|
pascal@4702
|
781 + while (1) {
|
pascal@4702
|
782 + read_size = read_buffer->file_size;
|
pascal@4702
|
783 + if(read_buffer->fragment && read_buffer->c_byte)
|
pascal@4702
|
784 + fragment_buffer = read_buffer;
|
pascal@4702
|
785 + else {
|
pascal@4702
|
786 + block_list = realloc(block_list, (block + 1) *
|
pascal@4702
|
787 + sizeof(unsigned int));
|
pascal@4702
|
788 + if(block_list == NULL)
|
pascal@4702
|
789 + BAD_ERROR("Out of memory allocating block_list"
|
pascal@4702
|
790 + "\n");
|
pascal@4702
|
791 + block_list[block ++] = read_buffer->c_byte;
|
pascal@4702
|
792 + if(read_buffer->c_byte) {
|
pascal@4702
|
793 + read_buffer->block = bytes;
|
pascal@4702
|
794 + bytes += read_buffer->size;
|
pascal@4702
|
795 + cache_rehash(read_buffer, read_buffer->block);
|
pascal@4702
|
796 + file_bytes += read_buffer->size;
|
pascal@4702
|
797 + queue_put(to_writer, read_buffer);
|
pascal@4702
|
798 + } else {
|
pascal@4702
|
799 + sparse += read_buffer->size;
|
pascal@4702
|
800 + cache_block_put(read_buffer);
|
pascal@4702
|
801 + }
|
pascal@4702
|
802 + }
|
pascal@4702
|
803 + inc_progress_bar();
|
pascal@4702
|
804 +
|
pascal@4702
|
805 + if(read_size != -1)
|
pascal@4702
|
806 + break;
|
pascal@4702
|
807 +
|
pascal@4702
|
808 + read_buffer = get_file_buffer(from_deflate);
|
pascal@4702
|
809 + if(read_buffer->error)
|
pascal@4702
|
810 + goto read_err;
|
pascal@4702
|
811 + }
|
pascal@4702
|
812 +
|
pascal@4702
|
813 + unlock_fragments();
|
pascal@4702
|
814 + fragment = get_and_fill_fragment(fragment_buffer);
|
pascal@4702
|
815 + cache_block_put(fragment_buffer);
|
pascal@4702
|
816 +
|
pascal@4702
|
817 + if(duplicate_checking)
|
pascal@4702
|
818 + add_non_dup(read_size, file_bytes, block_list, start, fragment,
|
pascal@4702
|
819 + 0, 0, FALSE);
|
pascal@4702
|
820 + file_count ++;
|
pascal@4702
|
821 + total_bytes += read_size;
|
pascal@4702
|
822 +
|
pascal@4702
|
823 + if(read_size < (1LL << 32) && start < (1LL << 32) && sparse == 0)
|
pascal@4702
|
824 + create_inode(inode, dir_ent, SQUASHFS_FILE_TYPE, read_size,
|
pascal@4702
|
825 + start, block, block_list, fragment, NULL, 0);
|
pascal@4702
|
826 + else
|
pascal@4702
|
827 + create_inode(inode, dir_ent, SQUASHFS_LREG_TYPE, read_size,
|
pascal@4702
|
828 + start, block, block_list, fragment, NULL, sparse);
|
pascal@4702
|
829 +
|
pascal@4702
|
830 + if(duplicate_checking == FALSE)
|
pascal@4702
|
831 + free(block_list);
|
pascal@4702
|
832 +
|
pascal@4702
|
833 + return 0;
|
pascal@4702
|
834 +
|
pascal@4702
|
835 +read_err:
|
pascal@4702
|
836 + cur_uncompressed -= block;
|
pascal@4702
|
837 + status = read_buffer->error;
|
pascal@4702
|
838 + bytes = start;
|
pascal@4702
|
839 + if(!block_device) {
|
pascal@4702
|
840 + int res;
|
pascal@4702
|
841 +
|
pascal@4702
|
842 + queue_put(to_writer, NULL);
|
pascal@4702
|
843 + if(queue_get(from_writer) != 0)
|
pascal@4702
|
844 + EXIT_MKSQUASHFS();
|
pascal@4702
|
845 + res = ftruncate(fd, bytes);
|
pascal@4702
|
846 + if(res != 0)
|
pascal@4702
|
847 + BAD_ERROR("Failed to truncate dest file because %s\n",
|
pascal@4702
|
848 + strerror(errno));
|
pascal@4702
|
849 + }
|
pascal@4702
|
850 + unlock_fragments();
|
pascal@4702
|
851 + free(block_list);
|
pascal@4702
|
852 + cache_block_put(read_buffer);
|
pascal@4702
|
853 + return status;
|
pascal@4702
|
854 +}
|
pascal@4702
|
855 +
|
pascal@4702
|
856 +
|
pascal@4702
|
857 int write_file_blocks(squashfs_inode *inode, struct dir_ent *dir_ent,
|
pascal@4702
|
858 long long read_size, struct file_buffer *read_buffer,
|
pascal@4702
|
859 int *duplicate_file)
|
pascal@4702
|
860 @@ -2941,7 +3058,10 @@
|
pascal@4702
|
861
|
pascal@4702
|
862 read_size = read_buffer->file_size;
|
pascal@4702
|
863
|
pascal@4702
|
864 - if(read_size == 0) {
|
pascal@4702
|
865 + if(read_size == -1)
|
pascal@4702
|
866 + status = write_file_process(inode, dir_ent, read_buffer,
|
pascal@4702
|
867 + duplicate_file);
|
pascal@4702
|
868 + else if(read_size == 0) {
|
pascal@4702
|
869 write_file_empty(inode, dir_ent, duplicate_file);
|
pascal@4702
|
870 cache_block_put(read_buffer);
|
pascal@4702
|
871 } else if(read_buffer->fragment && read_buffer->c_byte)
|
pascal@4702
|
872 @@ -3036,6 +3156,8 @@
|
pascal@4702
|
873
|
pascal@4702
|
874 memcpy(&inode->buf, buf, sizeof(struct stat));
|
pascal@4702
|
875 inode->read = FALSE;
|
pascal@4702
|
876 + inode->root_entry = FALSE;
|
pascal@4702
|
877 + inode->pseudo_file = FALSE;
|
pascal@4702
|
878 inode->inode = SQUASHFS_INVALID_BLK;
|
pascal@4702
|
879 inode->nlink = 1;
|
pascal@4702
|
880
|
pascal@4702
|
881 @@ -3056,7 +3178,7 @@
|
pascal@4702
|
882
|
pascal@4702
|
883
|
pascal@4702
|
884 inline void add_dir_entry(char *name, char *pathname, struct dir_info *sub_dir,
|
pascal@4702
|
885 - struct inode_info *inode_info, void *data, struct dir_info *dir)
|
pascal@4702
|
886 + struct inode_info *inode_info, struct dir_info *dir)
|
pascal@4702
|
887 {
|
pascal@4702
|
888 if((dir->count % DIR_ENTRIES) == 0) {
|
pascal@4702
|
889 dir->list = realloc(dir->list, (dir->count + DIR_ENTRIES) *
|
pascal@4702
|
890 @@ -3075,8 +3197,7 @@
|
pascal@4702
|
891 NULL;
|
pascal@4702
|
892 dir->list[dir->count]->inode = inode_info;
|
pascal@4702
|
893 dir->list[dir->count]->dir = sub_dir;
|
pascal@4702
|
894 - dir->list[dir->count]->our_dir = dir;
|
pascal@4702
|
895 - dir->list[dir->count++]->data = data;
|
pascal@4702
|
896 + dir->list[dir->count++]->our_dir = dir;
|
pascal@4702
|
897 dir->byte_count += strlen(name) + sizeof(squashfs_dir_entry);
|
pascal@4702
|
898 }
|
pascal@4702
|
899
|
pascal@4702
|
900 @@ -3128,10 +3249,10 @@
|
pascal@4702
|
901
|
pascal@4702
|
902 if(dir->count < old_root_entries)
|
pascal@4702
|
903 for(i = 0; i < old_root_entries; i++) {
|
pascal@4702
|
904 - if(old_root_entry[i].type == SQUASHFS_DIR_TYPE)
|
pascal@4702
|
905 + if(old_root_entry[i].inode.type == SQUASHFS_DIR_TYPE)
|
pascal@4702
|
906 dir->directory_count ++;
|
pascal@4702
|
907 - add_dir_entry(old_root_entry[i].name, "", NULL, NULL,
|
pascal@4702
|
908 - &old_root_entry[i], dir);
|
pascal@4702
|
909 + add_dir_entry(old_root_entry[i].name, "", NULL,
|
pascal@4702
|
910 + &old_root_entry[i].inode, dir);
|
pascal@4702
|
911 }
|
pascal@4702
|
912
|
pascal@4702
|
913 while(index < source) {
|
pascal@4702
|
914 @@ -3167,10 +3288,10 @@
|
pascal@4702
|
915
|
pascal@4702
|
916 if(dir->count < old_root_entries)
|
pascal@4702
|
917 for(i = 0; i < old_root_entries; i++) {
|
pascal@4702
|
918 - if(old_root_entry[i].type == SQUASHFS_DIR_TYPE)
|
pascal@4702
|
919 + if(old_root_entry[i].inode.type == SQUASHFS_DIR_TYPE)
|
pascal@4702
|
920 dir->directory_count ++;
|
pascal@4702
|
921 - add_dir_entry(old_root_entry[i].name, "", NULL, NULL,
|
pascal@4702
|
922 - &old_root_entry[i], dir);
|
pascal@4702
|
923 + add_dir_entry(old_root_entry[i].name, "", NULL,
|
pascal@4702
|
924 + &old_root_entry[i].inode, dir);
|
pascal@4702
|
925 }
|
pascal@4702
|
926
|
pascal@4702
|
927 if((d_name = readdir(dir->linuxdir)) != NULL) {
|
pascal@4702
|
928 @@ -3215,7 +3336,7 @@
|
pascal@4702
|
929 int current_count;
|
pascal@4702
|
930
|
pascal@4702
|
931 while((current_count = dir_info->current_count++) < dir_info->count)
|
pascal@4702
|
932 - if(dir_info->list[current_count]->data)
|
pascal@4702
|
933 + if(dir_info->list[current_count]->inode->root_entry)
|
pascal@4702
|
934 continue;
|
pascal@4702
|
935 else
|
pascal@4702
|
936 return dir_info->list[current_count];
|
pascal@4702
|
937 @@ -3240,11 +3361,11 @@
|
pascal@4702
|
938 int current_count;
|
pascal@4702
|
939
|
pascal@4702
|
940 while((current_count = dir_info->current_count++) < dir_info->count)
|
pascal@4702
|
941 - if(dir_info->list[current_count]->data)
|
pascal@4702
|
942 - add_dir(dir_info->list[current_count]->data->inode,
|
pascal@4702
|
943 - dir_info->list[current_count]->data->inode_number,
|
pascal@4702
|
944 + if(dir_info->list[current_count]->inode->root_entry)
|
pascal@4702
|
945 + add_dir(dir_info->list[current_count]->inode->inode,
|
pascal@4702
|
946 + dir_info->list[current_count]->inode->inode_number,
|
pascal@4702
|
947 dir_info->list[current_count]->name,
|
pascal@4702
|
948 - dir_info->list[current_count]->data->type, dir);
|
pascal@4702
|
949 + dir_info->list[current_count]->inode->type, dir);
|
pascal@4702
|
950 else
|
pascal@4702
|
951 return dir_info->list[current_count];
|
pascal@4702
|
952 return NULL;
|
pascal@4702
|
953 @@ -3313,7 +3434,6 @@
|
pascal@4702
|
954 dir_ent->name = dir_ent->pathname = strdup(pathname);
|
pascal@4702
|
955 dir_ent->dir = dir_info;
|
pascal@4702
|
956 dir_ent->our_dir = NULL;
|
pascal@4702
|
957 - dir_ent->data = NULL;
|
pascal@4702
|
958 dir_info->dir_ent = dir_ent;
|
pascal@4702
|
959
|
pascal@4702
|
960 if(sorted)
|
pascal@4702
|
961 @@ -3383,7 +3503,7 @@
|
pascal@4702
|
962 sub_dir = NULL;
|
pascal@4702
|
963
|
pascal@4702
|
964 add_dir_entry(dir_name, filename, sub_dir, lookup_inode(&buf),
|
pascal@4702
|
965 - NULL, dir);
|
pascal@4702
|
966 + dir);
|
pascal@4702
|
967 }
|
pascal@4702
|
968
|
pascal@4702
|
969 scan1_freedir(dir);
|
pascal@4702
|
970 @@ -3399,7 +3519,7 @@
|
pascal@4702
|
971 struct dir_ent *dir_ent;
|
pascal@4702
|
972 struct pseudo_entry *pseudo_ent;
|
pascal@4702
|
973 struct stat buf;
|
pascal@4702
|
974 - static pseudo_ino = 1;
|
pascal@4702
|
975 + static int pseudo_ino = 1;
|
pascal@4702
|
976
|
pascal@4702
|
977 if(dir == NULL && (dir = scan1_opendir("")) == NULL)
|
pascal@4702
|
978 return NULL;
|
pascal@4702
|
979 @@ -3415,6 +3535,29 @@
|
pascal@4702
|
980
|
pascal@4702
|
981 while((pseudo_ent = pseudo_readdir(pseudo)) != NULL) {
|
pascal@4702
|
982 dir_ent = scan2_lookup(dir, pseudo_ent->name);
|
pascal@4702
|
983 + if(pseudo_ent->dev->type == 's') {
|
pascal@4702
|
984 + struct stat *buf;
|
pascal@4702
|
985 + if(dir_ent == NULL) {
|
pascal@4702
|
986 + ERROR("Pseudo set file \"%s\" does not exist "
|
pascal@4702
|
987 + "in source filesystem. Ignoring\n",
|
pascal@4702
|
988 + pseudo_ent->pathname);
|
pascal@4702
|
989 + continue;
|
pascal@4702
|
990 + }
|
pascal@4702
|
991 + if(dir_ent->inode->root_entry) {
|
pascal@4702
|
992 + ERROR("Pseudo set file \"%s\" is a pre-existing"
|
pascal@4702
|
993 + " file in the filesystem being appended"
|
pascal@4702
|
994 + " to. It cannot be modified. "
|
pascal@4702
|
995 + "Ignoring!\n", pseudo_ent->pathname);
|
pascal@4702
|
996 + continue;
|
pascal@4702
|
997 + }
|
pascal@4702
|
998 + buf = &dir_ent->inode->buf;
|
pascal@4702
|
999 + buf->st_mode = (buf->st_mode & S_IFMT) |
|
pascal@4702
|
1000 + pseudo_ent->dev->mode;
|
pascal@4702
|
1001 + buf->st_uid = pseudo_ent->dev->uid;
|
pascal@4702
|
1002 + buf->st_gid = pseudo_ent->dev->gid;
|
pascal@4702
|
1003 + continue;
|
pascal@4702
|
1004 + }
|
pascal@4702
|
1005 +
|
pascal@4702
|
1006 if(dir_ent) {
|
pascal@4702
|
1007 ERROR("Pseudo file \"%s\" exists in source filesystem "
|
pascal@4702
|
1008 "\"%s\"\n", pseudo_ent->pathname,
|
pascal@4702
|
1009 @@ -3444,8 +3587,29 @@
|
pascal@4702
|
1010 buf.st_mtime = time(NULL);
|
pascal@4702
|
1011 buf.st_ino = pseudo_ino ++;
|
pascal@4702
|
1012
|
pascal@4702
|
1013 - add_dir_entry(pseudo_ent->name, pseudo_ent->pathname, sub_dir,
|
pascal@4702
|
1014 - lookup_inode(&buf), NULL, dir);
|
pascal@4702
|
1015 + if(pseudo_ent->dev->type == 'f') {
|
pascal@4702
|
1016 +#ifdef USE_TMP_FILE
|
pascal@4702
|
1017 + struct stat buf2;
|
pascal@4702
|
1018 + int res = stat(pseudo_ent->dev->filename, &buf2);
|
pascal@4702
|
1019 + if(res == -1) {
|
pascal@4702
|
1020 + ERROR("Stat on pseudo file \"%s\" failed, "
|
pascal@4702
|
1021 + "skipping...", pseudo_ent->pathname);
|
pascal@4702
|
1022 + continue;
|
pascal@4702
|
1023 + }
|
pascal@4702
|
1024 + buf.st_size = buf2.st_size;
|
pascal@4702
|
1025 + add_dir_entry(pseudo_ent->name,
|
pascal@4702
|
1026 + pseudo_ent->dev->filename, sub_dir,
|
pascal@4702
|
1027 + lookup_inode(&buf), dir);
|
pascal@4702
|
1028 +#else
|
pascal@4702
|
1029 + struct inode_info *inode = lookup_inode(&buf);
|
pascal@4702
|
1030 + inode->pseudo_id = pseudo_ent->dev->pseudo_id;
|
pascal@4702
|
1031 + inode->pseudo_file = TRUE;
|
pascal@4702
|
1032 + add_dir_entry(pseudo_ent->name, pseudo_ent->pathname,
|
pascal@4702
|
1033 + sub_dir, inode, dir);
|
pascal@4702
|
1034 +#endif
|
pascal@4702
|
1035 + } else
|
pascal@4702
|
1036 + add_dir_entry(pseudo_ent->name, pseudo_ent->pathname,
|
pascal@4702
|
1037 + sub_dir, lookup_inode(&buf), dir);
|
pascal@4702
|
1038 }
|
pascal@4702
|
1039
|
pascal@4702
|
1040 scan2_freedir(dir);
|
pascal@4702
|
1041 @@ -3482,8 +3646,9 @@
|
pascal@4702
|
1042 &duplicate_file);
|
pascal@4702
|
1043 INFO("file %s, uncompressed size %lld "
|
pascal@4702
|
1044 "bytes %s\n", filename,
|
pascal@4702
|
1045 - buf->st_size, duplicate_file ?
|
pascal@4702
|
1046 - "DUPLICATE" : "");
|
pascal@4702
|
1047 + (long long) buf->st_size,
|
pascal@4702
|
1048 + duplicate_file ? "DUPLICATE" :
|
pascal@4702
|
1049 + "");
|
pascal@4702
|
1050 break;
|
pascal@4702
|
1051
|
pascal@4702
|
1052 case S_IFDIR:
|
pascal@4702
|
1053 @@ -3557,6 +3722,7 @@
|
pascal@4702
|
1054 INFO("file %s, uncompressed "
|
pascal@4702
|
1055 "size %lld bytes LINK"
|
pascal@4702
|
1056 "\n", filename,
|
pascal@4702
|
1057 + (long long)
|
pascal@4702
|
1058 buf->st_size);
|
pascal@4702
|
1059 break;
|
pascal@4702
|
1060 case SQUASHFS_SYMLINK_TYPE:
|
pascal@4702
|
1061 @@ -3667,10 +3833,11 @@
|
pascal@4702
|
1062 BAD_ERROR("Out of memory in old root directory entries "
|
pascal@4702
|
1063 "reallocation\n");
|
pascal@4702
|
1064
|
pascal@4702
|
1065 - strcpy(old_root_entry[old_root_entries].name, name);
|
pascal@4702
|
1066 - old_root_entry[old_root_entries].inode = inode;
|
pascal@4702
|
1067 - old_root_entry[old_root_entries].inode_number = inode_number;
|
pascal@4702
|
1068 - old_root_entry[old_root_entries++].type = type;
|
pascal@4702
|
1069 + old_root_entry[old_root_entries].name = strdup(name);
|
pascal@4702
|
1070 + old_root_entry[old_root_entries].inode.inode = inode;
|
pascal@4702
|
1071 + old_root_entry[old_root_entries].inode.inode_number = inode_number;
|
pascal@4702
|
1072 + old_root_entry[old_root_entries].inode.type = type;
|
pascal@4702
|
1073 + old_root_entry[old_root_entries++].inode.root_entry = TRUE;
|
pascal@4702
|
1074 }
|
pascal@4702
|
1075
|
pascal@4702
|
1076
|
pascal@4702
|
1077 @@ -4137,7 +4304,7 @@
|
pascal@4702
|
1078
|
pascal@4702
|
1079
|
pascal@4702
|
1080 #define VERSION() \
|
pascal@4702
|
1081 - printf("mksquashfs version 4.0 (2009/04/05)\n");\
|
pascal@4702
|
1082 + printf("mksquashfs version 4.1-CVS (2009/12/08)\n");\
|
pascal@4702
|
1083 printf("copyright (C) 2009 Phillip Lougher <phillip@lougher.demon.co.uk>\n\n"); \
|
pascal@4702
|
1084 printf("This program is free software; you can redistribute it and/or\n");\
|
pascal@4702
|
1085 printf("modify it under the terms of the GNU General Public License\n");\
|
pascal@4702
|
1086 @@ -4172,26 +4339,28 @@
|
pascal@4702
|
1087 source_path = argv + 1;
|
pascal@4702
|
1088 source = i - 2;
|
pascal@4702
|
1089 for(; i < argc; i++) {
|
pascal@4702
|
1090 - if(strcmp(argv[i], "-pf") == 0) {
|
pascal@4702
|
1091 + if(strcmp(argv[i], "-comp") == 0) {
|
pascal@4702
|
1092 if(++i == argc) {
|
pascal@4702
|
1093 - ERROR("%s: -pf missing filename\n", argv[0]);
|
pascal@4702
|
1094 + ERROR("%s: -comp missing compression type\n",
|
pascal@4702
|
1095 + argv[0]);
|
pascal@4702
|
1096 exit(1);
|
pascal@4702
|
1097 }
|
pascal@4702
|
1098 - if(read_pseudo_file(&pseudo, argv[i]) == FALSE) {
|
pascal@4702
|
1099 - ERROR("Failed to parse pseudo file \"%s\"\n",
|
pascal@4702
|
1100 - argv[i]);
|
pascal@4702
|
1101 + comp_name = argv[i];
|
pascal@4702
|
1102 + } else if(strcmp(argv[i], "-pf") == 0) {
|
pascal@4702
|
1103 + if(++i == argc) {
|
pascal@4702
|
1104 + ERROR("%s: -pf missing filename\n", argv[0]);
|
pascal@4702
|
1105 exit(1);
|
pascal@4702
|
1106 }
|
pascal@4702
|
1107 + if(read_pseudo_file(&pseudo, argv[i]) == FALSE)
|
pascal@4702
|
1108 + exit(1);
|
pascal@4702
|
1109 } else if(strcmp(argv[i], "-p") == 0) {
|
pascal@4702
|
1110 if(++i == argc) {
|
pascal@4702
|
1111 ERROR("%s: -p missing pseudo file definition\n",
|
pascal@4702
|
1112 argv[0]);
|
pascal@4702
|
1113 exit(1);
|
pascal@4702
|
1114 }
|
pascal@4702
|
1115 - if(read_pseudo_def(&pseudo, argv[i]) == FALSE) {
|
pascal@4702
|
1116 - ERROR("Failed to parse pseudo definition\n");
|
pascal@4702
|
1117 + if(read_pseudo_def(&pseudo, argv[i]) == FALSE)
|
pascal@4702
|
1118 exit(1);
|
pascal@4702
|
1119 - }
|
pascal@4702
|
1120 } else if(strcmp(argv[i], "-recover") == 0) {
|
pascal@4702
|
1121 if(++i == argc) {
|
pascal@4702
|
1122 ERROR("%s: -recover missing recovery file\n",
|
pascal@4702
|
1123 @@ -4394,34 +4563,16 @@
|
pascal@4702
|
1124 printOptions:
|
pascal@4702
|
1125 ERROR("SYNTAX:%s source1 source2 ... dest [options] "
|
pascal@4702
|
1126 "[-e list of exclude\ndirs/files]\n", argv[0]);
|
pascal@4702
|
1127 - ERROR("\nOptions are\n");
|
pascal@4702
|
1128 - ERROR("-version\t\tprint version, licence and "
|
pascal@4702
|
1129 - "copyright message\n");
|
pascal@4702
|
1130 - ERROR("-recover <name>\t\trecover filesystem data "
|
pascal@4702
|
1131 - "using recovery file <name>\n");
|
pascal@4702
|
1132 - ERROR("-no-recovery\t\tdon't generate a recovery "
|
pascal@4702
|
1133 - "file\n");
|
pascal@4702
|
1134 - ERROR("-info\t\t\tprint files written to filesystem\n");
|
pascal@4702
|
1135 - ERROR("-no-exports\t\tdon't make the filesystem "
|
pascal@4702
|
1136 - "exportable via NFS\n");
|
pascal@4702
|
1137 - ERROR("-no-progress\t\tdon't display the progress "
|
pascal@4702
|
1138 - "bar\n");
|
pascal@4702
|
1139 - ERROR("-no-sparse\t\tdon't detect sparse files\n");
|
pascal@4702
|
1140 + ERROR("\nFilesystem build options:\n");
|
pascal@4702
|
1141 + ERROR("-comp <comp>\t\tselect <comp> compression\n");
|
pascal@4702
|
1142 + ERROR("\t\t\tCompressors available:\n");
|
pascal@4702
|
1143 + display_compressors("\t\t\t", COMP_DEFAULT);
|
pascal@4702
|
1144 ERROR("-b <block_size>\t\tset data block to "
|
pascal@4702
|
1145 "<block_size>. Default %d bytes\n",
|
pascal@4702
|
1146 SQUASHFS_FILE_SIZE);
|
pascal@4702
|
1147 - ERROR("-processors <number>\tUse <number> processors."
|
pascal@4702
|
1148 - " By default will use number of\n");
|
pascal@4702
|
1149 - ERROR("\t\t\tprocessors available\n");
|
pascal@4702
|
1150 - ERROR("-read-queue <size>\tSet input queue to <size> "
|
pascal@4702
|
1151 - "Mbytes. Default %d Mbytes\n",
|
pascal@4702
|
1152 - READER_BUFFER_DEFAULT);
|
pascal@4702
|
1153 - ERROR("-write-queue <size>\tSet output queue to <size> "
|
pascal@4702
|
1154 - "Mbytes. Default %d Mbytes\n",
|
pascal@4702
|
1155 - WRITER_BUFFER_DEFAULT);
|
pascal@4702
|
1156 - ERROR("-fragment-queue <size>\tSet fagment queue to "
|
pascal@4702
|
1157 - "<size> Mbytes. Default %d Mbytes\n",
|
pascal@4702
|
1158 - FRAGMENT_BUFFER_DEFAULT);
|
pascal@4702
|
1159 + ERROR("-no-exports\t\tdon't make the filesystem "
|
pascal@4702
|
1160 + "exportable via NFS\n");
|
pascal@4702
|
1161 + ERROR("-no-sparse\t\tdon't detect sparse files\n");
|
pascal@4702
|
1162 ERROR("-noI\t\t\tdo not compress inode table\n");
|
pascal@4702
|
1163 ERROR("-noD\t\t\tdo not compress data blocks\n");
|
pascal@4702
|
1164 ERROR("-noF\t\t\tdo not compress fragment blocks\n");
|
pascal@4702
|
1165 @@ -4430,13 +4581,34 @@
|
pascal@4702
|
1166 "files larger than block size\n");
|
pascal@4702
|
1167 ERROR("-no-duplicates\t\tdo not perform duplicate "
|
pascal@4702
|
1168 "checking\n");
|
pascal@4702
|
1169 - ERROR("-noappend\t\tdo not append to existing "
|
pascal@4702
|
1170 - "filesystem\n");
|
pascal@4702
|
1171 + ERROR("-all-root\t\tmake all files owned by root\n");
|
pascal@4702
|
1172 + ERROR("-force-uid uid\t\tset all file uids to uid\n");
|
pascal@4702
|
1173 + ERROR("-force-gid gid\t\tset all file gids to gid\n");
|
pascal@4702
|
1174 + ERROR("-nopad\t\t\tdo not pad filesystem to a multiple "
|
pascal@4702
|
1175 + "of 4K\n");
|
pascal@4702
|
1176 ERROR("-keep-as-directory\tif one source directory is "
|
pascal@4702
|
1177 "specified, create a root\n");
|
pascal@4702
|
1178 ERROR("\t\t\tdirectory containing that directory, "
|
pascal@4702
|
1179 "rather than the\n");
|
pascal@4702
|
1180 ERROR("\t\t\tcontents of the directory\n");
|
pascal@4702
|
1181 + ERROR("\nFilesystem filter options:\n");
|
pascal@4702
|
1182 + ERROR("-p <pseudo-definition>\tAdd pseudo file definition\n");
|
pascal@4702
|
1183 + ERROR("-pf <pseudo-file>\tAdd list of pseudo file definitions\n");
|
pascal@4702
|
1184 + ERROR("-sort <sort_file>\tsort files according to "
|
pascal@4702
|
1185 + "priorities in <sort_file>. One\n");
|
pascal@4702
|
1186 + ERROR("\t\t\tfile or dir with priority per line. "
|
pascal@4702
|
1187 + "Priority -32768 to\n");
|
pascal@4702
|
1188 + ERROR("\t\t\t32767, default priority 0\n");
|
pascal@4702
|
1189 + ERROR("-ef <exclude_file>\tlist of exclude dirs/files."
|
pascal@4702
|
1190 + " One per line\n");
|
pascal@4702
|
1191 + ERROR("-wildcards\t\tAllow extended shell wildcards "
|
pascal@4702
|
1192 + "(globbing) to be used in\n\t\t\texclude "
|
pascal@4702
|
1193 + "dirs/files\n");
|
pascal@4702
|
1194 + ERROR("-regex\t\t\tAllow POSIX regular expressions to "
|
pascal@4702
|
1195 + "be used in exclude\n\t\t\tdirs/files\n");
|
pascal@4702
|
1196 + ERROR("\nFilesystem append options:\n");
|
pascal@4702
|
1197 + ERROR("-noappend\t\tdo not append to existing "
|
pascal@4702
|
1198 + "filesystem\n");
|
pascal@4702
|
1199 ERROR("-root-becomes <name>\twhen appending source "
|
pascal@4702
|
1200 "files/directories, make the\n");
|
pascal@4702
|
1201 ERROR("\t\t\toriginal root become a subdirectory in "
|
pascal@4702
|
1202 @@ -4444,11 +4616,29 @@
|
pascal@4702
|
1203 ERROR("\t\t\tcalled <name>, rather than adding the new "
|
pascal@4702
|
1204 "source items\n");
|
pascal@4702
|
1205 ERROR("\t\t\tto the original root\n");
|
pascal@4702
|
1206 - ERROR("-all-root\t\tmake all files owned by root\n");
|
pascal@4702
|
1207 - ERROR("-force-uid uid\t\tset all file uids to uid\n");
|
pascal@4702
|
1208 - ERROR("-force-gid gid\t\tset all file gids to gid\n");
|
pascal@4702
|
1209 - ERROR("-nopad\t\t\tdo not pad filesystem to a multiple "
|
pascal@4702
|
1210 - "of 4K\n");
|
pascal@4702
|
1211 + ERROR("\nMksquashfs runtime options:\n");
|
pascal@4702
|
1212 + ERROR("-version\t\tprint version, licence and "
|
pascal@4702
|
1213 + "copyright message\n");
|
pascal@4702
|
1214 + ERROR("-recover <name>\t\trecover filesystem data "
|
pascal@4702
|
1215 + "using recovery file <name>\n");
|
pascal@4702
|
1216 + ERROR("-no-recovery\t\tdon't generate a recovery "
|
pascal@4702
|
1217 + "file\n");
|
pascal@4702
|
1218 + ERROR("-info\t\t\tprint files written to filesystem\n");
|
pascal@4702
|
1219 + ERROR("-no-progress\t\tdon't display the progress "
|
pascal@4702
|
1220 + "bar\n");
|
pascal@4702
|
1221 + ERROR("-processors <number>\tUse <number> processors."
|
pascal@4702
|
1222 + " By default will use number of\n");
|
pascal@4702
|
1223 + ERROR("\t\t\tprocessors available\n");
|
pascal@4702
|
1224 + ERROR("-read-queue <size>\tSet input queue to <size> "
|
pascal@4702
|
1225 + "Mbytes. Default %d Mbytes\n",
|
pascal@4702
|
1226 + READER_BUFFER_DEFAULT);
|
pascal@4702
|
1227 + ERROR("-write-queue <size>\tSet output queue to <size> "
|
pascal@4702
|
1228 + "Mbytes. Default %d Mbytes\n",
|
pascal@4702
|
1229 + WRITER_BUFFER_DEFAULT);
|
pascal@4702
|
1230 + ERROR("-fragment-queue <size>\tSet fagment queue to "
|
pascal@4702
|
1231 + "<size> Mbytes. Default %d Mbytes\n",
|
pascal@4702
|
1232 + FRAGMENT_BUFFER_DEFAULT);
|
pascal@4702
|
1233 + ERROR("\nMiscellaneous options:\n");
|
pascal@4702
|
1234 ERROR("-root-owned\t\talternative name for -all-root"
|
pascal@4702
|
1235 "\n");
|
pascal@4702
|
1236 ERROR("-noInodeCompression\talternative name for -noI"
|
pascal@4702
|
1237 @@ -4457,20 +4647,8 @@
|
pascal@4702
|
1238 "\n");
|
pascal@4702
|
1239 ERROR("-noFragmentCompression\talternative name for "
|
pascal@4702
|
1240 "-noF\n");
|
pascal@4702
|
1241 - ERROR("-sort <sort_file>\tsort files according to "
|
pascal@4702
|
1242 - "priorities in <sort_file>. One\n");
|
pascal@4702
|
1243 - ERROR("\t\t\tfile or dir with priority per line. "
|
pascal@4702
|
1244 - "Priority -32768 to\n");
|
pascal@4702
|
1245 - ERROR("\t\t\t32767, default priority 0\n");
|
pascal@4702
|
1246 - ERROR("-ef <exclude_file>\tlist of exclude dirs/files."
|
pascal@4702
|
1247 - " One per line\n");
|
pascal@4702
|
1248 - ERROR("-wildcards\t\tAllow extended shell wildcards "
|
pascal@4702
|
1249 - "(globbing) to be used in\n\t\t\texclude "
|
pascal@4702
|
1250 - "dirs/files\n");
|
pascal@4702
|
1251 - ERROR("-regex\t\t\tAllow POSIX regular expressions to "
|
pascal@4702
|
1252 - "be used in exclude\n\t\t\tdirs/files\n");
|
pascal@4702
|
1253 - ERROR("-p <pseudo-definition>\tAdd pseudo file definition\n");
|
pascal@4702
|
1254 - ERROR("-pf <pseudo-file>\tAdd list of pseudo file definitions\n");
|
pascal@4702
|
1255 + ERROR("\nCompressors available:\n");
|
pascal@4702
|
1256 + display_compressors("", COMP_DEFAULT);
|
pascal@4702
|
1257 exit(1);
|
pascal@4702
|
1258 }
|
pascal@4702
|
1259 }
|
pascal@4702
|
1260 @@ -4548,11 +4726,10 @@
|
pascal@4702
|
1261 fclose(fd);
|
pascal@4702
|
1262 } else if(strcmp(argv[i], "-e") == 0)
|
pascal@4702
|
1263 break;
|
pascal@4702
|
1264 - else if(strcmp(argv[i], "-b") == 0 ||
|
pascal@4702
|
1265 - strcmp(argv[i], "-root-becomes") == 0 ||
|
pascal@4702
|
1266 + else if(strcmp(argv[i], "-root-becomes") == 0 ||
|
pascal@4702
|
1267 strcmp(argv[i], "-sort") == 0 ||
|
pascal@4702
|
1268 strcmp(argv[i], "-pf") == 0 ||
|
pascal@4702
|
1269 - strcmp(argv[i], "-p") == 0)
|
pascal@4702
|
1270 + strcmp(argv[i], "-comp") == 0)
|
pascal@4702
|
1271 i++;
|
pascal@4702
|
1272
|
pascal@4702
|
1273 if(i != argc) {
|
pascal@4702
|
1274 @@ -4574,11 +4751,10 @@
|
pascal@4702
|
1275 sorted ++;
|
pascal@4702
|
1276 } else if(strcmp(argv[i], "-e") == 0)
|
pascal@4702
|
1277 break;
|
pascal@4702
|
1278 - else if(strcmp(argv[i], "-b") == 0 ||
|
pascal@4702
|
1279 - strcmp(argv[i], "-root-becomes") == 0 ||
|
pascal@4702
|
1280 + else if(strcmp(argv[i], "-root-becomes") == 0 ||
|
pascal@4702
|
1281 strcmp(argv[i], "-ef") == 0 ||
|
pascal@4702
|
1282 strcmp(argv[i], "-pf") == 0 ||
|
pascal@4702
|
1283 - strcmp(argv[i], "-p") == 0)
|
pascal@4702
|
1284 + strcmp(argv[i], "-comp") == 0)
|
pascal@4702
|
1285 i++;
|
pascal@4702
|
1286
|
pascal@4702
|
1287 #ifdef SQUASHFS_TRACE
|
pascal@4702
|
1288 @@ -4586,7 +4762,8 @@
|
pascal@4702
|
1289 #endif
|
pascal@4702
|
1290
|
pascal@4702
|
1291 if(!delete) {
|
pascal@4702
|
1292 - if(read_super(fd, &sBlk, argv[source + 1]) == 0) {
|
pascal@4702
|
1293 + comp = read_super(fd, &sBlk, argv[source + 1]);
|
pascal@4702
|
1294 + if(comp == NULL) {
|
pascal@4702
|
1295 ERROR("Failed to read existing filesystem - will not "
|
pascal@4702
|
1296 "overwrite - ABORTING!\n");
|
pascal@4702
|
1297 ERROR("To force Mksquashfs to write to this block "
|
pascal@4702
|
1298 @@ -4603,6 +4780,15 @@
|
pascal@4702
|
1299 always_use_fragments = SQUASHFS_ALWAYS_FRAGMENTS(sBlk.flags);
|
pascal@4702
|
1300 duplicate_checking = SQUASHFS_DUPLICATES(sBlk.flags);
|
pascal@4702
|
1301 exportable = SQUASHFS_EXPORTABLE(sBlk.flags);
|
pascal@4702
|
1302 + } else {
|
pascal@4702
|
1303 + comp = lookup_compressor(comp_name);
|
pascal@4702
|
1304 + if(!comp->supported) {
|
pascal@4702
|
1305 + ERROR("FATAL_ERROR: Compressor \"%s\" is not "
|
pascal@4702
|
1306 + "supported!\n", comp_name);
|
pascal@4702
|
1307 + ERROR("Compressors available:\n");
|
pascal@4702
|
1308 + display_compressors("", COMP_DEFAULT);
|
pascal@4702
|
1309 + EXIT_MKSQUASHFS();
|
pascal@4702
|
1310 + }
|
pascal@4702
|
1311 }
|
pascal@4702
|
1312
|
pascal@4702
|
1313 initialise_threads();
|
pascal@4702
|
1314 @@ -4648,8 +4834,8 @@
|
pascal@4702
|
1315 "size %d\n", SQUASHFS_MAJOR, s_minor, argv[source + 1],
|
pascal@4702
|
1316 block_size);
|
pascal@4702
|
1317 printf("All -b, -noI, -noD, -noF, no-duplicates, no-fragments, "
|
pascal@4702
|
1318 - "-always-use-fragments and -exportable options ignored"
|
pascal@4702
|
1319 - "\n");
|
pascal@4702
|
1320 + "-always-use-fragments,\n-exportable and -comp options "
|
pascal@4702
|
1321 + "ignored\n");
|
pascal@4702
|
1322 printf("\nIf appending is not wanted, please re-run with "
|
pascal@4702
|
1323 "-noappend specified!\n\n");
|
pascal@4702
|
1324
|
pascal@4702
|
1325 @@ -4803,8 +4989,7 @@
|
pascal@4702
|
1326
|
pascal@4702
|
1327 sBlk.bytes_used = bytes;
|
pascal@4702
|
1328
|
pascal@4702
|
1329 - /* Only compression supported */
|
pascal@4702
|
1330 - sBlk.compression = ZLIB_COMPRESSION;
|
pascal@4702
|
1331 + sBlk.compression = comp->id;
|
pascal@4702
|
1332
|
pascal@4702
|
1333 /* Xattrs are not currently supported */
|
pascal@4702
|
1334 sBlk.xattr_table_start = SQUASHFS_INVALID_BLK;
|
pascal@4702
|
1335 @@ -4820,6 +5005,8 @@
|
pascal@4702
|
1336
|
pascal@4702
|
1337 close(fd);
|
pascal@4702
|
1338
|
pascal@4702
|
1339 + delete_pseudo_files();
|
pascal@4702
|
1340 +
|
pascal@4702
|
1341 if(recovery_file[0] != '\0')
|
pascal@4702
|
1342 unlink(recovery_file);
|
pascal@4702
|
1343
|
pascal@4702
|
1344 @@ -4827,9 +5014,9 @@
|
pascal@4702
|
1345 * sizeof(unsigned short) + guid_count * sizeof(unsigned short) +
|
pascal@4702
|
1346 sizeof(squashfs_super_block);
|
pascal@4702
|
1347
|
pascal@4702
|
1348 - printf("\n%sSquashfs %d.%d filesystem, data block size %d\n",
|
pascal@4702
|
1349 - exportable ? "Exportable " : "", SQUASHFS_MAJOR, SQUASHFS_MINOR,
|
pascal@4702
|
1350 - block_size);
|
pascal@4702
|
1351 + printf("\n%sSquashfs %d.%d filesystem, %s compressed, data block size"
|
pascal@4702
|
1352 + " %d\n", exportable ? "Exportable " : "", SQUASHFS_MAJOR,
|
pascal@4702
|
1353 + SQUASHFS_MINOR, comp->name, block_size);
|
pascal@4702
|
1354 printf("\t%s data, %s metadata, %s fragments\n",
|
pascal@4702
|
1355 noD ? "uncompressed" : "compressed", noI ? "uncompressed" :
|
pascal@4702
|
1356 "compressed", no_fragments ? "no" : noF ? "uncompressed" :
|
pascal@4702
|
1357
|
pascal@4702
|
1358 --- squashfs-4.0/squashfs-tools/par_mksquashfs/README Thu Jan 1 01:00:00 1970
|
pascal@4702
|
1359 +++ squashfs-4.0/squashfs-tools/par_mksquashfs/README Mon Nov 6 01:27:32 2006
|
pascal@4702
|
1360 @@ -0,0 +1,2 @@
|
pascal@4702
|
1361 +par_mksquashfs is now the standard mksquashfs, and so this directory is now empty.
|
pascal@4702
|
1362 +
|
pascal@4702
|
1363
|
pascal@4702
|
1364 --- squashfs-4.0/squashfs-tools/pseudo.c Sun Apr 5 04:01:58 2009
|
pascal@4702
|
1365 +++ squashfs-4.0/squashfs-tools/pseudo.c Thu Sep 10 06:17:48 2009
|
pascal@4702
|
1366 @@ -30,6 +30,7 @@
|
pascal@4702
|
1367 #include <string.h>
|
pascal@4702
|
1368 #include <stdlib.h>
|
pascal@4702
|
1369 #include <sys/types.h>
|
pascal@4702
|
1370 +#include <sys/wait.h>
|
pascal@4702
|
1371
|
pascal@4702
|
1372 #include "pseudo.h"
|
pascal@4702
|
1373
|
pascal@4702
|
1374 @@ -55,6 +56,9 @@
|
pascal@4702
|
1375 #define TRUE 1
|
pascal@4702
|
1376 #define FALSE 0
|
pascal@4702
|
1377
|
pascal@4702
|
1378 +struct pseudo_dev **pseudo_file = NULL;
|
pascal@4702
|
1379 +int pseudo_count = 0;
|
pascal@4702
|
1380 +
|
pascal@4702
|
1381 static void dump_pseudo(struct pseudo *pseudo, char *string)
|
pascal@4702
|
1382 {
|
pascal@4702
|
1383 int i;
|
pascal@4702
|
1384 @@ -99,7 +103,7 @@
|
pascal@4702
|
1385 char *target, char *alltarget)
|
pascal@4702
|
1386 {
|
pascal@4702
|
1387 char targname[1024];
|
pascal@4702
|
1388 - int i, error;
|
pascal@4702
|
1389 + int i;
|
pascal@4702
|
1390
|
pascal@4702
|
1391 target = get_component(target, targname);
|
pascal@4702
|
1392
|
pascal@4702
|
1393 @@ -128,12 +132,8 @@
|
pascal@4702
|
1394 if(target[0] == '\0') {
|
pascal@4702
|
1395 /* at leaf pathname component */
|
pascal@4702
|
1396 pseudo->name[i].pseudo = NULL;
|
pascal@4702
|
1397 - pseudo->name[i].dev = malloc(sizeof(struct pseudo_dev));
|
pascal@4702
|
1398 - if(pseudo->name[i].dev == NULL)
|
pascal@4702
|
1399 - BAD_ERROR("failed to allocate pseudo file\n");
|
pascal@4702
|
1400 pseudo->name[i].pathname = strdup(alltarget);
|
pascal@4702
|
1401 - memcpy(pseudo->name[i].dev, pseudo_dev,
|
pascal@4702
|
1402 - sizeof(struct pseudo_dev));
|
pascal@4702
|
1403 + pseudo->name[i].dev = pseudo_dev;
|
pascal@4702
|
1404 } else {
|
pascal@4702
|
1405 /* recurse adding child components */
|
pascal@4702
|
1406 pseudo->name[i].dev = NULL;
|
pascal@4702
|
1407 @@ -169,15 +169,9 @@
|
pascal@4702
|
1408 if(target[0] == '\0') {
|
pascal@4702
|
1409 if(pseudo->name[i].dev == NULL &&
|
pascal@4702
|
1410 pseudo_dev->type == 'd') {
|
pascal@4702
|
1411 - pseudo->name[i].dev =
|
pascal@4702
|
1412 - malloc(sizeof(struct pseudo_dev));
|
pascal@4702
|
1413 - if(pseudo->name[i].dev == NULL)
|
pascal@4702
|
1414 - BAD_ERROR("failed to allocate "
|
pascal@4702
|
1415 - "pseudo file\n");
|
pascal@4702
|
1416 pseudo->name[i].pathname =
|
pascal@4702
|
1417 strdup(alltarget);
|
pascal@4702
|
1418 - memcpy(pseudo->name[i].dev, pseudo_dev,
|
pascal@4702
|
1419 - sizeof(struct pseudo_dev));
|
pascal@4702
|
1420 + pseudo->name[i].dev = pseudo_dev;
|
pascal@4702
|
1421 } else
|
pascal@4702
|
1422 ERROR("%s already exists as a "
|
pascal@4702
|
1423 "directory. Ignoring %s!\n",
|
pascal@4702
|
1424 @@ -229,16 +223,113 @@
|
pascal@4702
|
1425 }
|
pascal@4702
|
1426
|
pascal@4702
|
1427
|
pascal@4702
|
1428 +int exec_file(char *command, struct pseudo_dev *dev)
|
pascal@4702
|
1429 +{
|
pascal@4702
|
1430 + int child, res;
|
pascal@4702
|
1431 + static pid_t pid = -1;
|
pascal@4702
|
1432 + int pipefd[2];
|
pascal@4702
|
1433 +#ifdef USE_TMP_FILE
|
pascal@4702
|
1434 + char filename[1024];
|
pascal@4702
|
1435 + int status;
|
pascal@4702
|
1436 + static int number = 0;
|
pascal@4702
|
1437 +#endif
|
pascal@4702
|
1438 +
|
pascal@4702
|
1439 + if(pid == -1)
|
pascal@4702
|
1440 + pid = getpid();
|
pascal@4702
|
1441 +
|
pascal@4702
|
1442 +#ifdef USE_TMP_FILE
|
pascal@4702
|
1443 + sprintf(filename, "/tmp/squashfs_pseudo_%d_%d", pid, number ++);
|
pascal@4702
|
1444 + pipefd[1] = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
|
pascal@4702
|
1445 + if(pipefd[1] == -1) {
|
pascal@4702
|
1446 + printf("open failed\n");
|
pascal@4702
|
1447 + return -1;
|
pascal@4702
|
1448 + }
|
pascal@4702
|
1449 +#else
|
pascal@4702
|
1450 + res = pipe(pipefd);
|
pascal@4702
|
1451 + if(res == -1) {
|
pascal@4702
|
1452 + printf("pipe failed\n");
|
pascal@4702
|
1453 + return -1;
|
pascal@4702
|
1454 + }
|
pascal@4702
|
1455 +#endif
|
pascal@4702
|
1456 +
|
pascal@4702
|
1457 + child = fork();
|
pascal@4702
|
1458 + if(child == -1) {
|
pascal@4702
|
1459 + printf("fork failed\n");
|
pascal@4702
|
1460 + goto failed;
|
pascal@4702
|
1461 + }
|
pascal@4702
|
1462 +
|
pascal@4702
|
1463 + if(child == 0) {
|
pascal@4702
|
1464 + close(STDOUT_FILENO);
|
pascal@4702
|
1465 + res = dup(pipefd[1]);
|
pascal@4702
|
1466 + if(res == -1) {
|
pascal@4702
|
1467 + printf("dup failed\n");
|
pascal@4702
|
1468 + exit(EXIT_FAILURE);
|
pascal@4702
|
1469 + }
|
pascal@4702
|
1470 + execl("/bin/sh", "sh", "-c", command, (char *) NULL);
|
pascal@4702
|
1471 + printf("execl failed\n");
|
pascal@4702
|
1472 + exit(EXIT_FAILURE);
|
pascal@4702
|
1473 + }
|
pascal@4702
|
1474 +
|
pascal@4702
|
1475 +#ifdef USE_TMP_FILE
|
pascal@4702
|
1476 + res = waitpid(child, &status, 0);
|
pascal@4702
|
1477 + close(pipefd[1]);
|
pascal@4702
|
1478 + if(res != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
|
pascal@4702
|
1479 + dev->filename = strdup(filename);
|
pascal@4702
|
1480 + return 0;
|
pascal@4702
|
1481 + }
|
pascal@4702
|
1482 +failed:
|
pascal@4702
|
1483 + unlink(filename);
|
pascal@4702
|
1484 + return -1;
|
pascal@4702
|
1485 +#else
|
pascal@4702
|
1486 + close(pipefd[1]);
|
pascal@4702
|
1487 + dev->fd = pipefd[0];
|
pascal@4702
|
1488 + dev->child = child;
|
pascal@4702
|
1489 + return 0;
|
pascal@4702
|
1490 +failed:
|
pascal@4702
|
1491 + return -1;
|
pascal@4702
|
1492 +#endif
|
pascal@4702
|
1493 +}
|
pascal@4702
|
1494 +
|
pascal@4702
|
1495 +
|
pascal@4702
|
1496 +void add_pseudo_file(struct pseudo_dev *dev)
|
pascal@4702
|
1497 +{
|
pascal@4702
|
1498 + pseudo_file = realloc(pseudo_file, (pseudo_count + 1) *
|
pascal@4702
|
1499 + sizeof(struct pseudo_dev *));
|
pascal@4702
|
1500 + if(pseudo_file == NULL)
|
pascal@4702
|
1501 + BAD_ERROR("Failed to realloc pseudo_file\n");
|
pascal@4702
|
1502 +
|
pascal@4702
|
1503 + dev->pseudo_id = pseudo_count;
|
pascal@4702
|
1504 + pseudo_file[pseudo_count ++] = dev;
|
pascal@4702
|
1505 +}
|
pascal@4702
|
1506 +
|
pascal@4702
|
1507 +
|
pascal@4702
|
1508 +void delete_pseudo_files()
|
pascal@4702
|
1509 +{
|
pascal@4702
|
1510 +#ifdef USE_TMP_FILE
|
pascal@4702
|
1511 + int i;
|
pascal@4702
|
1512 +
|
pascal@4702
|
1513 + for(i = 0; i < pseudo_count; i++)
|
pascal@4702
|
1514 + unlink(pseudo_file[i]->filename);
|
pascal@4702
|
1515 +#endif
|
pascal@4702
|
1516 +}
|
pascal@4702
|
1517 +
|
pascal@4702
|
1518 +
|
pascal@4702
|
1519 +struct pseudo_dev *get_pseudo_file(int pseudo_id)
|
pascal@4702
|
1520 +{
|
pascal@4702
|
1521 + return pseudo_file[pseudo_id];
|
pascal@4702
|
1522 +}
|
pascal@4702
|
1523 +
|
pascal@4702
|
1524 +
|
pascal@4702
|
1525 int read_pseudo_def(struct pseudo **pseudo, char *def)
|
pascal@4702
|
1526 {
|
pascal@4702
|
1527 - int n;
|
pascal@4702
|
1528 + int n, bytes;
|
pascal@4702
|
1529 unsigned int major = 0, minor = 0, mode;
|
pascal@4702
|
1530 char filename[2048], type, suid[100], sgid[100], *ptr;
|
pascal@4702
|
1531 long long uid, gid;
|
pascal@4702
|
1532 - struct pseudo_dev dev;
|
pascal@4702
|
1533 + struct pseudo_dev *dev;
|
pascal@4702
|
1534
|
pascal@4702
|
1535 - n = sscanf(def, "%s %c %o %s %s %u %u", filename, &type, &mode, suid, sgid,
|
pascal@4702
|
1536 - &major, &minor);
|
pascal@4702
|
1537 + n = sscanf(def, "%s %c %o %s %s %n", filename, &type, &mode, suid,
|
pascal@4702
|
1538 + sgid, &bytes);
|
pascal@4702
|
1539
|
pascal@4702
|
1540 if(n < 5) {
|
pascal@4702
|
1541 ERROR("Not enough or invalid arguments in pseudo file "
|
pascal@4702
|
1542 @@ -249,7 +340,9 @@
|
pascal@4702
|
1543 switch(type) {
|
pascal@4702
|
1544 case 'b':
|
pascal@4702
|
1545 case 'c':
|
pascal@4702
|
1546 - if(n < 7) {
|
pascal@4702
|
1547 + n = sscanf(def + bytes, "%u %u", &major, &minor);
|
pascal@4702
|
1548 +
|
pascal@4702
|
1549 + if(n < 2) {
|
pascal@4702
|
1550 ERROR("Not enough or invalid arguments in pseudo file "
|
pascal@4702
|
1551 "definition\n");
|
pascal@4702
|
1552 goto error;
|
pascal@4702
|
1553 @@ -265,54 +358,59 @@
|
pascal@4702
|
1554 goto error;
|
pascal@4702
|
1555 }
|
pascal@4702
|
1556
|
pascal@4702
|
1557 - /* fall through */
|
pascal@4702
|
1558 - case 'd':
|
pascal@4702
|
1559 - if(mode > 0777) {
|
pascal@4702
|
1560 - ERROR("Mode %o out of range\n", mode);
|
pascal@4702
|
1561 + case 'f':
|
pascal@4702
|
1562 + if(def[bytes] == '\0') {
|
pascal@4702
|
1563 + ERROR("Not enough arguments in pseudo file "
|
pascal@4702
|
1564 + "definition\n");
|
pascal@4702
|
1565 goto error;
|
pascal@4702
|
1566 - }
|
pascal@4702
|
1567 -
|
pascal@4702
|
1568 - uid = strtoll(suid, &ptr, 10);
|
pascal@4702
|
1569 - if(*ptr == '\0') {
|
pascal@4702
|
1570 - if(uid < 0 || uid > ((1LL << 32) - 1)) {
|
pascal@4702
|
1571 - ERROR("Uid %s out of range\n", suid);
|
pascal@4702
|
1572 - goto error;
|
pascal@4702
|
1573 - }
|
pascal@4702
|
1574 - } else {
|
pascal@4702
|
1575 - struct passwd *pwuid = getpwnam(suid);
|
pascal@4702
|
1576 - if(pwuid)
|
pascal@4702
|
1577 - uid = pwuid->pw_uid;
|
pascal@4702
|
1578 - else {
|
pascal@4702
|
1579 - ERROR("Uid %s invalid uid or unknown user\n",
|
pascal@4702
|
1580 - suid);
|
pascal@4702
|
1581 - goto error;
|
pascal@4702
|
1582 - }
|
pascal@4702
|
1583 - }
|
pascal@4702
|
1584 -
|
pascal@4702
|
1585 - gid = strtoll(sgid, &ptr, 10);
|
pascal@4702
|
1586 - if(*ptr == '\0') {
|
pascal@4702
|
1587 - if(gid < 0 || gid > ((1LL << 32) - 1)) {
|
pascal@4702
|
1588 - ERROR("Gid %s out of range\n", sgid);
|
pascal@4702
|
1589 - goto error;
|
pascal@4702
|
1590 - }
|
pascal@4702
|
1591 - } else {
|
pascal@4702
|
1592 - struct group *grgid = getgrnam(sgid);
|
pascal@4702
|
1593 - if(grgid)
|
pascal@4702
|
1594 - gid = grgid->gr_gid;
|
pascal@4702
|
1595 - else {
|
pascal@4702
|
1596 - ERROR("Gid %s invalid uid or unknown user\n",
|
pascal@4702
|
1597 - sgid);
|
pascal@4702
|
1598 - goto error;
|
pascal@4702
|
1599 - }
|
pascal@4702
|
1600 - }
|
pascal@4702
|
1601 -
|
pascal@4702
|
1602 + }
|
pascal@4702
|
1603 break;
|
pascal@4702
|
1604 + case 'd':
|
pascal@4702
|
1605 + case 'm':
|
pascal@4702
|
1606 + break;
|
pascal@4702
|
1607 default:
|
pascal@4702
|
1608 ERROR("Unsupported type %c\n", type);
|
pascal@4702
|
1609 goto error;
|
pascal@4702
|
1610 }
|
pascal@4702
|
1611
|
pascal@4702
|
1612
|
pascal@4702
|
1613 + if(mode > 0777) {
|
pascal@4702
|
1614 + ERROR("Mode %o out of range\n", mode);
|
pascal@4702
|
1615 + goto error;
|
pascal@4702
|
1616 + }
|
pascal@4702
|
1617 +
|
pascal@4702
|
1618 + uid = strtoll(suid, &ptr, 10);
|
pascal@4702
|
1619 + if(*ptr == '\0') {
|
pascal@4702
|
1620 + if(uid < 0 || uid > ((1LL << 32) - 1)) {
|
pascal@4702
|
1621 + ERROR("Uid %s out of range\n", suid);
|
pascal@4702
|
1622 + goto error;
|
pascal@4702
|
1623 + }
|
pascal@4702
|
1624 + } else {
|
pascal@4702
|
1625 + struct passwd *pwuid = getpwnam(suid);
|
pascal@4702
|
1626 + if(pwuid)
|
pascal@4702
|
1627 + uid = pwuid->pw_uid;
|
pascal@4702
|
1628 + else {
|
pascal@4702
|
1629 + ERROR("Uid %s invalid uid or unknown user\n", suid);
|
pascal@4702
|
1630 + goto error;
|
pascal@4702
|
1631 + }
|
pascal@4702
|
1632 + }
|
pascal@4702
|
1633 +
|
pascal@4702
|
1634 + gid = strtoll(sgid, &ptr, 10);
|
pascal@4702
|
1635 + if(*ptr == '\0') {
|
pascal@4702
|
1636 + if(gid < 0 || gid > ((1LL << 32) - 1)) {
|
pascal@4702
|
1637 + ERROR("Gid %s out of range\n", sgid);
|
pascal@4702
|
1638 + goto error;
|
pascal@4702
|
1639 + }
|
pascal@4702
|
1640 + } else {
|
pascal@4702
|
1641 + struct group *grgid = getgrnam(sgid);
|
pascal@4702
|
1642 + if(grgid)
|
pascal@4702
|
1643 + gid = grgid->gr_gid;
|
pascal@4702
|
1644 + else {
|
pascal@4702
|
1645 + ERROR("Gid %s invalid uid or unknown user\n", sgid);
|
pascal@4702
|
1646 + goto error;
|
pascal@4702
|
1647 + }
|
pascal@4702
|
1648 + }
|
pascal@4702
|
1649 +
|
pascal@4702
|
1650 switch(type) {
|
pascal@4702
|
1651 case 'b':
|
pascal@4702
|
1652 mode |= S_IFBLK;
|
pascal@4702
|
1653 @@ -323,16 +421,37 @@
|
pascal@4702
|
1654 case 'd':
|
pascal@4702
|
1655 mode |= S_IFDIR;
|
pascal@4702
|
1656 break;
|
pascal@4702
|
1657 + case 'f':
|
pascal@4702
|
1658 + mode |= S_IFREG;
|
pascal@4702
|
1659 + break;
|
pascal@4702
|
1660 }
|
pascal@4702
|
1661
|
pascal@4702
|
1662 - dev.type = type;
|
pascal@4702
|
1663 - dev.mode = mode;
|
pascal@4702
|
1664 - dev.uid = uid;
|
pascal@4702
|
1665 - dev.gid = gid;
|
pascal@4702
|
1666 - dev.major = major;
|
pascal@4702
|
1667 - dev.minor = minor;
|
pascal@4702
|
1668 + dev = malloc(sizeof(struct pseudo_dev));
|
pascal@4702
|
1669 + if(dev == NULL)
|
pascal@4702
|
1670 + BAD_ERROR("Failed to create pseudo_dev\n");
|
pascal@4702
|
1671
|
pascal@4702
|
1672 - *pseudo = add_pseudo(*pseudo, &dev, filename, filename);
|
pascal@4702
|
1673 + dev->type = type;
|
pascal@4702
|
1674 + dev->mode = mode;
|
pascal@4702
|
1675 + dev->uid = uid;
|
pascal@4702
|
1676 + dev->gid = gid;
|
pascal@4702
|
1677 + dev->major = major;
|
pascal@4702
|
1678 + dev->minor = minor;
|
pascal@4702
|
1679 +
|
pascal@4702
|
1680 + if(type == 'f') {
|
pascal@4702
|
1681 + int res;
|
pascal@4702
|
1682 +
|
pascal@4702
|
1683 + printf("Executing dynamic pseudo file\n");
|
pascal@4702
|
1684 + printf("\t\"%s\"\n", def);
|
pascal@4702
|
1685 + res = exec_file(def + bytes, dev);
|
pascal@4702
|
1686 + if(res == -1) {
|
pascal@4702
|
1687 + ERROR("Failed to execute dynamic pseudo file definition"
|
pascal@4702
|
1688 + " \"%s\"\n", def);
|
pascal@4702
|
1689 + return FALSE;
|
pascal@4702
|
1690 + }
|
pascal@4702
|
1691 + add_pseudo_file(dev);
|
pascal@4702
|
1692 + }
|
pascal@4702
|
1693 +
|
pascal@4702
|
1694 + *pseudo = add_pseudo(*pseudo, dev, filename, filename);
|
pascal@4702
|
1695
|
pascal@4702
|
1696 return TRUE;
|
pascal@4702
|
1697
|
pascal@4702
|
1698
|
pascal@4702
|
1699 --- squashfs-4.0/squashfs-tools/pseudo.h Sat Apr 4 03:44:24 2009
|
pascal@4702
|
1700 +++ squashfs-4.0/squashfs-tools/pseudo.h Fri Sep 11 14:10:58 2009
|
pascal@4702
|
1701 @@ -27,6 +27,12 @@
|
pascal@4702
|
1702 unsigned int gid;
|
pascal@4702
|
1703 unsigned int major;
|
pascal@4702
|
1704 unsigned int minor;
|
pascal@4702
|
1705 + int pseudo_id;
|
pascal@4702
|
1706 + int fd;
|
pascal@4702
|
1707 + int child;
|
pascal@4702
|
1708 +#ifdef USE_TMP_FILE
|
pascal@4702
|
1709 + char *filename;
|
pascal@4702
|
1710 +#endif
|
pascal@4702
|
1711 };
|
pascal@4702
|
1712
|
pascal@4702
|
1713 struct pseudo_entry {
|
pascal@4702
|
1714 @@ -46,3 +52,5 @@
|
pascal@4702
|
1715 extern int read_pseudo_file(struct pseudo **, char *);
|
pascal@4702
|
1716 extern struct pseudo *pseudo_subdir(char *, struct pseudo *);
|
pascal@4702
|
1717 extern struct pseudo_entry *pseudo_readdir(struct pseudo *);
|
pascal@4702
|
1718 +extern struct pseudo_dev *get_pseudo_file(int);
|
pascal@4702
|
1719 +extern void delete_pseudo_files();
|
pascal@4702
|
1720
|
pascal@4702
|
1721 --- squashfs-4.0/squashfs-tools/read_fs.c Tue Mar 31 06:23:14 2009
|
pascal@4702
|
1722 +++ squashfs-4.0/squashfs-tools/read_fs.c Mon Aug 24 20:28:04 2009
|
pascal@4702
|
1723 @@ -36,7 +36,6 @@
|
pascal@4702
|
1724 #include <fcntl.h>
|
pascal@4702
|
1725 #include <errno.h>
|
pascal@4702
|
1726 #include <string.h>
|
pascal@4702
|
1727 -#include <zlib.h>
|
pascal@4702
|
1728 #include <sys/mman.h>
|
pascal@4702
|
1729
|
pascal@4702
|
1730 #ifndef linux
|
pascal@4702
|
1731 @@ -51,6 +50,7 @@
|
pascal@4702
|
1732 #include "squashfs_swap.h"
|
pascal@4702
|
1733 #include "read_fs.h"
|
pascal@4702
|
1734 #include "global.h"
|
pascal@4702
|
1735 +#include "compressor.h"
|
pascal@4702
|
1736
|
pascal@4702
|
1737 #include <stdlib.h>
|
pascal@4702
|
1738
|
pascal@4702
|
1739 @@ -66,7 +66,9 @@
|
pascal@4702
|
1740 fprintf(stderr, s, ## args); \
|
pascal@4702
|
1741 } while(0)
|
pascal@4702
|
1742
|
pascal@4702
|
1743 -int read_block(int fd, long long start, long long *next, unsigned char *block,
|
pascal@4702
|
1744 +static struct compressor *comp;
|
pascal@4702
|
1745 +
|
pascal@4702
|
1746 +int read_block(int fd, long long start, long long *next, void *block,
|
pascal@4702
|
1747 squashfs_super_block *sBlk)
|
pascal@4702
|
1748 {
|
pascal@4702
|
1749 unsigned short c_byte;
|
pascal@4702
|
1750 @@ -77,32 +79,24 @@
|
pascal@4702
|
1751
|
pascal@4702
|
1752 if(SQUASHFS_COMPRESSED(c_byte)) {
|
pascal@4702
|
1753 char buffer[SQUASHFS_METADATA_SIZE];
|
pascal@4702
|
1754 - int res;
|
pascal@4702
|
1755 - unsigned long bytes = SQUASHFS_METADATA_SIZE;
|
pascal@4702
|
1756 + int error, res;
|
pascal@4702
|
1757
|
pascal@4702
|
1758 c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
|
pascal@4702
|
1759 read_destination(fd, start + offset, c_byte, buffer);
|
pascal@4702
|
1760
|
pascal@4702
|
1761 - res = uncompress(block, &bytes, (const unsigned char *) buffer,
|
pascal@4702
|
1762 - c_byte);
|
pascal@4702
|
1763 - if(res != Z_OK) {
|
pascal@4702
|
1764 - if(res == Z_MEM_ERROR)
|
pascal@4702
|
1765 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
1766 - "memory\n");
|
pascal@4702
|
1767 - else if(res == Z_BUF_ERROR)
|
pascal@4702
|
1768 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
1769 - "room in output buffer\n");
|
pascal@4702
|
1770 - else
|
pascal@4702
|
1771 - ERROR("zlib::uncompress failed, unknown error "
|
pascal@4702
|
1772 - "%d\n", res);
|
pascal@4702
|
1773 + res = comp->uncompress(block, buffer, c_byte,
|
pascal@4702
|
1774 + SQUASHFS_METADATA_SIZE, &error);
|
pascal@4702
|
1775 + if(res == -1) {
|
pascal@4702
|
1776 + ERROR("%s uncompress failed with error code %d\n",
|
pascal@4702
|
1777 + comp->name, error);
|
pascal@4702
|
1778 return 0;
|
pascal@4702
|
1779 }
|
pascal@4702
|
1780 if(next)
|
pascal@4702
|
1781 *next = start + offset + c_byte;
|
pascal@4702
|
1782 - return bytes;
|
pascal@4702
|
1783 + return res;
|
pascal@4702
|
1784 } else {
|
pascal@4702
|
1785 c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
|
pascal@4702
|
1786 - read_destination(fd, start + offset, c_byte, (char *) block);
|
pascal@4702
|
1787 + read_destination(fd, start + offset, c_byte, block);
|
pascal@4702
|
1788 if(next)
|
pascal@4702
|
1789 *next = start + offset + c_byte;
|
pascal@4702
|
1790 return c_byte;
|
pascal@4702
|
1791 @@ -356,7 +350,7 @@
|
pascal@4702
|
1792 }
|
pascal@4702
|
1793
|
pascal@4702
|
1794
|
pascal@4702
|
1795 -int read_super(int fd, squashfs_super_block *sBlk, char *source)
|
pascal@4702
|
1796 +struct compressor *read_super(int fd, squashfs_super_block *sBlk, char *source)
|
pascal@4702
|
1797 {
|
pascal@4702
|
1798 read_destination(fd, SQUASHFS_START, sizeof(squashfs_super_block),
|
pascal@4702
|
1799 (char *) sBlk);
|
pascal@4702
|
1800 @@ -388,8 +382,18 @@
|
pascal@4702
|
1801 goto failed_mount;
|
pascal@4702
|
1802 }
|
pascal@4702
|
1803
|
pascal@4702
|
1804 + /* Check the compression type */
|
pascal@4702
|
1805 + comp = lookup_compressor_id(sBlk->compression);
|
pascal@4702
|
1806 + if(!comp->supported) {
|
pascal@4702
|
1807 + ERROR("Filesystem on %s uses %s compression, this is"
|
pascal@4702
|
1808 + "unsupported by this version\n", source, comp->name);
|
pascal@4702
|
1809 + display_compressors("", "");
|
pascal@4702
|
1810 + goto failed_mount;
|
pascal@4702
|
1811 + }
|
pascal@4702
|
1812 +
|
pascal@4702
|
1813 printf("Found a valid %sSQUASHFS superblock on %s.\n",
|
pascal@4702
|
1814 SQUASHFS_EXPORTABLE(sBlk->flags) ? "exportable " : "", source);
|
pascal@4702
|
1815 + printf("\tCompression used %s\n", comp->name);
|
pascal@4702
|
1816 printf("\tInodes are %scompressed\n",
|
pascal@4702
|
1817 SQUASHFS_UNCOMPRESSED_INODES(sBlk->flags) ? "un" : "");
|
pascal@4702
|
1818 printf("\tData is %scompressed\n",
|
pascal@4702
|
1819 @@ -417,10 +421,10 @@
|
pascal@4702
|
1820 TRACE("sBlk->lookup_table_start %llx\n", sBlk->lookup_table_start);
|
pascal@4702
|
1821 printf("\n");
|
pascal@4702
|
1822
|
pascal@4702
|
1823 - return TRUE;
|
pascal@4702
|
1824 + return comp;
|
pascal@4702
|
1825
|
pascal@4702
|
1826 failed_mount:
|
pascal@4702
|
1827 - return FALSE;
|
pascal@4702
|
1828 + return NULL;
|
pascal@4702
|
1829 }
|
pascal@4702
|
1830
|
pascal@4702
|
1831
|
pascal@4702
|
1832 @@ -514,12 +518,17 @@
|
pascal@4702
|
1833 SQUASHFS_INSWAP_ID_BLOCKS(index, indexes);
|
pascal@4702
|
1834
|
pascal@4702
|
1835 for(i = 0; i < indexes; i++) {
|
pascal@4702
|
1836 - int length;
|
pascal@4702
|
1837 - length = read_block(fd, index[i], NULL,
|
pascal@4702
|
1838 + int length = read_block(fd, index[i], NULL,
|
pascal@4702
|
1839 ((unsigned char *) id_table) +
|
pascal@4702
|
1840 (i * SQUASHFS_METADATA_SIZE), sBlk);
|
pascal@4702
|
1841 TRACE("Read id table block %d, from 0x%llx, length %d\n", i,
|
pascal@4702
|
1842 index[i], length);
|
pascal@4702
|
1843 + if(length == 0) {
|
pascal@4702
|
1844 + ERROR("Failed to read id table block %d, from 0x%llx, "
|
pascal@4702
|
1845 + "length %d\n", i, index[i], length);
|
pascal@4702
|
1846 + free(id_table);
|
pascal@4702
|
1847 + return NULL;
|
pascal@4702
|
1848 + }
|
pascal@4702
|
1849 }
|
pascal@4702
|
1850
|
pascal@4702
|
1851 SQUASHFS_INSWAP_INTS(id_table, sBlk->no_ids);
|
pascal@4702
|
1852 @@ -563,6 +572,13 @@
|
pascal@4702
|
1853 (i * SQUASHFS_METADATA_SIZE), sBlk);
|
pascal@4702
|
1854 TRACE("Read fragment table block %d, from 0x%llx, length %d\n",
|
pascal@4702
|
1855 i, fragment_table_index[i], length);
|
pascal@4702
|
1856 + if(length == 0) {
|
pascal@4702
|
1857 + ERROR("Failed to read fragment table block %d, from "
|
pascal@4702
|
1858 + "0x%llx, length %d\n", i,
|
pascal@4702
|
1859 + fragment_table_index[i], length);
|
pascal@4702
|
1860 + free(*fragment_table);
|
pascal@4702
|
1861 + return 0;
|
pascal@4702
|
1862 + }
|
pascal@4702
|
1863 }
|
pascal@4702
|
1864
|
pascal@4702
|
1865 for(i = 0; i < sBlk->fragments; i++)
|
pascal@4702
|
1866 @@ -599,6 +615,13 @@
|
pascal@4702
|
1867 (i * SQUASHFS_METADATA_SIZE), sBlk);
|
pascal@4702
|
1868 TRACE("Read inode lookup table block %d, from 0x%llx, length "
|
pascal@4702
|
1869 "%d\n", i, index[i], length);
|
pascal@4702
|
1870 + if(length == 0) {
|
pascal@4702
|
1871 + ERROR("Failed to read inode lookup table block %d, "
|
pascal@4702
|
1872 + "from 0x%llx, length %d\n", i, index[i],
|
pascal@4702
|
1873 + length);
|
pascal@4702
|
1874 + free(*inode_lookup_table);
|
pascal@4702
|
1875 + return 0;
|
pascal@4702
|
1876 + }
|
pascal@4702
|
1877 }
|
pascal@4702
|
1878
|
pascal@4702
|
1879 SQUASHFS_INSWAP_LONG_LONGS(*inode_lookup_table, sBlk->inodes);
|
pascal@4702
|
1880
|
pascal@4702
|
1881 --- squashfs-4.0/squashfs-tools/sort.c Tue Mar 31 06:25:53 2009
|
pascal@4702
|
1882 +++ squashfs-4.0/squashfs-tools/sort.c Sat Aug 29 07:41:45 2009
|
pascal@4702
|
1883 @@ -198,7 +198,7 @@
|
pascal@4702
|
1884 while(dir->current_count < dir->count) {
|
pascal@4702
|
1885 struct dir_ent *dir_ent = dir->list[dir->current_count++];
|
pascal@4702
|
1886 struct stat *buf = &dir_ent->inode->buf;
|
pascal@4702
|
1887 - if(dir_ent->data)
|
pascal@4702
|
1888 + if(dir_ent->inode->root_entry)
|
pascal@4702
|
1889 continue;
|
pascal@4702
|
1890
|
pascal@4702
|
1891 switch(buf->st_mode & S_IFMT) {
|
pascal@4702
|
1892 @@ -254,6 +254,7 @@
|
pascal@4702
|
1893 write_file(&inode, entry->dir, &duplicate_file);
|
pascal@4702
|
1894 INFO("file %s, uncompressed size %lld bytes %s"
|
pascal@4702
|
1895 "\n", entry->dir->pathname,
|
pascal@4702
|
1896 + (long long)
|
pascal@4702
|
1897 entry->dir->inode->buf.st_size,
|
pascal@4702
|
1898 duplicate_file ? "DUPLICATE" : "");
|
pascal@4702
|
1899 entry->dir->inode->inode = inode;
|
pascal@4702
|
1900 @@ -261,6 +262,7 @@
|
pascal@4702
|
1901 } else
|
pascal@4702
|
1902 INFO("file %s, uncompressed size %lld bytes "
|
pascal@4702
|
1903 "LINK\n", entry->dir->pathname,
|
pascal@4702
|
1904 + (long long)
|
pascal@4702
|
1905 entry->dir->inode->buf.st_size);
|
pascal@4702
|
1906 }
|
pascal@4702
|
1907 }
|
pascal@4702
|
1908
|
pascal@4702
|
1909 --- squashfs-4.0/squashfs-tools/sort.h Sun Feb 8 13:02:53 2009
|
pascal@4702
|
1910 +++ squashfs-4.0/squashfs-tools/sort.h Thu Sep 10 05:50:01 2009
|
pascal@4702
|
1911 @@ -42,17 +42,19 @@
|
pascal@4702
|
1912 struct inode_info *inode;
|
pascal@4702
|
1913 struct dir_info *dir;
|
pascal@4702
|
1914 struct dir_info *our_dir;
|
pascal@4702
|
1915 - struct old_root_entry_info *data;
|
pascal@4702
|
1916 };
|
pascal@4702
|
1917
|
pascal@4702
|
1918 struct inode_info {
|
pascal@4702
|
1919 - unsigned int nlink;
|
pascal@4702
|
1920 struct stat buf;
|
pascal@4702
|
1921 + struct inode_info *next;
|
pascal@4702
|
1922 squashfs_inode inode;
|
pascal@4702
|
1923 - unsigned int type;
|
pascal@4702
|
1924 unsigned int inode_number;
|
pascal@4702
|
1925 + unsigned int nlink;
|
pascal@4702
|
1926 + int pseudo_id;
|
pascal@4702
|
1927 + char type;
|
pascal@4702
|
1928 char read;
|
pascal@4702
|
1929 - struct inode_info *next;
|
pascal@4702
|
1930 + char root_entry;
|
pascal@4702
|
1931 + char pseudo_file;
|
pascal@4702
|
1932 };
|
pascal@4702
|
1933
|
pascal@4702
|
1934 struct priority_entry {
|
pascal@4702
|
1935
|
pascal@4702
|
1936 --- squashfs-4.0/squashfs-tools/squashfs_compat.h Mon Mar 16 05:27:27 2009
|
pascal@4702
|
1937 +++ squashfs-4.0/squashfs-tools/squashfs_compat.h Tue Apr 21 02:52:24 2009
|
pascal@4702
|
1938 @@ -777,11 +777,10 @@
|
pascal@4702
|
1939 #endif
|
pascal@4702
|
1940
|
pascal@4702
|
1941 #define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
|
pascal@4702
|
1942 - int bits;\
|
pascal@4702
|
1943 - int b_pos = pos % 8;\
|
pascal@4702
|
1944 - unsigned long long val = 0;\
|
pascal@4702
|
1945 - unsigned char *s = (unsigned char *)p + (pos / 8);\
|
pascal@4702
|
1946 - unsigned char *d = ((unsigned char *) &val) + 7;\
|
pascal@4702
|
1947 + b_pos = pos % 8;\
|
pascal@4702
|
1948 + val = 0;\
|
pascal@4702
|
1949 + s = (unsigned char *)p + (pos / 8);\
|
pascal@4702
|
1950 + d = ((unsigned char *) &val) + 7;\
|
pascal@4702
|
1951 for(bits = 0; bits < (tbits + b_pos); bits += 8) \
|
pascal@4702
|
1952 *d-- = *s++;\
|
pascal@4702
|
1953 value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
|
pascal@4702
|
1954
|
pascal@4702
|
1955 --- squashfs-4.0/squashfs-tools/squashfs_fs.h Wed Mar 18 03:50:20 2009
|
pascal@4702
|
1956 +++ squashfs-4.0/squashfs-tools/squashfs_fs.h Thu Jul 30 06:45:38 2009
|
pascal@4702
|
1957 @@ -229,6 +229,7 @@
|
pascal@4702
|
1958 typedef long long squashfs_inode_t;
|
pascal@4702
|
1959
|
pascal@4702
|
1960 #define ZLIB_COMPRESSION 1
|
pascal@4702
|
1961 +#define LZMA_COMPRESSION 2
|
pascal@4702
|
1962
|
pascal@4702
|
1963 struct squashfs_super_block {
|
pascal@4702
|
1964 unsigned int s_magic;
|
pascal@4702
|
1965
|
pascal@4702
|
1966 --- squashfs-4.0/squashfs-tools/unsquash-3.c Tue Mar 31 06:35:10 2009
|
pascal@4702
|
1967 +++ squashfs-4.0/squashfs-tools/unsquash-3.c Tue Apr 21 02:58:22 2009
|
pascal@4702
|
1968 @@ -36,7 +36,7 @@
|
pascal@4702
|
1969 sBlk.fragment_table_start);
|
pascal@4702
|
1970
|
pascal@4702
|
1971 if(sBlk.fragments == 0)
|
pascal@4702
|
1972 - return;
|
pascal@4702
|
1973 + return TRUE;
|
pascal@4702
|
1974
|
pascal@4702
|
1975 if((fragment_table = malloc(sBlk.fragments *
|
pascal@4702
|
1976 sizeof(squashfs_fragment_entry_3))) == NULL)
|
pascal@4702
|
1977
|
pascal@4702
|
1978 --- squashfs-4.0/squashfs-tools/unsquash-4.c Tue Mar 31 06:38:31 2009
|
pascal@4702
|
1979 +++ squashfs-4.0/squashfs-tools/unsquash-4.c Tue Apr 21 02:59:16 2009
|
pascal@4702
|
1980 @@ -38,7 +38,7 @@
|
pascal@4702
|
1981 sBlk.fragment_table_start);
|
pascal@4702
|
1982
|
pascal@4702
|
1983 if(sBlk.fragments == 0)
|
pascal@4702
|
1984 - return;
|
pascal@4702
|
1985 + return TRUE;
|
pascal@4702
|
1986
|
pascal@4702
|
1987 if((fragment_table = malloc(sBlk.fragments *
|
pascal@4702
|
1988 sizeof(squashfs_fragment_entry))) == NULL)
|
pascal@4702
|
1989
|
pascal@4702
|
1990 --- squashfs-4.0/squashfs-tools/unsquashfs.c Sun Apr 5 23:23:06 2009
|
pascal@4702
|
1991 +++ squashfs-4.0/squashfs-tools/unsquashfs.c Sun Aug 30 16:10:31 2009
|
pascal@4702
|
1992 @@ -25,7 +25,10 @@
|
pascal@4702
|
1993 #include "squashfs_swap.h"
|
pascal@4702
|
1994 #include "squashfs_compat.h"
|
pascal@4702
|
1995 #include "read_fs.h"
|
pascal@4702
|
1996 +#include "compressor.h"
|
pascal@4702
|
1997
|
pascal@4702
|
1998 +#include <sys/sysinfo.h>
|
pascal@4702
|
1999 +
|
pascal@4702
|
2000 struct cache *fragment_cache, *data_cache;
|
pascal@4702
|
2001 struct queue *to_reader, *to_deflate, *to_writer, *from_writer;
|
pascal@4702
|
2002 pthread_t *thread, *deflator_thread;
|
pascal@4702
|
2003 @@ -36,6 +39,7 @@
|
pascal@4702
|
2004
|
pascal@4702
|
2005 struct super_block sBlk;
|
pascal@4702
|
2006 squashfs_operations s_ops;
|
pascal@4702
|
2007 +struct compressor *comp;
|
pascal@4702
|
2008
|
pascal@4702
|
2009 int bytes = 0, swap, file_count = 0, dir_count = 0, sym_count = 0,
|
pascal@4702
|
2010 dev_count = 0, fifo_count = 0;
|
pascal@4702
|
2011 @@ -590,31 +594,23 @@
|
pascal@4702
|
2012 offset = 3;
|
pascal@4702
|
2013 if(SQUASHFS_COMPRESSED(c_byte)) {
|
pascal@4702
|
2014 char buffer[SQUASHFS_METADATA_SIZE];
|
pascal@4702
|
2015 - int res;
|
pascal@4702
|
2016 - unsigned long bytes = SQUASHFS_METADATA_SIZE;
|
pascal@4702
|
2017 + int error, res;
|
pascal@4702
|
2018
|
pascal@4702
|
2019 c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
|
pascal@4702
|
2020 if(read_bytes(start + offset, c_byte, buffer) == FALSE)
|
pascal@4702
|
2021 goto failed;
|
pascal@4702
|
2022
|
pascal@4702
|
2023 - res = uncompress((unsigned char *) block, &bytes,
|
pascal@4702
|
2024 - (const unsigned char *) buffer, c_byte);
|
pascal@4702
|
2025 + res = comp->uncompress(block, buffer, c_byte,
|
pascal@4702
|
2026 + SQUASHFS_METADATA_SIZE, &error);
|
pascal@4702
|
2027
|
pascal@4702
|
2028 - if(res != Z_OK) {
|
pascal@4702
|
2029 - if(res == Z_MEM_ERROR)
|
pascal@4702
|
2030 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
2031 - "memory\n");
|
pascal@4702
|
2032 - else if(res == Z_BUF_ERROR)
|
pascal@4702
|
2033 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
2034 - "room in output buffer\n");
|
pascal@4702
|
2035 - else
|
pascal@4702
|
2036 - ERROR("zlib::uncompress failed, unknown error "
|
pascal@4702
|
2037 - "%d\n", res);
|
pascal@4702
|
2038 + if(res == -1) {
|
pascal@4702
|
2039 + ERROR("%s uncompress failed with error code %d\n",
|
pascal@4702
|
2040 + comp->name, error);
|
pascal@4702
|
2041 goto failed;
|
pascal@4702
|
2042 }
|
pascal@4702
|
2043 if(next)
|
pascal@4702
|
2044 *next = start + offset + c_byte;
|
pascal@4702
|
2045 - return bytes;
|
pascal@4702
|
2046 + return res;
|
pascal@4702
|
2047 } else {
|
pascal@4702
|
2048 c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
|
pascal@4702
|
2049 if(read_bytes(start + offset, c_byte, block) == FALSE)
|
pascal@4702
|
2050 @@ -632,36 +628,26 @@
|
pascal@4702
|
2051
|
pascal@4702
|
2052 int read_data_block(long long start, unsigned int size, char *block)
|
pascal@4702
|
2053 {
|
pascal@4702
|
2054 - int res;
|
pascal@4702
|
2055 - unsigned long bytes = block_size;
|
pascal@4702
|
2056 + int error, res;
|
pascal@4702
|
2057 int c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(size);
|
pascal@4702
|
2058
|
pascal@4702
|
2059 TRACE("read_data_block: block @0x%llx, %d %s bytes\n", start,
|
pascal@4702
|
2060 - SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte),
|
pascal@4702
|
2061 - SQUASHFS_COMPRESSED_BLOCK(c_byte) ? "compressed" :
|
pascal@4702
|
2062 + c_byte, SQUASHFS_COMPRESSED_BLOCK(size) ? "compressed" :
|
pascal@4702
|
2063 "uncompressed");
|
pascal@4702
|
2064
|
pascal@4702
|
2065 if(SQUASHFS_COMPRESSED_BLOCK(size)) {
|
pascal@4702
|
2066 if(read_bytes(start, c_byte, data) == FALSE)
|
pascal@4702
|
2067 goto failed;
|
pascal@4702
|
2068
|
pascal@4702
|
2069 - res = uncompress((unsigned char *) block, &bytes,
|
pascal@4702
|
2070 - (const unsigned char *) data, c_byte);
|
pascal@4702
|
2071 + res = comp->uncompress(block, data, c_byte, block_size, &error);
|
pascal@4702
|
2072
|
pascal@4702
|
2073 - if(res != Z_OK) {
|
pascal@4702
|
2074 - if(res == Z_MEM_ERROR)
|
pascal@4702
|
2075 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
2076 - "memory\n");
|
pascal@4702
|
2077 - else if(res == Z_BUF_ERROR)
|
pascal@4702
|
2078 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
2079 - "room in output buffer\n");
|
pascal@4702
|
2080 - else
|
pascal@4702
|
2081 - ERROR("zlib::uncompress failed, unknown error "
|
pascal@4702
|
2082 - "%d\n", res);
|
pascal@4702
|
2083 + if(res == -1) {
|
pascal@4702
|
2084 + ERROR("%s uncompress failed with error code %d\n",
|
pascal@4702
|
2085 + comp->name, error);
|
pascal@4702
|
2086 goto failed;
|
pascal@4702
|
2087 }
|
pascal@4702
|
2088
|
pascal@4702
|
2089 - return bytes;
|
pascal@4702
|
2090 + return res;
|
pascal@4702
|
2091 } else {
|
pascal@4702
|
2092 if(read_bytes(start, c_byte, block) == FALSE)
|
pascal@4702
|
2093 goto failed;
|
pascal@4702
|
2094 @@ -671,7 +657,7 @@
|
pascal@4702
|
2095
|
pascal@4702
|
2096 failed:
|
pascal@4702
|
2097 ERROR("read_data_block: failed to read block @0x%llx, size %d\n", start,
|
pascal@4702
|
2098 - size);
|
pascal@4702
|
2099 + c_byte);
|
pascal@4702
|
2100 return FALSE;
|
pascal@4702
|
2101 }
|
pascal@4702
|
2102
|
pascal@4702
|
2103 @@ -1383,6 +1369,11 @@
|
pascal@4702
|
2104 #endif
|
pascal@4702
|
2105 printf("Creation or last append time %s", mkfs_str ? mkfs_str :
|
pascal@4702
|
2106 "failed to get time\n");
|
pascal@4702
|
2107 + printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n",
|
pascal@4702
|
2108 + sBlk.bytes_used / 1024.0, sBlk.bytes_used / (1024.0 * 1024.0));
|
pascal@4702
|
2109 + if(sBlk.s_major == 4)
|
pascal@4702
|
2110 + printf("Compression %s\n", comp->name);
|
pascal@4702
|
2111 + printf("Block size %d\n", sBlk.block_size);
|
pascal@4702
|
2112 printf("Filesystem is %sexportable via NFS\n",
|
pascal@4702
|
2113 SQUASHFS_EXPORTABLE(sBlk.flags) ? "" : "not ");
|
pascal@4702
|
2114
|
pascal@4702
|
2115 @@ -1409,9 +1400,6 @@
|
pascal@4702
|
2116 SQUASHFS_DUPLICATES(sBlk.flags) ? "" : "not ");
|
pascal@4702
|
2117 else
|
pascal@4702
|
2118 printf("Duplicates are removed\n");
|
pascal@4702
|
2119 - printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n",
|
pascal@4702
|
2120 - sBlk.bytes_used / 1024.0, sBlk.bytes_used / (1024.0 * 1024.0));
|
pascal@4702
|
2121 - printf("Block size %d\n", sBlk.block_size);
|
pascal@4702
|
2122 if(sBlk.s_major > 1)
|
pascal@4702
|
2123 printf("Number of fragments %d\n", sBlk.fragments);
|
pascal@4702
|
2124 printf("Number of inodes %d\n", sBlk.inodes);
|
pascal@4702
|
2125 @@ -1459,6 +1447,18 @@
|
pascal@4702
|
2126 s_ops.read_inode = read_inode_4;
|
pascal@4702
|
2127 s_ops.read_uids_guids = read_uids_guids_4;
|
pascal@4702
|
2128 memcpy(&sBlk, &sBlk_4, sizeof(sBlk_4));
|
pascal@4702
|
2129 +
|
pascal@4702
|
2130 + /*
|
pascal@4702
|
2131 + * Check the compression type
|
pascal@4702
|
2132 + */
|
pascal@4702
|
2133 + comp = lookup_compressor_id(sBlk.compression);
|
pascal@4702
|
2134 + if(!comp->supported) {
|
pascal@4702
|
2135 + ERROR("Filesystem uses %s compression, this is "
|
pascal@4702
|
2136 + "unsupported by this version\n", comp->name);
|
pascal@4702
|
2137 + ERROR("Decompressors available:\n");
|
pascal@4702
|
2138 + display_compressors("", "");
|
pascal@4702
|
2139 + goto failed_mount;
|
pascal@4702
|
2140 + }
|
pascal@4702
|
2141 return TRUE;
|
pascal@4702
|
2142 }
|
pascal@4702
|
2143
|
pascal@4702
|
2144 @@ -1548,6 +1548,11 @@
|
pascal@4702
|
2145 goto failed_mount;
|
pascal@4702
|
2146 }
|
pascal@4702
|
2147
|
pascal@4702
|
2148 + /*
|
pascal@4702
|
2149 + * 1.x, 2.x and 3.x filesystems use gzip compression. Gzip is always
|
pascal@4702
|
2150 + * suppported.
|
pascal@4702
|
2151 + */
|
pascal@4702
|
2152 + comp = lookup_compressor("gzip");
|
pascal@4702
|
2153 return TRUE;
|
pascal@4702
|
2154
|
pascal@4702
|
2155 failed_mount:
|
pascal@4702
|
2156 @@ -1707,32 +1712,24 @@
|
pascal@4702
|
2157
|
pascal@4702
|
2158 while(1) {
|
pascal@4702
|
2159 struct cache_entry *entry = queue_get(to_deflate);
|
pascal@4702
|
2160 - int res;
|
pascal@4702
|
2161 - unsigned long bytes = block_size;
|
pascal@4702
|
2162 + int error, res;
|
pascal@4702
|
2163
|
pascal@4702
|
2164 - res = uncompress((unsigned char *) tmp, &bytes,
|
pascal@4702
|
2165 - (const unsigned char *) entry->data,
|
pascal@4702
|
2166 - SQUASHFS_COMPRESSED_SIZE_BLOCK(entry->size));
|
pascal@4702
|
2167 + res = comp->uncompress(tmp, entry->data,
|
pascal@4702
|
2168 + SQUASHFS_COMPRESSED_SIZE_BLOCK(entry->size), block_size,
|
pascal@4702
|
2169 + &error);
|
pascal@4702
|
2170
|
pascal@4702
|
2171 - if(res != Z_OK) {
|
pascal@4702
|
2172 - if(res == Z_MEM_ERROR)
|
pascal@4702
|
2173 - ERROR("zlib::uncompress failed, not enough"
|
pascal@4702
|
2174 - "memory\n");
|
pascal@4702
|
2175 - else if(res == Z_BUF_ERROR)
|
pascal@4702
|
2176 - ERROR("zlib::uncompress failed, not enough "
|
pascal@4702
|
2177 - "room in output buffer\n");
|
pascal@4702
|
2178 - else
|
pascal@4702
|
2179 - ERROR("zlib::uncompress failed, unknown error "
|
pascal@4702
|
2180 - "%d\n", res);
|
pascal@4702
|
2181 - } else
|
pascal@4702
|
2182 - memcpy(entry->data, tmp, bytes);
|
pascal@4702
|
2183 + if(res == -1)
|
pascal@4702
|
2184 + ERROR("%s uncompress failed with error code %d\n",
|
pascal@4702
|
2185 + comp->name, error);
|
pascal@4702
|
2186 + else
|
pascal@4702
|
2187 + memcpy(entry->data, tmp, res);
|
pascal@4702
|
2188
|
pascal@4702
|
2189 /*
|
pascal@4702
|
2190 * block has been either successfully decompressed, or an error
|
pascal@4702
|
2191 * occurred, clear pending flag, set error appropriately and
|
pascal@4702
|
2192 * wake up any threads waiting on this block
|
pascal@4702
|
2193 */
|
pascal@4702
|
2194 - cache_block_ready(entry, res != Z_OK);
|
pascal@4702
|
2195 + cache_block_ready(entry, res == -1);
|
pascal@4702
|
2196 }
|
pascal@4702
|
2197 }
|
pascal@4702
|
2198
|
pascal@4702
|
2199 @@ -1913,7 +1910,7 @@
|
pascal@4702
|
2200
|
pascal@4702
|
2201
|
pascal@4702
|
2202 #define VERSION() \
|
pascal@4702
|
2203 - printf("unsquashfs version 4.0 (2009/04/05)\n");\
|
pascal@4702
|
2204 + printf("unsquashfs version 4.0 (CVS 2009/08/30)\n");\
|
pascal@4702
|
2205 printf("copyright (C) 2009 Phillip Lougher <phillip@lougher.demon.co.uk>"\
|
pascal@4702
|
2206 "\n\n");\
|
pascal@4702
|
2207 printf("This program is free software; you can redistribute it and/or\n");\
|
pascal@4702
|
2208 @@ -1938,7 +1935,6 @@
|
pascal@4702
|
2209 int fragment_buffer_size = FRAGMENT_BUFFER_DEFAULT;
|
pascal@4702
|
2210 int data_buffer_size = DATA_BUFFER_DEFAULT;
|
pascal@4702
|
2211 char *b;
|
pascal@4702
|
2212 - struct winsize winsize;
|
pascal@4702
|
2213
|
pascal@4702
|
2214 pthread_mutex_init(&screen_mutex, NULL);
|
pascal@4702
|
2215 root_process = geteuid() == 0;
|
pascal@4702
|
2216 @@ -2087,6 +2083,8 @@
|
pascal@4702
|
2217 "regular expressions\n");
|
pascal@4702
|
2218 ERROR("\t\t\t\trather than use the default shell "
|
pascal@4702
|
2219 "wildcard\n\t\t\t\texpansion (globbing)\n");
|
pascal@4702
|
2220 + ERROR("\nDecompressors available:\n");
|
pascal@4702
|
2221 + display_compressors("", "");
|
pascal@4702
|
2222 }
|
pascal@4702
|
2223 exit(1);
|
pascal@4702
|
2224 }
|
pascal@4702
|
2225
|
pascal@4702
|
2226 --- squashfs-4.0/squashfs-tools/unsquashfs.h Sun Mar 29 04:29:02 2009
|
pascal@4702
|
2227 +++ squashfs-4.0/squashfs-tools/unsquashfs.h Fri Jul 31 19:24:38 2009
|
pascal@4702
|
2228 @@ -31,7 +31,6 @@
|
pascal@4702
|
2229 #include <fcntl.h>
|
pascal@4702
|
2230 #include <errno.h>
|
pascal@4702
|
2231 #include <string.h>
|
pascal@4702
|
2232 -#include <zlib.h>
|
pascal@4702
|
2233 #include <sys/mman.h>
|
pascal@4702
|
2234 #include <utime.h>
|
pascal@4702
|
2235 #include <pwd.h>
|
pascal@4704
|
2236
|
pascal@4704
|
2237 --- squashfs-4.0/squashfs-tools/squashfs_fs.h
|
pascal@4704
|
2238 +++ squashfs-4.0/squashfs-tools/squashfs_fs.h
|
pascal@4704
|
2239 @@ -28,6 +28,8 @@
|
pascal@4704
|
2240 #define SQUASHFS_MINOR 0
|
pascal@4704
|
2241 #define SQUASHFS_MAGIC 0x73717368
|
pascal@4704
|
2242 #define SQUASHFS_MAGIC_SWAP 0x68737173
|
pascal@4704
|
2243 +#define SQUASHFS_MAGIC_OLD_LZMA 0x71736873
|
pascal@4704
|
2244 +#define SQUASHFS_MAGIC_OLD_LZMA_SWAP 0x73687371
|
pascal@4704
|
2245 #define SQUASHFS_START 0
|
pascal@4704
|
2246
|
pascal@4704
|
2247 /* size of metadata (inode and directory) blocks */
|
pascal@4704
|
2248
|
pascal@4704
|
2249 --- squashfs-4.0/squashfs-tools/unsquashfs.c
|
pascal@4704
|
2250 +++ squashfs-4.0/squashfs-tools/unsquashfs.c
|
pascal@4704
|
2251 @@ -1473,8 +1473,10 @@
|
pascal@4704
|
2252 * Check it is a SQUASHFS superblock
|
pascal@4704
|
2253 */
|
pascal@4704
|
2254 swap = 0;
|
pascal@4704
|
2255 - if(sBlk_3.s_magic != SQUASHFS_MAGIC) {
|
pascal@4704
|
2256 - if(sBlk_3.s_magic == SQUASHFS_MAGIC_SWAP) {
|
pascal@4704
|
2257 + if(sBlk_3.s_magic != SQUASHFS_MAGIC &&
|
pascal@4704
|
2258 + sBlk_3.s_magic != SQUASHFS_MAGIC_OLD_LZMA) {
|
pascal@4704
|
2259 + if(sBlk_3.s_magic == SQUASHFS_MAGIC_SWAP ||
|
pascal@4704
|
2260 + sBlk_3.s_magic == SQUASHFS_MAGIC_OLD_LZMA_SWAP) {
|
pascal@4704
|
2261 squashfs_super_block_3 sblk;
|
pascal@4704
|
2262 ERROR("Reading a different endian SQUASHFS filesystem "
|
pascal@4704
|
2263 "on %s\n", source);
|
pascal@4704
|
2264 @@ -1552,7 +1554,10 @@
|
pascal@4704
|
2265 * 1.x, 2.x and 3.x filesystems use gzip compression. Gzip is always
|
pascal@4704
|
2266 * suppported.
|
pascal@4704
|
2267 */
|
pascal@4704
|
2268 - comp = lookup_compressor("gzip");
|
pascal@4704
|
2269 + if (sBlk_3.s_magic == SQUASHFS_MAGIC_OLD_LZMA ||
|
pascal@4704
|
2270 + sBlk_3.s_magic == SQUASHFS_MAGIC_OLD_LZMA_SWAP)
|
pascal@4704
|
2271 + comp = lookup_compressor("lzma");
|
pascal@4704
|
2272 + else comp = lookup_compressor("gzip");
|
pascal@4704
|
2273 return TRUE;
|
pascal@4704
|
2274
|
pascal@4704
|
2275 failed_mount:
|