This source file includes following definitions.
- squashfs_get_id
- squashfs_read_id_index_table
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <linux/fs.h>
22 #include <linux/vfs.h>
23 #include <linux/slab.h>
24
25 #include "squashfs_fs.h"
26 #include "squashfs_fs_sb.h"
27 #include "squashfs.h"
28
29
30
31
32 int squashfs_get_id(struct super_block *sb, unsigned int index,
33 unsigned int *id)
34 {
35 struct squashfs_sb_info *msblk = sb->s_fs_info;
36 int block = SQUASHFS_ID_BLOCK(index);
37 int offset = SQUASHFS_ID_BLOCK_OFFSET(index);
38 u64 start_block = le64_to_cpu(msblk->id_table[block]);
39 __le32 disk_id;
40 int err;
41
42 err = squashfs_read_metadata(sb, &disk_id, &start_block, &offset,
43 sizeof(disk_id));
44 if (err < 0)
45 return err;
46
47 *id = le32_to_cpu(disk_id);
48 return 0;
49 }
50
51
52
53
54
55 __le64 *squashfs_read_id_index_table(struct super_block *sb,
56 u64 id_table_start, u64 next_table, unsigned short no_ids)
57 {
58 unsigned int length = SQUASHFS_ID_BLOCK_BYTES(no_ids);
59 __le64 *table;
60
61 TRACE("In read_id_index_table, length %d\n", length);
62
63
64
65
66 if (no_ids == 0)
67 return ERR_PTR(-EINVAL);
68
69
70
71
72
73
74 if (id_table_start + length > next_table)
75 return ERR_PTR(-EINVAL);
76
77 table = squashfs_read_table(sb, id_table_start, length);
78
79
80
81
82
83 if (!IS_ERR(table) && le64_to_cpu(table[0]) >= id_table_start) {
84 kfree(table);
85 return ERR_PTR(-EINVAL);
86 }
87
88 return table;
89 }