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