Skip to content

Commit 227c10c

Browse files
committed
Unsquashfs: Add veneer functions read_[inode|directory]_data()
This is in preparation to move to dynamically reading the directory table data, rather than reading it at start-up. This is for the same reasons as previously mentioned for the inode table data. Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
1 parent 8cb2423 commit 227c10c

File tree

6 files changed

+82
-67
lines changed

6 files changed

+82
-67
lines changed

squashfs-tools/unsquash-1.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ static void read_block_list(unsigned int *block_list, long long start,
4949
if(swap_buff == NULL)
5050
MEM_ERROR();
5151

52-
res = read_metadata(swap_buff, &start, &offset, blocks * sizeof(unsigned short));
52+
res = read_inode_data(swap_buff, &start, &offset, blocks * sizeof(unsigned short));
5353
if(res == FALSE)
5454
EXIT_UNSQUASH("read_block_list: failed to read "
5555
"inode index %lld:%d\n", start, offset);
5656
SQUASHFS_SWAP_SHORTS_3(source, swap_buff, blocks);
5757
free(swap_buff);
5858
} else {
59-
res = read_metadata(source, &start, &offset, blocks * sizeof(unsigned short));
59+
res = read_inode_data(source, &start, &offset, blocks * sizeof(unsigned short));
6060
if(res == FALSE)
6161
EXIT_UNSQUASH("read_block_list: failed to read "
6262
"inode index %lld:%d\n", start, offset);
@@ -83,12 +83,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
8383

8484
if(swap) {
8585
squashfs_base_inode_header_1 sinode;
86-
res = read_metadata(&sinode, &st, &off, sizeof(sinode));
86+
res = read_inode_data(&sinode, &st, &off, sizeof(sinode));
8787
if(res)
8888
SQUASHFS_SWAP_BASE_INODE_HEADER_1(&header.base, &sinode,
8989
sizeof(squashfs_base_inode_header_1));
9090
} else
91-
res = read_metadata(&header.base, &st, &off, sizeof(header.base));
91+
res = read_inode_data(&header.base, &st, &off, sizeof(header.base));
9292

9393
if(res == FALSE)
9494
EXIT_UNSQUASH("read_inode: failed to read inode %lld:%d\n", st, off);
@@ -100,11 +100,11 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
100100

101101
if(swap) {
102102
squashfs_ipc_inode_header_1 sinodep;
103-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
103+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
104104
if(res)
105105
SQUASHFS_SWAP_IPC_INODE_HEADER_1(inodep, &sinodep);
106106
} else
107-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
107+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
108108

109109
if(res == FALSE)
110110
EXIT_UNSQUASH("read_inode: failed to read "
@@ -136,12 +136,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
136136

137137
if(swap) {
138138
squashfs_dir_inode_header_1 sinode;
139-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
139+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
140140
if(res)
141141
SQUASHFS_SWAP_DIR_INODE_HEADER_1(inode,
142142
&sinode);
143143
} else
144-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
144+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
145145

146146
if(res == FALSE)
147147
EXIT_UNSQUASH("read_inode: failed to read "
@@ -158,12 +158,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
158158

159159
if(swap) {
160160
squashfs_reg_inode_header_1 sinode;
161-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
161+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
162162
if(res)
163163
SQUASHFS_SWAP_REG_INODE_HEADER_1(inode,
164164
&sinode);
165165
} else
166-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
166+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
167167

168168
if(res == FALSE)
169169
EXIT_UNSQUASH("read_inode: failed to read "
@@ -188,12 +188,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
188188

189189
if(swap) {
190190
squashfs_symlink_inode_header_1 sinodep;
191-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
191+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
192192
if(res)
193193
SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(inodep,
194194
&sinodep);
195195
} else
196-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
196+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
197197

198198
if(res == FALSE)
199199
EXIT_UNSQUASH("read_inode: failed to read "
@@ -203,7 +203,7 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
203203
if(i.symlink == NULL)
204204
MEM_ERROR();
205205

206-
res = read_metadata(i.symlink, &start, &offset, inodep->symlink_size);
206+
res = read_inode_data(i.symlink, &start, &offset, inodep->symlink_size);
207207
if(res == FALSE)
208208
EXIT_UNSQUASH("read_inode: failed to read "
209209
"inode symbolic link %lld:%d\n", start, offset);
@@ -217,12 +217,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
217217

218218
if(swap) {
219219
squashfs_dev_inode_header_1 sinodep;
220-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
220+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
221221
if(res)
222222
SQUASHFS_SWAP_DEV_INODE_HEADER_1(inodep,
223223
&sinodep);
224224
} else
225-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
225+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
226226

227227
if(res == FALSE)
228228
EXIT_UNSQUASH("read_inode: failed to read "

squashfs-tools/unsquash-2.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ static void read_block_list(unsigned int *block_list, long long start,
4343
char *block_ptr = malloc(blocks * sizeof(unsigned int));
4444
if(block_ptr == NULL)
4545
MEM_ERROR();
46-
res = read_metadata(block_ptr, &start, &offset, blocks * sizeof(unsigned int));
46+
res = read_inode_data(block_ptr, &start, &offset, blocks * sizeof(unsigned int));
4747
if(res == FALSE)
4848
EXIT_UNSQUASH("read_block_list: failed to read "
4949
"inode index %lld:%d\n", start, offset);
5050
SQUASHFS_SWAP_INTS_3(block_list, block_ptr, blocks);
5151
free(block_ptr);
5252
} else {
53-
res = read_metadata(block_list, &start, &offset, blocks * sizeof(unsigned int));
53+
res = read_inode_data(block_list, &start, &offset, blocks * sizeof(unsigned int));
5454
if(res == FALSE)
5555
EXIT_UNSQUASH("read_block_list: failed to read "
5656
"inode index %lld:%d\n", start, offset);
@@ -180,12 +180,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
180180

181181
if(swap) {
182182
squashfs_base_inode_header_2 sinode;
183-
res = read_metadata(&sinode, &st, &off, sizeof(sinode));
183+
res = read_inode_data(&sinode, &st, &off, sizeof(sinode));
184184
if(res)
185185
SQUASHFS_SWAP_BASE_INODE_HEADER_2(&header.base, &sinode,
186186
sizeof(squashfs_base_inode_header_2));
187187
} else
188-
res = read_metadata(&header.base, &st, &off, sizeof(header.base));
188+
res = read_inode_data(&header.base, &st, &off, sizeof(header.base));
189189

190190
if(res == FALSE)
191191
EXIT_UNSQUASH("read_inode: failed to read inode %lld:%d\n", st, off);
@@ -205,12 +205,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
205205

206206
if(swap) {
207207
squashfs_dir_inode_header_2 sinode;
208-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
208+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
209209
if(res)
210210
SQUASHFS_SWAP_DIR_INODE_HEADER_2(&header.dir,
211211
&sinode);
212212
} else
213-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
213+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
214214

215215
if(res == FALSE)
216216
EXIT_UNSQUASH("read_inode: failed to read "
@@ -227,12 +227,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
227227

228228
if(swap) {
229229
squashfs_ldir_inode_header_2 sinode;
230-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
230+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
231231
if(res)
232232
SQUASHFS_SWAP_LDIR_INODE_HEADER_2(&header.ldir,
233233
&sinode);
234234
} else
235-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
235+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
236236

237237
if(res == FALSE)
238238
EXIT_UNSQUASH("read_inode: failed to read "
@@ -249,12 +249,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
249249

250250
if(swap) {
251251
squashfs_reg_inode_header_2 sinode;
252-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
252+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
253253
if(res)
254254
SQUASHFS_SWAP_REG_INODE_HEADER_2(inode,
255255
&sinode);
256256
} else
257-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
257+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
258258

259259
if(res == FALSE)
260260
EXIT_UNSQUASH("read_inode: failed to read "
@@ -282,12 +282,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
282282

283283
if(swap) {
284284
squashfs_symlink_inode_header_2 sinodep;
285-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
285+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
286286
if(res)
287287
SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(inodep,
288288
&sinodep);
289289
} else
290-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
290+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
291291

292292
if(res == FALSE)
293293
EXIT_UNSQUASH("read_inode: failed to read "
@@ -297,7 +297,7 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
297297
if(i.symlink == NULL)
298298
MEM_ERROR();
299299

300-
res = read_metadata(i.symlink, &start, &offset, inodep->symlink_size);
300+
res = read_inode_data(i.symlink, &start, &offset, inodep->symlink_size);
301301
if(res == FALSE)
302302
EXIT_UNSQUASH("read_inode: failed to read "
303303
"inode symbolic link %lld:%d\n", start, offset);
@@ -311,12 +311,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
311311

312312
if(swap) {
313313
squashfs_dev_inode_header_2 sinodep;
314-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
314+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
315315
if(res)
316316
SQUASHFS_SWAP_DEV_INODE_HEADER_2(inodep,
317317
&sinodep);
318318
} else
319-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
319+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
320320

321321
if(res == FALSE)
322322
EXIT_UNSQUASH("read_inode: failed to read "

squashfs-tools/unsquash-3.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ static void read_block_list(unsigned int *block_list, long long start,
6262
unsigned int *block_ptr = malloc(blocks * sizeof(unsigned int));
6363
if(block_ptr == NULL)
6464
MEM_ERROR();
65-
res = read_metadata(block_ptr, &start, &offset, blocks * sizeof(unsigned int));
65+
res = read_inode_data(block_ptr, &start, &offset, blocks * sizeof(unsigned int));
6666
if(res == FALSE)
6767
EXIT_UNSQUASH("read_block_list: failed to read "
6868
"inode index %lld:%d\n", start, offset);
6969
SQUASHFS_SWAP_INTS_3(block_list, block_ptr, blocks);
7070
free(block_ptr);
7171
} else {
72-
res = read_metadata(block_list, &start, &offset, blocks * sizeof(unsigned int));
72+
res = read_inode_data(block_list, &start, &offset, blocks * sizeof(unsigned int));
7373
if(res == FALSE)
7474
EXIT_UNSQUASH("read_block_list: failed to read "
7575
"inode index %lld:%d\n", start, offset);
@@ -186,12 +186,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
186186

187187
if(swap) {
188188
squashfs_base_inode_header_3 sinode;
189-
res = read_metadata(&sinode, &st, &off, sizeof(sinode));
189+
res = read_inode_data(&sinode, &st, &off, sizeof(sinode));
190190
if(res)
191191
SQUASHFS_SWAP_BASE_INODE_HEADER_3(&header.base, &sinode,
192192
sizeof(squashfs_base_inode_header_3));
193193
} else
194-
res = read_metadata(&header.base, &st, &off, sizeof(header.base));
194+
res = read_inode_data(&header.base, &st, &off, sizeof(header.base));
195195

196196
if(res == FALSE)
197197
EXIT_UNSQUASH("read_inode: failed to read inode %lld:%d\n", st, off);
@@ -211,12 +211,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
211211

212212
if(swap) {
213213
squashfs_dir_inode_header_3 sinode;
214-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
214+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
215215
if(res)
216216
SQUASHFS_SWAP_DIR_INODE_HEADER_3(&header.dir,
217217
&sinode);
218218
} else
219-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
219+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
220220

221221
if(res == FALSE)
222222
EXIT_UNSQUASH("read_inode: failed to read "
@@ -232,12 +232,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
232232

233233
if(swap) {
234234
squashfs_ldir_inode_header_3 sinode;
235-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
235+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
236236
if(res)
237237
SQUASHFS_SWAP_LDIR_INODE_HEADER_3(&header.ldir,
238238
&sinode);
239239
} else
240-
res = read_metadata(&inode, &start, &offset, sizeof(*inode));
240+
res = read_inode_data(&inode, &start, &offset, sizeof(*inode));
241241

242242
if(res == FALSE)
243243
EXIT_UNSQUASH("read_inode: failed to read "
@@ -253,12 +253,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
253253

254254
if(swap) {
255255
squashfs_reg_inode_header_3 sinode;
256-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
256+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
257257
if(res)
258258
SQUASHFS_SWAP_REG_INODE_HEADER_3(inode,
259259
&sinode);
260260
} else
261-
res = read_metadata(&inode, &start, &offset, sizeof(*inode));
261+
res = read_inode_data(&inode, &start, &offset, sizeof(*inode));
262262

263263
if(res == FALSE)
264264
EXIT_UNSQUASH("read_inode: failed to read "
@@ -284,12 +284,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
284284

285285
if(swap) {
286286
squashfs_lreg_inode_header_3 sinode;
287-
res = read_metadata(&sinode, &start, &offset, sizeof(sinode));
287+
res = read_inode_data(&sinode, &start, &offset, sizeof(sinode));
288288
if(res)
289289
SQUASHFS_SWAP_LREG_INODE_HEADER_3(inode,
290290
&sinode);
291291
} else
292-
res = read_metadata(inode, &start, &offset, sizeof(*inode));
292+
res = read_inode_data(inode, &start, &offset, sizeof(*inode));
293293

294294
if(res == FALSE)
295295
EXIT_UNSQUASH("read_inode: failed to read "
@@ -316,12 +316,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
316316

317317
if(swap) {
318318
squashfs_symlink_inode_header_3 sinodep;
319-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
319+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
320320
if(res)
321321
SQUASHFS_SWAP_SYMLINK_INODE_HEADER_3(inodep,
322322
&sinodep);
323323
} else
324-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
324+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
325325

326326
if(res == FALSE)
327327
EXIT_UNSQUASH("read_inode: failed to read "
@@ -331,7 +331,7 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
331331
if(i.symlink == NULL)
332332
MEM_ERROR();
333333

334-
res = read_metadata(i.symlink, &start, &offset, inodep->symlink_size);
334+
res = read_inode_data(i.symlink, &start, &offset, inodep->symlink_size);
335335
if(res == FALSE)
336336
EXIT_UNSQUASH("read_inode: failed to read "
337337
"inode symbolic link %lld:%d\n", start, offset);
@@ -346,12 +346,12 @@ static struct inode *read_inode(unsigned int start_block, unsigned int offset)
346346

347347
if(swap) {
348348
squashfs_dev_inode_header_3 sinodep;
349-
res = read_metadata(&sinodep, &start, &offset, sizeof(sinodep));
349+
res = read_inode_data(&sinodep, &start, &offset, sizeof(sinodep));
350350
if(res)
351351
SQUASHFS_SWAP_DEV_INODE_HEADER_3(inodep,
352352
&sinodep);
353353
} else
354-
res = read_metadata(inodep, &start, &offset, sizeof(*inodep));
354+
res = read_inode_data(inodep, &start, &offset, sizeof(*inodep));
355355

356356
if(res == FALSE)
357357
EXIT_UNSQUASH("read_inode: failed to read "

0 commit comments

Comments
 (0)