OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [freevxfs/] [vxfs_fshead.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
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
#ident "$Id: vxfs_fshead.c,v 1.1.1.1 2004-04-15 01:11:43 phoenix Exp $"
31
 
32
/*
33
 * Veritas filesystem driver - fileset header routines.
34
 */
35
#include <linux/fs.h>
36
#include <linux/kernel.h>
37
#include <linux/slab.h>
38
 
39
#include "vxfs.h"
40
#include "vxfs_inode.h"
41
#include "vxfs_extern.h"
42
#include "vxfs_fshead.h"
43
 
44
 
45
#ifdef DIAGNOSTIC
46
static void
47
vxfs_dumpfsh(struct vxfs_fsh *fhp)
48
{
49
        printk("\n\ndumping fileset header:\n");
50
        printk("----------------------------\n");
51
        printk("version: %u\n", fhp->fsh_version);
52
        printk("fsindex: %u\n", fhp->fsh_fsindex);
53
        printk("iauino: %u\tninodes:%u\n",
54
                        fhp->fsh_iauino, fhp->fsh_ninodes);
55
        printk("maxinode: %u\tlctino: %u\n",
56
                        fhp->fsh_maxinode, fhp->fsh_lctino);
57
        printk("nau: %u\n", fhp->fsh_nau);
58
        printk("ilistino[0]: %u\tilistino[1]: %u\n",
59
                        fhp->fsh_ilistino[0], fhp->fsh_ilistino[1]);
60
}
61
#endif
62
 
63
/**
64
 * vxfs_getfsh - read fileset header into memory
65
 * @ip:         the (fake) fileset header inode
66
 * @which:      0 for the structural, 1 for the primary fsh.
67
 *
68
 * Description:
69
 *   vxfs_getfsh reads either the structural or primary fileset header
70
 *   described by @ip into memory.
71
 *
72
 * Returns:
73
 *   The fileset header structure on success, else Zero.
74
 */
75
static struct vxfs_fsh *
76
vxfs_getfsh(struct inode *ip, int which)
77
{
78
        struct buffer_head              *bp;
79
 
80
        bp = vxfs_bread(ip, which);
81
        if (buffer_mapped(bp)) {
82
                struct vxfs_fsh         *fhp;
83
 
84
                if (!(fhp = kmalloc(sizeof(*fhp), SLAB_KERNEL)))
85
                        return NULL;
86
                memcpy(fhp, bp->b_data, sizeof(*fhp));
87
 
88
                brelse(bp);
89
                return (fhp);
90
        }
91
 
92
        return NULL;
93
}
94
 
95
/**
96
 * vxfs_read_fshead - read the fileset headers
97
 * @sbp:        superblock to which the fileset belongs
98
 *
99
 * Description:
100
 *   vxfs_read_fshead will fill the inode and structural inode list in @sb.
101
 *
102
 * Returns:
103
 *   Zero on success, else a negative error code (-EINVAL).
104
 */
105
int
106
vxfs_read_fshead(struct super_block *sbp)
107
{
108
        struct vxfs_sb_info             *infp = VXFS_SBI(sbp);
109
        struct vxfs_fsh                 *pfp, *sfp;
110
        struct vxfs_inode_info          *vip, *tip;
111
 
112
        if (!(vip = vxfs_blkiget(sbp, infp->vsi_iext, infp->vsi_fshino))) {
113
                printk(KERN_ERR "vxfs: unabled to read fsh inode\n");
114
                return -EINVAL;
115
        } else if (!VXFS_ISFSH(vip)) {
116
                printk(KERN_ERR "vxfs: fsh list inode is of wrong type (%x)\n",
117
                                vip->vii_mode & VXFS_TYPE_MASK);
118
                return -EINVAL;
119
        }
120
 
121
 
122
#ifdef DIAGNOSTIC
123
        printk("vxfs: fsh inode dump:\n");
124
        vxfs_dumpi(vip, infp->vsi_fshino);
125
#endif
126
 
127
        if (!(infp->vsi_fship = vxfs_get_fake_inode(sbp, vip))) {
128
                printk(KERN_ERR "vxfs: unabled to get fsh inode\n");
129
                return -EINVAL;
130
        }
131
 
132
        if (!(sfp = vxfs_getfsh(infp->vsi_fship, 0))) {
133
                printk(KERN_ERR "vxfs: unabled to get structural fsh\n");
134
                return -EINVAL;
135
        }
136
 
137
#ifdef DIAGNOSTIC
138
        vxfs_dumpfsh(sfp);
139
#endif
140
 
141
        if (!(pfp = vxfs_getfsh(infp->vsi_fship, 1))) {
142
                printk(KERN_ERR "vxfs: unabled to get primary fsh\n");
143
                return -EINVAL;
144
        }
145
 
146
#ifdef DIAGNOSTIC
147
        vxfs_dumpfsh(pfp);
148
#endif
149
 
150
        tip = vxfs_blkiget(sbp, infp->vsi_iext, sfp->fsh_ilistino[0]);
151
        if (!tip || ((infp->vsi_stilist = vxfs_get_fake_inode(sbp, tip)) == NULL)) {
152
                printk(KERN_ERR "vxfs: unabled to get structual list inode\n");
153
                return -EINVAL;
154
        } else if (!VXFS_ISILT(VXFS_INO(infp->vsi_stilist))) {
155
                printk(KERN_ERR "vxfs: structual list inode is of wrong type (%x)\n",
156
                                VXFS_INO(infp->vsi_stilist)->vii_mode & VXFS_TYPE_MASK);
157
                return -EINVAL;
158
        }
159
 
160
        tip = vxfs_stiget(sbp, pfp->fsh_ilistino[0]);
161
        if (!tip || ((infp->vsi_ilist = vxfs_get_fake_inode(sbp, tip)) == NULL)) {
162
                printk(KERN_ERR "vxfs: unabled to get inode list inode\n");
163
                return -EINVAL;
164
        } else if (!VXFS_ISILT(VXFS_INO(infp->vsi_ilist))) {
165
                printk(KERN_ERR "vxfs: inode list inode is of wrong type (%x)\n",
166
                                VXFS_INO(infp->vsi_ilist)->vii_mode & VXFS_TYPE_MASK);
167
                return -EINVAL;
168
        }
169
 
170
        return 0;
171
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.