]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - SQUASHFS/squashfs-tools-4.4/squashfs-tools/unsquash-123.c
2 * Unsquash a squashfs filesystem. This is a highly compressed read only
6 * Phillip Lougher <phillip@squashfs.org.uk>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2,
11 * or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Helper functions used by unsquash-1, unsquash-2 and unsquash-3.
27 #include "unsquashfs.h"
28 #include "squashfs_compat.h"
30 int read_ids(int ids
, long long start
, long long end
, unsigned int **id_table
)
32 /* Note on overflow limits:
34 * Max length is 2^8*4 or 1024
37 int length
= ids
* sizeof(unsigned int);
40 * The size of the index table (length bytes) should match the
41 * table start and end points
43 if(length
!= (end
- start
)) {
44 ERROR("read_ids: Bad inode count in super block\n");
48 TRACE("read_ids: no_ids %d\n", ids
);
50 *id_table
= malloc(length
);
51 if(*id_table
== NULL
) {
52 ERROR("read_ids: failed to allocate uid/gid table\n");
57 unsigned int *sid_table
= malloc(length
);
59 if(sid_table
== NULL
) {
60 ERROR("read_ids: failed to allocate uid/gid table\n");
64 res
= read_fs_bytes(fd
, start
, length
, sid_table
);
66 ERROR("read_ids: failed to read uid/gid table"
71 SQUASHFS_SWAP_INTS_3((*id_table
), sid_table
, ids
);
74 res
= read_fs_bytes(fd
, start
, length
, *id_table
);
76 ERROR("read_ids: failed to read uid/gid table"