1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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
7 * published by the Free Software Foundation.
8 *
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.
13 *
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
17 */
18#ifndef __XFS_TYPES_H__
19#define	__XFS_TYPES_H__
20
21#ifdef __KERNEL__
22
23/*
24 * POSIX Extensions
25 */
26typedef unsigned char		uchar_t;
27typedef unsigned short		ushort_t;
28typedef unsigned int		uint_t;
29typedef unsigned long		ulong_t;
30
31/*
32 * Additional type declarations for XFS
33 */
34#ifndef __FreeBSD__
35typedef signed char		__int8_t;
36typedef unsigned char		__uint8_t;
37typedef signed short int	__int16_t;
38typedef unsigned short int	__uint16_t;
39typedef signed int		__int32_t;
40typedef unsigned int		__uint32_t;
41typedef signed long long int	__int64_t;
42typedef unsigned long long int	__uint64_t;
43
44typedef enum { B_FALSE,B_TRUE }	boolean_t;
45#endif
46
47typedef __uint32_t		prid_t;		/* project ID */
48typedef __uint32_t		inst_t;		/* an instruction */
49
50typedef __s64			xfs_off_t;	/* <file offset> type */
51typedef __u64			xfs_ino_t;	/* <inode> type */
52typedef __s64			xfs_daddr_t;	/* <disk address> type */
53typedef char *			xfs_caddr_t;	/* <core address> type */
54typedef __u32			xfs_dev_t;
55typedef __u32			xfs_nlink_t;
56
57/* __psint_t is the same size as a pointer */
58#if (BITS_PER_LONG == 32)
59typedef __int32_t __psint_t;
60typedef __uint32_t __psunsigned_t;
61#elif (BITS_PER_LONG == 64)
62typedef __int64_t __psint_t;
63typedef __uint64_t __psunsigned_t;
64#else
65#error BITS_PER_LONG must be 32 or 64
66#endif
67
68#endif	/* __KERNEL__ */
69
70typedef __uint32_t	xfs_agblock_t;	/* blockno in alloc. group */
71typedef	__uint32_t	xfs_extlen_t;	/* extent length in blocks */
72typedef	__uint32_t	xfs_agnumber_t;	/* allocation group number */
73typedef __int32_t	xfs_extnum_t;	/* # of extents in a file */
74typedef __int16_t	xfs_aextnum_t;	/* # extents in an attribute fork */
75typedef	__int64_t	xfs_fsize_t;	/* bytes in a file */
76typedef __uint64_t	xfs_ufsize_t;	/* unsigned bytes in a file */
77
78typedef	__int32_t	xfs_suminfo_t;	/* type of bitmap summary info */
79typedef	__int32_t	xfs_rtword_t;	/* word type for bitmap manipulations */
80
81typedef	__int64_t	xfs_lsn_t;	/* log sequence number */
82typedef	__int32_t	xfs_tid_t;	/* transaction identifier */
83
84typedef	__uint32_t	xfs_dablk_t;	/* dir/attr block number (in file) */
85typedef	__uint32_t	xfs_dahash_t;	/* dir/attr hash value */
86
87typedef __uint16_t	xfs_prid_t;	/* prid_t truncated to 16bits in XFS */
88
89/*
90 * These types are 64 bits on disk but are either 32 or 64 bits in memory.
91 * Disk based types:
92 */
93typedef __uint64_t	xfs_dfsbno_t;	/* blockno in filesystem (agno|agbno) */
94typedef __uint64_t	xfs_drfsbno_t;	/* blockno in filesystem (raw) */
95typedef	__uint64_t	xfs_drtbno_t;	/* extent (block) in realtime area */
96typedef	__uint64_t	xfs_dfiloff_t;	/* block number in a file */
97typedef	__uint64_t	xfs_dfilblks_t;	/* number of blocks in a file */
98
99/*
100 * Memory based types are conditional.
101 */
102#if XFS_BIG_BLKNOS
103typedef	__uint64_t	xfs_fsblock_t;	/* blockno in filesystem (agno|agbno) */
104typedef __uint64_t	xfs_rfsblock_t;	/* blockno in filesystem (raw) */
105typedef __uint64_t	xfs_rtblock_t;	/* extent (block) in realtime area */
106typedef	__int64_t	xfs_srtblock_t;	/* signed version of xfs_rtblock_t */
107#else
108typedef	__uint32_t	xfs_fsblock_t;	/* blockno in filesystem (agno|agbno) */
109typedef __uint32_t	xfs_rfsblock_t;	/* blockno in filesystem (raw) */
110typedef __uint32_t	xfs_rtblock_t;	/* extent (block) in realtime area */
111typedef	__int32_t	xfs_srtblock_t;	/* signed version of xfs_rtblock_t */
112#endif
113typedef __uint64_t	xfs_fileoff_t;	/* block number in a file */
114typedef __int64_t	xfs_sfiloff_t;	/* signed block number in a file */
115typedef __uint64_t	xfs_filblks_t;	/* number of blocks in a file */
116
117typedef __uint8_t	xfs_arch_t;	/* architecture of an xfs fs */
118
119/*
120 * Null values for the types.
121 */
122#define	NULLDFSBNO	((xfs_dfsbno_t)-1)
123#define	NULLDRFSBNO	((xfs_drfsbno_t)-1)
124#define	NULLDRTBNO	((xfs_drtbno_t)-1)
125#define	NULLDFILOFF	((xfs_dfiloff_t)-1)
126
127#define	NULLFSBLOCK	((xfs_fsblock_t)-1)
128#define	NULLRFSBLOCK	((xfs_rfsblock_t)-1)
129#define	NULLRTBLOCK	((xfs_rtblock_t)-1)
130#define	NULLFILEOFF	((xfs_fileoff_t)-1)
131
132#define	NULLAGBLOCK	((xfs_agblock_t)-1)
133#define	NULLAGNUMBER	((xfs_agnumber_t)-1)
134#define	NULLEXTNUM	((xfs_extnum_t)-1)
135
136#define NULLCOMMITLSN	((xfs_lsn_t)-1)
137
138/*
139 * Max values for extlen, extnum, aextnum.
140 */
141#define	MAXEXTLEN	((xfs_extlen_t)0x001fffff)	/* 21 bits */
142#define	MAXEXTNUM	((xfs_extnum_t)0x7fffffff)	/* signed int */
143#define	MAXAEXTNUM	((xfs_aextnum_t)0x7fff)		/* signed short */
144
145/*
146 * Min numbers of data/attr fork btree root pointers.
147 */
148#define MINDBTPTRS	3
149#define MINABTPTRS	2
150
151/*
152 * MAXNAMELEN is the length (including the terminating null) of
153 * the longest permissible file (component) name.
154 */
155#define MAXNAMELEN	256
156
157typedef struct xfs_dirent {		/* data from readdir() */
158	xfs_ino_t	d_ino;		/* inode number of entry */
159	xfs_off_t	d_off;		/* offset of disk directory entry */
160	unsigned short	d_reclen;	/* length of this record */
161	char		d_name[1];	/* name of file */
162} xfs_dirent_t;
163
164#define DIRENTBASESIZE		(((xfs_dirent_t *)0)->d_name - (char *)0)
165#define DIRENTSIZE(namelen)	\
166	((DIRENTBASESIZE + (namelen) + \
167		sizeof(xfs_off_t)) & ~(sizeof(xfs_off_t) - 1))
168
169typedef enum {
170	XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
171} xfs_lookup_t;
172
173typedef enum {
174	XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_BMAPi, XFS_BTNUM_INOi,
175	XFS_BTNUM_MAX
176} xfs_btnum_t;
177
178#endif	/* __XFS_TYPES_H__ */
179
180