]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - SQUASHFS/squashfs-tools-4.4/squashfs-tools/unsquash-123.c
added Spanish (Latinoamérica) translation (#1865)
[Ventoy.git] / SQUASHFS / squashfs-tools-4.4 / squashfs-tools / unsquash-123.c
1 /*
2 * Unsquash a squashfs filesystem. This is a highly compressed read only
3 * filesystem.
4 *
5 * Copyright (c) 2019
6 * Phillip Lougher <phillip@squashfs.org.uk>
7 *
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.
12 *
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.
17 *
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.
21 *
22 * unsquash-123.c
23 *
24 * Helper functions used by unsquash-1, unsquash-2 and unsquash-3.
25 */
26
27 #include "unsquashfs.h"
28 #include "squashfs_compat.h"
29
30 int read_ids(int ids, long long start, long long end, unsigned int **id_table)
31 {
32 /* Note on overflow limits:
33 * Size of ids is 2^8
34 * Max length is 2^8*4 or 1024
35 */
36 int res;
37 int length = ids * sizeof(unsigned int);
38
39 /*
40 * The size of the index table (length bytes) should match the
41 * table start and end points
42 */
43 if(length != (end - start)) {
44 ERROR("read_ids: Bad inode count in super block\n");
45 return FALSE;
46 }
47
48 TRACE("read_ids: no_ids %d\n", ids);
49
50 *id_table = malloc(length);
51 if(*id_table == NULL) {
52 ERROR("read_ids: failed to allocate uid/gid table\n");
53 return FALSE;
54 }
55
56 if(swap) {
57 unsigned int *sid_table = malloc(length);
58
59 if(sid_table == NULL) {
60 ERROR("read_ids: failed to allocate uid/gid table\n");
61 return FALSE;
62 }
63
64 res = read_fs_bytes(fd, start, length, sid_table);
65 if(res == FALSE) {
66 ERROR("read_ids: failed to read uid/gid table"
67 "\n");
68 free(sid_table);
69 return FALSE;
70 }
71 SQUASHFS_SWAP_INTS_3((*id_table), sid_table, ids);
72 free(sid_table);
73 } else {
74 res = read_fs_bytes(fd, start, length, *id_table);
75 if(res == FALSE) {
76 ERROR("read_ids: failed to read uid/gid table"
77 "\n");
78 return FALSE;
79 }
80 }
81
82 return TRUE;
83 }