1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2000-2001 Christoph Hellwig.
4 * Copyright (c) 2016 Krzysztof Blaszkowski
8 * Veritas filesystem driver - fileset header routines.
11 #include <linux/buffer_head.h>
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/string.h>
17 #include "vxfs_inode.h"
18 #include "vxfs_extern.h"
19 #include "vxfs_fshead.h"
24 vxfs_dumpfsh(struct vxfs_fsh *fhp)
26 printk("\n\ndumping fileset header:\n");
27 printk("----------------------------\n");
28 printk("version: %u\n", fhp->fsh_version);
29 printk("fsindex: %u\n", fhp->fsh_fsindex);
30 printk("iauino: %u\tninodes:%u\n",
31 fhp->fsh_iauino, fhp->fsh_ninodes);
32 printk("maxinode: %u\tlctino: %u\n",
33 fhp->fsh_maxinode, fhp->fsh_lctino);
34 printk("nau: %u\n", fhp->fsh_nau);
35 printk("ilistino[0]: %u\tilistino[1]: %u\n",
36 fhp->fsh_ilistino[0], fhp->fsh_ilistino[1]);
41 * vxfs_getfsh - read fileset header into memory
42 * @ip: the (fake) fileset header inode
43 * @which: 0 for the structural, 1 for the primary fsh.
46 * vxfs_getfsh reads either the structural or primary fileset header
47 * described by @ip into memory.
50 * The fileset header structure on success, else Zero.
52 static struct vxfs_fsh *
53 vxfs_getfsh(struct inode *ip, int which)
55 struct buffer_head *bp;
57 bp = vxfs_bread(ip, which);
61 if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL)))
63 memcpy(fhp, bp->b_data, sizeof(*fhp));
74 * vxfs_read_fshead - read the fileset headers
75 * @sbp: superblock to which the fileset belongs
78 * vxfs_read_fshead will fill the inode and structural inode list in @sb.
81 * Zero on success, else a negative error code (-EINVAL).
84 vxfs_read_fshead(struct super_block *sbp)
86 struct vxfs_sb_info *infp = VXFS_SBI(sbp);
87 struct vxfs_fsh *pfp, *sfp;
88 struct vxfs_inode_info *vip;
90 infp->vsi_fship = vxfs_blkiget(sbp, infp->vsi_iext, infp->vsi_fshino);
91 if (!infp->vsi_fship) {
92 printk(KERN_ERR "vxfs: unable to read fsh inode\n");
96 vip = VXFS_INO(infp->vsi_fship);
97 if (!VXFS_ISFSH(vip)) {
98 printk(KERN_ERR "vxfs: fsh list inode is of wrong type (%x)\n",
99 vip->vii_mode & VXFS_TYPE_MASK);
104 printk("vxfs: fsh inode dump:\n");
105 vxfs_dumpi(vip, infp->vsi_fshino);
108 sfp = vxfs_getfsh(infp->vsi_fship, 0);
110 printk(KERN_ERR "vxfs: unable to get structural fsh\n");
118 pfp = vxfs_getfsh(infp->vsi_fship, 1);
120 printk(KERN_ERR "vxfs: unable to get primary fsh\n");
128 infp->vsi_stilist = vxfs_blkiget(sbp, infp->vsi_iext,
129 fs32_to_cpu(infp, sfp->fsh_ilistino[0]));
130 if (!infp->vsi_stilist) {
131 printk(KERN_ERR "vxfs: unable to get structural list inode\n");
134 if (!VXFS_ISILT(VXFS_INO(infp->vsi_stilist))) {
135 printk(KERN_ERR "vxfs: structural list inode is of wrong type (%x)\n",
136 VXFS_INO(infp->vsi_stilist)->vii_mode & VXFS_TYPE_MASK);
137 goto out_iput_stilist;
140 infp->vsi_ilist = vxfs_stiget(sbp, fs32_to_cpu(infp, pfp->fsh_ilistino[0]));
141 if (!infp->vsi_ilist) {
142 printk(KERN_ERR "vxfs: unable to get inode list inode\n");
143 goto out_iput_stilist;
145 if (!VXFS_ISILT(VXFS_INO(infp->vsi_ilist))) {
146 printk(KERN_ERR "vxfs: inode list inode is of wrong type (%x)\n",
147 VXFS_INO(infp->vsi_ilist)->vii_mode & VXFS_TYPE_MASK);
156 iput(infp->vsi_ilist);
158 iput(infp->vsi_stilist);
164 iput(infp->vsi_fship);