This source file includes following definitions.
- vxfs_get_fshead
- vxfs_get_ilist
- vxfs_oblock
- vxfs_read_olt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #include <linux/fs.h>
34 #include <linux/buffer_head.h>
35 #include <linux/kernel.h>
36
37 #include "vxfs.h"
38 #include "vxfs_olt.h"
39 #include "vxfs_extern.h"
40
41
42 static inline void
43 vxfs_get_fshead(struct vxfs_oltfshead *fshp, struct vxfs_sb_info *infp)
44 {
45 BUG_ON(infp->vsi_fshino);
46 infp->vsi_fshino = fs32_to_cpu(infp, fshp->olt_fsino[0]);
47 }
48
49 static inline void
50 vxfs_get_ilist(struct vxfs_oltilist *ilistp, struct vxfs_sb_info *infp)
51 {
52 BUG_ON(infp->vsi_iext);
53 infp->vsi_iext = fs32_to_cpu(infp, ilistp->olt_iext[0]);
54 }
55
56 static inline u_long
57 vxfs_oblock(struct super_block *sbp, daddr_t block, u_long bsize)
58 {
59 BUG_ON(sbp->s_blocksize % bsize);
60 return (block * (sbp->s_blocksize / bsize));
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 int
77 vxfs_read_olt(struct super_block *sbp, u_long bsize)
78 {
79 struct vxfs_sb_info *infp = VXFS_SBI(sbp);
80 struct buffer_head *bp;
81 struct vxfs_olt *op;
82 char *oaddr, *eaddr;
83
84 bp = sb_bread(sbp, vxfs_oblock(sbp, infp->vsi_oltext, bsize));
85 if (!bp || !bp->b_data)
86 goto fail;
87
88 op = (struct vxfs_olt *)bp->b_data;
89 if (fs32_to_cpu(infp, op->olt_magic) != VXFS_OLT_MAGIC) {
90 printk(KERN_NOTICE "vxfs: ivalid olt magic number\n");
91 goto fail;
92 }
93
94
95
96
97
98 if (infp->vsi_oltsize > 1) {
99 printk(KERN_NOTICE "vxfs: oltsize > 1 detected.\n");
100 printk(KERN_NOTICE "vxfs: please notify hch@infradead.org\n");
101 goto fail;
102 }
103
104 oaddr = bp->b_data + fs32_to_cpu(infp, op->olt_size);
105 eaddr = bp->b_data + (infp->vsi_oltsize * sbp->s_blocksize);
106
107 while (oaddr < eaddr) {
108 struct vxfs_oltcommon *ocp =
109 (struct vxfs_oltcommon *)oaddr;
110
111 switch (fs32_to_cpu(infp, ocp->olt_type)) {
112 case VXFS_OLT_FSHEAD:
113 vxfs_get_fshead((struct vxfs_oltfshead *)oaddr, infp);
114 break;
115 case VXFS_OLT_ILIST:
116 vxfs_get_ilist((struct vxfs_oltilist *)oaddr, infp);
117 break;
118 }
119
120 oaddr += fs32_to_cpu(infp, ocp->olt_size);
121 }
122
123 brelse(bp);
124 return (infp->vsi_fshino && infp->vsi_iext) ? 0 : -EINVAL;
125
126 fail:
127 brelse(bp);
128 return -EINVAL;
129 }