freevxfs: handle big endian HP-UX file systems
[linux-2.6-microblaze.git] / fs / freevxfs / vxfs_inode.h
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 #ifndef _VXFS_INODE_H_
31 #define _VXFS_INODE_H_
32
33 /*
34  * Veritas filesystem driver - inode structure.
35  *
36  * This file contains the definition of the disk and core
37  * inodes of the Veritas Filesystem.
38  */
39
40
41 #define VXFS_ISIZE              0x100           /* Inode size */
42
43 #define VXFS_NDADDR             10              /* Number of direct addrs in inode */
44 #define VXFS_NIADDR             2               /* Number of indirect addrs in inode */
45 #define VXFS_NIMMED             96              /* Size of immediate data in inode */
46 #define VXFS_NTYPED             6               /* Num of typed extents */
47
48 #define VXFS_TYPED_OFFSETMASK   (0x00FFFFFFFFFFFFFFULL)
49 #define VXFS_TYPED_TYPEMASK     (0xFF00000000000000ULL)
50 #define VXFS_TYPED_TYPESHIFT    56
51
52 #define VXFS_TYPED_PER_BLOCK(sbp) \
53         ((sbp)->s_blocksize / sizeof(struct vxfs_typed))
54
55 /*
56  * Possible extent descriptor types for %VXFS_ORG_TYPED extents.
57  */
58 enum {
59         VXFS_TYPED_INDIRECT             = 1,
60         VXFS_TYPED_DATA                 = 2,
61         VXFS_TYPED_INDIRECT_DEV4        = 3,
62         VXFS_TYPED_DATA_DEV4            = 4,
63 };
64
65 /*
66  * Data stored immediately in the inode.
67  */
68 struct vxfs_immed {
69         __u8                    vi_immed[VXFS_NIMMED];
70 };
71
72 struct vxfs_ext4 {
73         __fs32                  ve4_spare;              /* ?? */
74         __fs32                  ve4_indsize;            /* Indirect extent size */
75         __fs32                  ve4_indir[VXFS_NIADDR]; /* Indirect extents */
76         struct direct {                                 /* Direct extents */
77                 __fs32          extent;                 /* Extent number */
78                 __fs32          size;                   /* Size of extent */
79         } ve4_direct[VXFS_NDADDR];
80 };
81
82 struct vxfs_typed {
83         __fs64          vt_hdr;         /* Header, 0xTTOOOOOOOOOOOOOO; T=type,O=offs */
84         __fs32          vt_block;       /* Extent block */
85         __fs32          vt_size;        /* Size in blocks */
86 };
87
88 struct vxfs_typed_dev4 {
89         __fs64          vd4_hdr;        /* Header, 0xTTOOOOOOOOOOOOOO; T=type,O=offs */
90         __fs64          vd4_block;      /* Extent block */
91         __fs64          vd4_size;       /* Size in blocks */
92         __fs32          vd4_dev;        /* Device ID */
93         __u8            __pad1;
94 };
95
96 /*
97  * The inode as contained on the physical device.
98  */
99 struct vxfs_dinode {
100         __fs32          vdi_mode;
101         __fs32          vdi_nlink;      /* Link count */
102         __fs32          vdi_uid;        /* UID */
103         __fs32          vdi_gid;        /* GID */
104         __fs64          vdi_size;       /* Inode size in bytes */
105         __fs32          vdi_atime;      /* Last time accessed - sec */
106         __fs32          vdi_autime;     /* Last time accessed - usec */
107         __fs32          vdi_mtime;      /* Last modify time - sec */
108         __fs32          vdi_mutime;     /* Last modify time - usec */
109         __fs32          vdi_ctime;      /* Create time - sec */
110         __fs32          vdi_cutime;     /* Create time - usec */
111         __u8            vdi_aflags;     /* Allocation flags */
112         __u8            vdi_orgtype;    /* Organisation type */
113         __fs16          vdi_eopflags;
114         __fs32          vdi_eopdata;
115         union {
116                 __fs32                  rdev;
117                 __fs32                  dotdot;
118                 struct {
119                         __u32           reserved;
120                         __fs32          fixextsize;
121                 } i_regular;
122                 struct {
123                         __fs32          matchino;
124                         __fs32          fsetindex;
125                 } i_vxspec;
126                 __u64                   align;
127         } vdi_ftarea;
128         __fs32          vdi_blocks;     /* How much blocks does inode occupy */
129         __fs32          vdi_gen;        /* Inode generation */
130         __fs64          vdi_version;    /* Version */
131         union {
132                 struct vxfs_immed       immed;
133                 struct vxfs_ext4        ext4;
134                 struct vxfs_typed       typed[VXFS_NTYPED];
135         } vdi_org;
136         __fs32          vdi_iattrino;
137 };
138
139 #define vdi_rdev        vdi_ftarea.rdev
140 #define vdi_dotdot      vdi_ftarea.dotdot
141 #define vdi_fixextsize  vdi_ftarea.regular.fixextsize
142 #define vdi_matchino    vdi_ftarea.vxspec.matchino
143 #define vdi_fsetindex   vdi_ftarea.vxspec.fsetindex
144
145 #define vdi_immed       vdi_org.immed
146 #define vdi_ext4        vdi_org.ext4
147 #define vdi_typed       vdi_org.typed
148
149
150 /*
151  * The inode as represented in the main memory.
152  */
153 struct vxfs_inode_info {
154         __u32           vii_mode;
155         __u32           vii_nlink;      /* Link count */
156         __u32           vii_uid;        /* UID */
157         __u32           vii_gid;        /* GID */
158         __u64           vii_size;       /* Inode size in bytes */
159         __u32           vii_atime;      /* Last time accessed - sec */
160         __u32           vii_autime;     /* Last time accessed - usec */
161         __u32           vii_mtime;      /* Last modify time - sec */
162         __u32           vii_mutime;     /* Last modify time - usec */
163         __u32           vii_ctime;      /* Create time - sec */
164         __u32           vii_cutime;     /* Create time - usec */
165         __u8            vii_orgtype;    /* Organisation type */
166         union {
167                 __u32                   rdev;
168                 __u32                   dotdot;
169         } vii_ftarea;
170         __u32           vii_blocks;     /* How much blocks does inode occupy */
171         __u32           vii_gen;        /* Inode generation */
172         union {
173                 struct vxfs_immed       immed;
174                 struct vxfs_ext4        ext4;
175                 struct vxfs_typed       typed[VXFS_NTYPED];
176         } vii_org;
177 };
178
179 #define vii_rdev        vii_ftarea.rdev
180 #define vii_dotdot      vii_ftarea.dotdot
181
182 #define vii_immed       vii_org.immed
183 #define vii_ext4        vii_org.ext4
184 #define vii_typed       vii_org.typed
185
186 #endif /* _VXFS_INODE_H_ */