aboutsummaryrefslogtreecommitdiffstats
path: root/fs/freevxfs/vxfs_olt.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/freevxfs/vxfs_olt.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'fs/freevxfs/vxfs_olt.c')
-rw-r--r--fs/freevxfs/vxfs_olt.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/fs/freevxfs/vxfs_olt.c b/fs/freevxfs/vxfs_olt.c
new file mode 100644
index 000000000000..7a204e31aad9
--- /dev/null
+++ b/fs/freevxfs/vxfs_olt.c
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) 2000-2001 Christoph Hellwig.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification.
11 * 2. The name of the author may not be used to endorse or promote products
12 * derived from this software without specific prior written permission.
13 *
14 * Alternatively, this software may be distributed under the terms of the
15 * GNU General Public License ("GPL").
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/*
31 * Veritas filesystem driver - object location table support.
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
40
41static __inline__ void
42vxfs_get_fshead(struct vxfs_oltfshead *fshp, struct vxfs_sb_info *infp)
43{
44 if (infp->vsi_fshino)
45 BUG();
46 infp->vsi_fshino = fshp->olt_fsino[0];
47}
48
49static __inline__ void
50vxfs_get_ilist(struct vxfs_oltilist *ilistp, struct vxfs_sb_info *infp)
51{
52 if (infp->vsi_iext)
53 BUG();
54 infp->vsi_iext = ilistp->olt_iext[0];
55}
56
57static __inline__ u_long
58vxfs_oblock(struct super_block *sbp, daddr_t block, u_long bsize)
59{
60 if (sbp->s_blocksize % bsize)
61 BUG();
62 return (block * (sbp->s_blocksize / bsize));
63}
64
65
66/**
67 * vxfs_read_olt - read olt
68 * @sbp: superblock of the filesystem
69 * @bsize: blocksize of the filesystem
70 *
71 * Description:
72 * vxfs_read_olt reads the olt of the filesystem described by @sbp
73 * into main memory and does some basic setup.
74 *
75 * Returns:
76 * Zero on success, else a negative error code.
77 */
78int
79vxfs_read_olt(struct super_block *sbp, u_long bsize)
80{
81 struct vxfs_sb_info *infp = VXFS_SBI(sbp);
82 struct buffer_head *bp;
83 struct vxfs_olt *op;
84 char *oaddr, *eaddr;
85
86
87 bp = sb_bread(sbp, vxfs_oblock(sbp, infp->vsi_oltext, bsize));
88 if (!bp || !bp->b_data)
89 goto fail;
90
91 op = (struct vxfs_olt *)bp->b_data;
92 if (op->olt_magic != VXFS_OLT_MAGIC) {
93 printk(KERN_NOTICE "vxfs: ivalid olt magic number\n");
94 goto fail;
95 }
96
97 /*
98 * It is in theory possible that vsi_oltsize is > 1.
99 * I've not seen any such filesystem yet and I'm lazy.. --hch
100 */
101 if (infp->vsi_oltsize > 1) {
102 printk(KERN_NOTICE "vxfs: oltsize > 1 detected.\n");
103 printk(KERN_NOTICE "vxfs: please notify hch@infradead.org\n");
104 goto fail;
105 }
106
107 oaddr = (char *)bp->b_data + op->olt_size;
108 eaddr = (char *)bp->b_data + (infp->vsi_oltsize * sbp->s_blocksize);
109
110 while (oaddr < eaddr) {
111 struct vxfs_oltcommon *ocp =
112 (struct vxfs_oltcommon *)oaddr;
113
114 switch (ocp->olt_type) {
115 case VXFS_OLT_FSHEAD:
116 vxfs_get_fshead((struct vxfs_oltfshead *)oaddr, infp);
117 break;
118 case VXFS_OLT_ILIST:
119 vxfs_get_ilist((struct vxfs_oltilist *)oaddr, infp);
120 break;
121 }
122
123 oaddr += ocp->olt_size;
124 }
125
126 brelse(bp);
127 return 0;
128
129fail:
130 brelse(bp);
131 return -EINVAL;
132}