This source file includes following definitions.
- hfs_part_find
1
2
3
4
5
6
7
8
9
10
11
12 #include "hfs_fs.h"
13
14
15
16
17
18
19
20
21 struct new_pmap {
22 __be16 pmSig;
23 __be16 reSigPad;
24 __be32 pmMapBlkCnt;
25 __be32 pmPyPartStart;
26 __be32 pmPartBlkCnt;
27 u8 pmPartName[32];
28
29
30 u8 pmPartType[32];
31
32
33
34 } __packed;
35
36
37
38
39
40
41
42
43 struct old_pmap {
44 __be16 pdSig;
45 struct old_pmap_entry {
46 __be32 pdStart;
47 __be32 pdSize;
48 __be32 pdFSID;
49 } pdEntry[42];
50 } __packed;
51
52
53
54
55
56
57
58 int hfs_part_find(struct super_block *sb,
59 sector_t *part_start, sector_t *part_size)
60 {
61 struct buffer_head *bh;
62 __be16 *data;
63 int i, size, res;
64
65 res = -ENOENT;
66 bh = sb_bread512(sb, *part_start + HFS_PMAP_BLK, data);
67 if (!bh)
68 return -EIO;
69
70 switch (be16_to_cpu(*data)) {
71 case HFS_OLD_PMAP_MAGIC:
72 {
73 struct old_pmap *pm;
74 struct old_pmap_entry *p;
75
76 pm = (struct old_pmap *)bh->b_data;
77 p = pm->pdEntry;
78 size = 42;
79 for (i = 0; i < size; p++, i++) {
80 if (p->pdStart && p->pdSize &&
81 p->pdFSID == cpu_to_be32(0x54465331) &&
82 (HFS_SB(sb)->part < 0 || HFS_SB(sb)->part == i)) {
83 *part_start += be32_to_cpu(p->pdStart);
84 *part_size = be32_to_cpu(p->pdSize);
85 res = 0;
86 }
87 }
88 break;
89 }
90 case HFS_NEW_PMAP_MAGIC:
91 {
92 struct new_pmap *pm;
93
94 pm = (struct new_pmap *)bh->b_data;
95 size = be32_to_cpu(pm->pmMapBlkCnt);
96 for (i = 0; i < size;) {
97 if (!memcmp(pm->pmPartType,"Apple_HFS", 9) &&
98 (HFS_SB(sb)->part < 0 || HFS_SB(sb)->part == i)) {
99 *part_start += be32_to_cpu(pm->pmPyPartStart);
100 *part_size = be32_to_cpu(pm->pmPartBlkCnt);
101 res = 0;
102 break;
103 }
104 brelse(bh);
105 bh = sb_bread512(sb, *part_start + HFS_PMAP_BLK + ++i, pm);
106 if (!bh)
107 return -EIO;
108 if (pm->pmSig != cpu_to_be16(HFS_NEW_PMAP_MAGIC))
109 break;
110 }
111 break;
112 }
113 }
114 brelse(bh);
115
116 return res;
117 }