blob: f012abed125d61e1c3dd2cbb279c27b2aa7e2130 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (c) 2000-2001 Christoph Hellwig.
Krzysztof Błaszkowski1cce1702016-06-01 09:25:12 +02003 * Copyright (c) 2016 Krzysztof Blaszkowski
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer,
11 * without modification.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * Alternatively, this software may be distributed under the terms of the
16 * GNU General Public License ("GPL").
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31#ifndef _VXFS_INODE_H_
32#define _VXFS_INODE_H_
33
34/*
35 * Veritas filesystem driver - inode structure.
36 *
37 * This file contains the definition of the disk and core
38 * inodes of the Veritas Filesystem.
39 */
40
41
42#define VXFS_ISIZE 0x100 /* Inode size */
43
44#define VXFS_NDADDR 10 /* Number of direct addrs in inode */
45#define VXFS_NIADDR 2 /* Number of indirect addrs in inode */
46#define VXFS_NIMMED 96 /* Size of immediate data in inode */
47#define VXFS_NTYPED 6 /* Num of typed extents */
48
49#define VXFS_TYPED_OFFSETMASK (0x00FFFFFFFFFFFFFFULL)
50#define VXFS_TYPED_TYPEMASK (0xFF00000000000000ULL)
51#define VXFS_TYPED_TYPESHIFT 56
52
53#define VXFS_TYPED_PER_BLOCK(sbp) \
54 ((sbp)->s_blocksize / sizeof(struct vxfs_typed))
55
56/*
57 * Possible extent descriptor types for %VXFS_ORG_TYPED extents.
58 */
59enum {
60 VXFS_TYPED_INDIRECT = 1,
61 VXFS_TYPED_DATA = 2,
62 VXFS_TYPED_INDIRECT_DEV4 = 3,
63 VXFS_TYPED_DATA_DEV4 = 4,
64};
65
66/*
67 * Data stored immediately in the inode.
68 */
69struct vxfs_immed {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +020070 __u8 vi_immed[VXFS_NIMMED];
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
73struct vxfs_ext4 {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +020074 __fs32 ve4_spare; /* ?? */
75 __fs32 ve4_indsize; /* Indirect extent size */
76 __fs32 ve4_indir[VXFS_NIADDR]; /* Indirect extents */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 struct direct { /* Direct extents */
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +020078 __fs32 extent; /* Extent number */
79 __fs32 size; /* Size of extent */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 } ve4_direct[VXFS_NDADDR];
81};
82
83struct vxfs_typed {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +020084 __fs64 vt_hdr; /* Header, 0xTTOOOOOOOOOOOOOO; T=type,O=offs */
85 __fs32 vt_block; /* Extent block */
86 __fs32 vt_size; /* Size in blocks */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
89struct vxfs_typed_dev4 {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +020090 __fs64 vd4_hdr; /* Header, 0xTTOOOOOOOOOOOOOO; T=type,O=offs */
91 __fs64 vd4_block; /* Extent block */
92 __fs64 vd4_size; /* Size in blocks */
93 __fs32 vd4_dev; /* Device ID */
94 __u8 __pad1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095};
96
97/*
98 * The inode as contained on the physical device.
99 */
100struct vxfs_dinode {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200101 __fs32 vdi_mode;
102 __fs32 vdi_nlink; /* Link count */
103 __fs32 vdi_uid; /* UID */
104 __fs32 vdi_gid; /* GID */
105 __fs64 vdi_size; /* Inode size in bytes */
106 __fs32 vdi_atime; /* Last time accessed - sec */
107 __fs32 vdi_autime; /* Last time accessed - usec */
108 __fs32 vdi_mtime; /* Last modify time - sec */
109 __fs32 vdi_mutime; /* Last modify time - usec */
110 __fs32 vdi_ctime; /* Create time - sec */
111 __fs32 vdi_cutime; /* Create time - usec */
112 __u8 vdi_aflags; /* Allocation flags */
113 __u8 vdi_orgtype; /* Organisation type */
114 __fs16 vdi_eopflags;
115 __fs32 vdi_eopdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 union {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200117 __fs32 rdev;
118 __fs32 dotdot;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 struct {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200120 __u32 reserved;
121 __fs32 fixextsize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 } i_regular;
123 struct {
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200124 __fs32 matchino;
125 __fs32 fsetindex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 } i_vxspec;
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200127 __u64 align;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 } vdi_ftarea;
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200129 __fs32 vdi_blocks; /* How much blocks does inode occupy */
130 __fs32 vdi_gen; /* Inode generation */
131 __fs64 vdi_version; /* Version */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 union {
133 struct vxfs_immed immed;
134 struct vxfs_ext4 ext4;
135 struct vxfs_typed typed[VXFS_NTYPED];
136 } vdi_org;
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200137 __fs32 vdi_iattrino;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138};
139
140#define vdi_rdev vdi_ftarea.rdev
141#define vdi_dotdot vdi_ftarea.dotdot
142#define vdi_fixextsize vdi_ftarea.regular.fixextsize
143#define vdi_matchino vdi_ftarea.vxspec.matchino
144#define vdi_fsetindex vdi_ftarea.vxspec.fsetindex
145
146#define vdi_immed vdi_org.immed
147#define vdi_ext4 vdi_org.ext4
148#define vdi_typed vdi_org.typed
149
150
151/*
152 * The inode as represented in the main memory.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 */
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200154struct vxfs_inode_info {
Christoph Hellwig2f137e32016-06-01 08:44:45 +0200155 struct inode vfs_inode;
156
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200157 __u32 vii_mode;
158 __u32 vii_nlink; /* Link count */
159 __u32 vii_uid; /* UID */
160 __u32 vii_gid; /* GID */
161 __u64 vii_size; /* Inode size in bytes */
162 __u32 vii_atime; /* Last time accessed - sec */
163 __u32 vii_autime; /* Last time accessed - usec */
164 __u32 vii_mtime; /* Last modify time - sec */
165 __u32 vii_mutime; /* Last modify time - usec */
166 __u32 vii_ctime; /* Create time - sec */
167 __u32 vii_cutime; /* Create time - usec */
168 __u8 vii_orgtype; /* Organisation type */
169 union {
170 __u32 rdev;
171 __u32 dotdot;
172 } vii_ftarea;
173 __u32 vii_blocks; /* How much blocks does inode occupy */
174 __u32 vii_gen; /* Inode generation */
175 union {
176 struct vxfs_immed immed;
177 struct vxfs_ext4 ext4;
178 struct vxfs_typed typed[VXFS_NTYPED];
179 } vii_org;
180};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200182#define vii_rdev vii_ftarea.rdev
183#define vii_dotdot vii_ftarea.dotdot
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
Krzysztof Błaszkowski0d83f7f2016-05-31 08:45:13 +0200185#define vii_immed vii_org.immed
186#define vii_ext4 vii_org.ext4
187#define vii_typed vii_org.typed
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Christoph Hellwig2f137e32016-06-01 08:44:45 +0200189static inline struct vxfs_inode_info *VXFS_INO(struct inode *inode)
190{
191 return container_of(inode, struct vxfs_inode_info, vfs_inode);
192}
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#endif /* _VXFS_INODE_H_ */