Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
7b718769 NS |
2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
1da177e4 | 4 | * |
7b718769 NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
1da177e4 LT |
7 | * published by the Free Software Foundation. |
8 | * | |
7b718769 NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
1da177e4 | 13 | * |
7b718769 NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
1da177e4 LT |
17 | */ |
18 | #ifndef __XFS_DINODE_H__ | |
19 | #define __XFS_DINODE_H__ | |
20 | ||
21 | struct xfs_buf; | |
22 | struct xfs_mount; | |
23 | ||
24 | #define XFS_DINODE_VERSION_1 1 | |
25 | #define XFS_DINODE_VERSION_2 2 | |
a844f451 NS |
26 | #define XFS_DINODE_GOOD_VERSION(v) \ |
27 | (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2)) | |
1da177e4 LT |
28 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ |
29 | ||
30 | /* | |
31 | * Disk inode structure. | |
32 | * This is just the header; the inode is expanded to fill a variable size | |
33 | * with the last field expanding. It is split into the core and "other" | |
34 | * because we only need the core part in the in-core inode. | |
35 | */ | |
36 | typedef struct xfs_timestamp { | |
347d1c01 CH |
37 | __be32 t_sec; /* timestamp seconds */ |
38 | __be32 t_nsec; /* timestamp nanoseconds */ | |
1da177e4 LT |
39 | } xfs_timestamp_t; |
40 | ||
41 | /* | |
42 | * Note: Coordinate changes to this structure with the XFS_DI_* #defines | |
347d1c01 CH |
43 | * below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode |
44 | * in xfs_inode.h. | |
1da177e4 | 45 | */ |
347d1c01 CH |
46 | typedef struct xfs_dinode_core { |
47 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | |
48 | __be16 di_mode; /* mode and type of file */ | |
49 | __u8 di_version; /* inode version */ | |
50 | __u8 di_format; /* format of di_c data */ | |
51 | __be16 di_onlink; /* old number of links to file */ | |
52 | __be32 di_uid; /* owner's user id */ | |
53 | __be32 di_gid; /* owner's group id */ | |
54 | __be32 di_nlink; /* number of links to file */ | |
55 | __be16 di_projid; /* owner's project id */ | |
56 | __u8 di_pad[8]; /* unused, zeroed space */ | |
57 | __be16 di_flushiter; /* incremented on flush */ | |
1da177e4 LT |
58 | xfs_timestamp_t di_atime; /* time last accessed */ |
59 | xfs_timestamp_t di_mtime; /* time last modified */ | |
60 | xfs_timestamp_t di_ctime; /* time created/inode modified */ | |
347d1c01 CH |
61 | __be64 di_size; /* number of bytes in file */ |
62 | __be64 di_nblocks; /* # of direct & btree blocks used */ | |
63 | __be32 di_extsize; /* basic/minimum extent size for file */ | |
64 | __be32 di_nextents; /* number of extents in data fork */ | |
65 | __be16 di_anextents; /* number of extents in attribute fork*/ | |
66 | __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ | |
67 | __s8 di_aformat; /* format of attr fork's data */ | |
68 | __be32 di_dmevmask; /* DMIG event mask */ | |
69 | __be16 di_dmstate; /* DMIG state info */ | |
70 | __be16 di_flags; /* random flags, XFS_DIFLAG_... */ | |
71 | __be32 di_gen; /* generation number */ | |
1da177e4 LT |
72 | } xfs_dinode_core_t; |
73 | ||
74 | #define DI_MAX_FLUSH 0xffff | |
75 | ||
76 | typedef struct xfs_dinode | |
77 | { | |
78 | xfs_dinode_core_t di_core; | |
79 | /* | |
80 | * In adding anything between the core and the union, be | |
60197e8d | 81 | * sure to update the macros like XFS_LITINO below. |
1da177e4 | 82 | */ |
347d1c01 | 83 | __be32 di_next_unlinked;/* agi unlinked list ptr */ |
1da177e4 LT |
84 | union { |
85 | xfs_bmdr_block_t di_bmbt; /* btree root block */ | |
86 | xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */ | |
1da177e4 LT |
87 | xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */ |
88 | char di_c[1]; /* local contents */ | |
347d1c01 | 89 | __be32 di_dev; /* device for S_IFCHR/S_IFBLK */ |
1da177e4 LT |
90 | uuid_t di_muuid; /* mount point value */ |
91 | char di_symlink[1]; /* local symbolic link */ | |
92 | } di_u; | |
93 | union { | |
94 | xfs_bmdr_block_t di_abmbt; /* btree root block */ | |
95 | xfs_bmbt_rec_32_t di_abmx[1]; /* extent list */ | |
96 | xfs_attr_shortform_t di_attrsf; /* shortform attribute list */ | |
97 | } di_a; | |
98 | } xfs_dinode_t; | |
99 | ||
100 | /* | |
101 | * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. | |
102 | * Since the pathconf interface is signed, we use 2^31 - 1 instead. | |
103 | * The old inode format had a 16 bit link count, so its maximum is USHRT_MAX. | |
104 | */ | |
105 | #define XFS_MAXLINK ((1U << 31) - 1U) | |
106 | #define XFS_MAXLINK_1 65535U | |
107 | ||
1da177e4 LT |
108 | /* |
109 | * Values for di_format | |
110 | */ | |
111 | typedef enum xfs_dinode_fmt | |
112 | { | |
113 | XFS_DINODE_FMT_DEV, /* CHR, BLK: di_dev */ | |
114 | XFS_DINODE_FMT_LOCAL, /* DIR, REG: di_c */ | |
115 | /* LNK: di_symlink */ | |
116 | XFS_DINODE_FMT_EXTENTS, /* DIR, REG, LNK: di_bmx */ | |
117 | XFS_DINODE_FMT_BTREE, /* DIR, REG, LNK: di_bmbt */ | |
118 | XFS_DINODE_FMT_UUID /* MNT: di_uuid */ | |
119 | } xfs_dinode_fmt_t; | |
120 | ||
121 | /* | |
122 | * Inode minimum and maximum sizes. | |
123 | */ | |
124 | #define XFS_DINODE_MIN_LOG 8 | |
125 | #define XFS_DINODE_MAX_LOG 11 | |
126 | #define XFS_DINODE_MIN_SIZE (1 << XFS_DINODE_MIN_LOG) | |
127 | #define XFS_DINODE_MAX_SIZE (1 << XFS_DINODE_MAX_LOG) | |
128 | ||
129 | /* | |
130 | * Inode size for given fs. | |
131 | */ | |
1da177e4 | 132 | #define XFS_LITINO(mp) ((mp)->m_litino) |
1da177e4 | 133 | #define XFS_BROOT_SIZE_ADJ \ |
7cc95a82 | 134 | (XFS_BTREE_LBLOCK_LEN - sizeof(xfs_bmdr_block_t)) |
1da177e4 | 135 | |
1da177e4 LT |
136 | /* |
137 | * Inode data & attribute fork sizes, per inode. | |
138 | */ | |
45ba598e CH |
139 | #define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0) |
140 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3)) | |
1da177e4 | 141 | |
a844f451 | 142 | #define XFS_DFORK_DSIZE(dip,mp) \ |
45ba598e CH |
143 | (XFS_DFORK_Q(dip) ? \ |
144 | XFS_DFORK_BOFF(dip) : \ | |
145 | XFS_LITINO(mp)) | |
a844f451 | 146 | #define XFS_DFORK_ASIZE(dip,mp) \ |
45ba598e CH |
147 | (XFS_DFORK_Q(dip) ? \ |
148 | XFS_LITINO(mp) - XFS_DFORK_BOFF(dip) : \ | |
149 | 0) | |
150 | #define XFS_DFORK_SIZE(dip,mp,w) \ | |
1da177e4 | 151 | ((w) == XFS_DATA_FORK ? \ |
45ba598e CH |
152 | XFS_DFORK_DSIZE(dip, mp) : \ |
153 | XFS_DFORK_ASIZE(dip, mp)) | |
1da177e4 | 154 | |
45ba598e CH |
155 | #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) |
156 | #define XFS_DFORK_APTR(dip) \ | |
157 | ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) | |
158 | #define XFS_DFORK_PTR(dip,w) \ | |
159 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) | |
160 | #define XFS_DFORK_FORMAT(dip,w) \ | |
1da177e4 | 161 | ((w) == XFS_DATA_FORK ? \ |
45ba598e CH |
162 | (dip)->di_core.di_format : \ |
163 | (dip)->di_core.di_aformat) | |
164 | #define XFS_DFORK_NEXTENTS(dip,w) \ | |
1da177e4 | 165 | ((w) == XFS_DATA_FORK ? \ |
45ba598e CH |
166 | be32_to_cpu((dip)->di_core.di_nextents) : \ |
167 | be16_to_cpu((dip)->di_core.di_anextents)) | |
1da177e4 | 168 | |
a844f451 | 169 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) |
1da177e4 LT |
170 | |
171 | /* | |
172 | * Values for di_flags | |
173 | * There should be a one-to-one correspondence between these flags and the | |
174 | * XFS_XFLAG_s. | |
175 | */ | |
176 | #define XFS_DIFLAG_REALTIME_BIT 0 /* file's blocks come from rt area */ | |
177 | #define XFS_DIFLAG_PREALLOC_BIT 1 /* file space has been preallocated */ | |
178 | #define XFS_DIFLAG_NEWRTBM_BIT 2 /* for rtbitmap inode, new format */ | |
179 | #define XFS_DIFLAG_IMMUTABLE_BIT 3 /* inode is immutable */ | |
180 | #define XFS_DIFLAG_APPEND_BIT 4 /* inode is append-only */ | |
181 | #define XFS_DIFLAG_SYNC_BIT 5 /* inode is written synchronously */ | |
182 | #define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */ | |
183 | #define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */ | |
184 | #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */ | |
dd9f438e NS |
185 | #define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */ |
186 | #define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */ | |
187 | #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */ | |
188 | #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ | |
d3446eac | 189 | #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ |
2a82b8be | 190 | #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */ |
1da177e4 LT |
191 | #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) |
192 | #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) | |
193 | #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) | |
194 | #define XFS_DIFLAG_IMMUTABLE (1 << XFS_DIFLAG_IMMUTABLE_BIT) | |
195 | #define XFS_DIFLAG_APPEND (1 << XFS_DIFLAG_APPEND_BIT) | |
196 | #define XFS_DIFLAG_SYNC (1 << XFS_DIFLAG_SYNC_BIT) | |
197 | #define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT) | |
198 | #define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT) | |
199 | #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT) | |
200 | #define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT) | |
201 | #define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT) | |
dd9f438e NS |
202 | #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT) |
203 | #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT) | |
d3446eac | 204 | #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT) |
2a82b8be | 205 | #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT) |
1da177e4 | 206 | |
71ddabb9 ES |
207 | #ifdef CONFIG_XFS_RT |
208 | #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) | |
209 | #else | |
210 | #define XFS_IS_REALTIME_INODE(ip) (0) | |
211 | #endif | |
212 | ||
1da177e4 LT |
213 | #define XFS_DIFLAG_ANY \ |
214 | (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ | |
215 | XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ | |
216 | XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ | |
dd9f438e | 217 | XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \ |
2a82b8be | 218 | XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM) |
1da177e4 LT |
219 | |
220 | #endif /* __XFS_DINODE_H__ */ |