2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __XFS_INUM_H__
33 #define __XFS_INUM_H__
36 * Inode number format:
37 * low inopblog bits - offset in block
38 * next agblklog bits - block number in ag
39 * next agno_log bits - ag number
40 * high agno_log-agblklog-inopblog bits - 0
43 typedef __uint32_t xfs_agino_t; /* within allocation grp inode number */
46 * Useful inode bits for this kernel.
47 * Used in some places where having 64-bits in the 32-bit kernels
51 typedef xfs_ino_t xfs_intino_t;
53 typedef __uint32_t xfs_intino_t;
56 #define NULLFSINO ((xfs_ino_t)-1)
57 #define NULLAGINO ((xfs_agino_t)-1)
61 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_MASK)
62 __uint32_t xfs_ino_mask(int k);
65 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_MASK)
66 #define XFS_INO_MASK(k) xfs_ino_mask(k)
68 #define XFS_INO_MASK(k) ((__uint32_t)((1ULL << (k)) - 1))
71 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_OFFSET_BITS)
72 int xfs_ino_offset_bits(struct xfs_mount *mp);
75 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_OFFSET_BITS)
76 #define XFS_INO_OFFSET_BITS(mp) xfs_ino_offset_bits(mp)
78 #define XFS_INO_OFFSET_BITS(mp) ((mp)->m_sb.sb_inopblog)
81 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGBNO_BITS)
82 int xfs_ino_agbno_bits(struct xfs_mount *mp);
85 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGBNO_BITS)
86 #define XFS_INO_AGBNO_BITS(mp) xfs_ino_agbno_bits(mp)
88 #define XFS_INO_AGBNO_BITS(mp) ((mp)->m_sb.sb_agblklog)
91 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGINO_BITS)
92 int xfs_ino_agino_bits(struct xfs_mount *mp);
95 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGINO_BITS)
96 #define XFS_INO_AGINO_BITS(mp) xfs_ino_agino_bits(mp)
98 #define XFS_INO_AGINO_BITS(mp) ((mp)->m_agino_log)
101 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGNO_BITS)
102 int xfs_ino_agno_bits(struct xfs_mount *mp);
105 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGNO_BITS)
106 #define XFS_INO_AGNO_BITS(mp) xfs_ino_agno_bits(mp)
108 #define XFS_INO_AGNO_BITS(mp) ((mp)->m_agno_log)
111 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_BITS)
112 int xfs_ino_bits(struct xfs_mount *mp);
115 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_BITS)
116 #define XFS_INO_BITS(mp) xfs_ino_bits(mp)
118 #define XFS_INO_BITS(mp) (XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp))
121 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGNO)
122 xfs_agnumber_t xfs_ino_to_agno(struct xfs_mount *mp, xfs_ino_t i);
125 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGNO)
126 #define XFS_INO_TO_AGNO(mp,i) xfs_ino_to_agno(mp,i)
128 #define XFS_INO_TO_AGNO(mp,i) \
129 ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
132 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGINO)
133 xfs_agino_t xfs_ino_to_agino(struct xfs_mount *mp, xfs_ino_t i);
136 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGINO)
137 #define XFS_INO_TO_AGINO(mp,i) xfs_ino_to_agino(mp,i)
139 #define XFS_INO_TO_AGINO(mp,i) \
140 ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
143 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGBNO)
144 xfs_agblock_t xfs_ino_to_agbno(struct xfs_mount *mp, xfs_ino_t i);
147 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGBNO)
148 #define XFS_INO_TO_AGBNO(mp,i) xfs_ino_to_agbno(mp,i)
150 #define XFS_INO_TO_AGBNO(mp,i) \
151 (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
152 XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
155 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_OFFSET)
156 int xfs_ino_to_offset(struct xfs_mount *mp, xfs_ino_t i);
159 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_OFFSET)
160 #define XFS_INO_TO_OFFSET(mp,i) xfs_ino_to_offset(mp,i)
162 #define XFS_INO_TO_OFFSET(mp,i) \
163 ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
166 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_FSB)
167 xfs_fsblock_t xfs_ino_to_fsb(struct xfs_mount *mp, xfs_ino_t i);
170 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_FSB)
171 #define XFS_INO_TO_FSB(mp,i) xfs_ino_to_fsb(mp,i)
173 #define XFS_INO_TO_FSB(mp,i) \
174 XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
177 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_INO)
179 xfs_agino_to_ino(struct xfs_mount *mp, xfs_agnumber_t a, xfs_agino_t i);
182 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_INO)
183 #define XFS_AGINO_TO_INO(mp,a,i) xfs_agino_to_ino(mp,a,i)
185 #define XFS_AGINO_TO_INO(mp,a,i) \
186 (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
189 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_AGBNO)
190 xfs_agblock_t xfs_agino_to_agbno(struct xfs_mount *mp, xfs_agino_t i);
193 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_AGBNO)
194 #define XFS_AGINO_TO_AGBNO(mp,i) xfs_agino_to_agbno(mp,i)
196 #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
199 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_OFFSET)
200 int xfs_agino_to_offset(struct xfs_mount *mp, xfs_agino_t i);
203 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_OFFSET)
204 #define XFS_AGINO_TO_OFFSET(mp,i) xfs_agino_to_offset(mp,i)
206 #define XFS_AGINO_TO_OFFSET(mp,i) \
207 ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
210 #if XFS_WANT_FUNCS || XFS_WANT_FUNCS_C || (XFS_WANT_SPACE && XFSSO_XFS_OFFBNO_TO_AGINO)
211 xfs_agino_t xfs_offbno_to_agino(struct xfs_mount *mp, xfs_agblock_t b, int o);
214 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_OFFBNO_TO_AGINO)
215 #define XFS_OFFBNO_TO_AGINO(mp,b,o) xfs_offbno_to_agino(mp,b,o)
217 #define XFS_OFFBNO_TO_AGINO(mp,b,o) \
218 ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
222 #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
223 #define XFS_INO64_OFFSET ((xfs_ino_t)(1ULL << 32))
225 #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL))
227 #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL))
229 #endif /* __XFS_INUM_H__ */