FreeBSD/Linux Kernel Cross Reference
sys/fs/jfs/jfs_types.h
1 /*
2 * Copyright (c) International Business Machines Corp., 2000-2002
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the 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 to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #ifndef _H_JFS_TYPES
19 #define _H_JFS_TYPES
20
21 /*
22 * jfs_types.h:
23 *
24 * basic type/utility definitions
25 *
26 * note: this header file must be the 1st include file
27 * of JFS include list in all JFS .c file.
28 */
29
30 #include <linux/types.h>
31 #include <linux/nls.h>
32
33 /*
34 * transaction and lock id's
35 */
36 typedef uint tid_t;
37 typedef uint lid_t;
38
39 /*
40 * Almost identical to Linux's timespec, but not quite
41 */
42 struct timestruc_t {
43 u32 tv_sec;
44 u32 tv_nsec;
45 };
46
47 /*
48 * handy
49 */
50
51 #define LEFTMOSTONE 0x80000000
52 #define HIGHORDER 0x80000000u /* high order bit on */
53 #define ONES 0xffffffffu /* all bit on */
54
55 typedef int boolean_t;
56 #define TRUE 1
57 #define FALSE 0
58
59 /*
60 * logical xd (lxd)
61 */
62 typedef struct {
63 unsigned len:24;
64 unsigned off1:8;
65 u32 off2;
66 } lxd_t;
67
68 /* lxd_t field construction */
69 #define LXDlength(lxd, length32) ( (lxd)->len = length32 )
70 #define LXDoffset(lxd, offset64)\
71 {\
72 (lxd)->off1 = ((s64)offset64) >> 32;\
73 (lxd)->off2 = (offset64) & 0xffffffff;\
74 }
75
76 /* lxd_t field extraction */
77 #define lengthLXD(lxd) ( (lxd)->len )
78 #define offsetLXD(lxd)\
79 ( ((s64)((lxd)->off1)) << 32 | (lxd)->off2 )
80
81 /* lxd list */
82 struct lxdlist {
83 s16 maxnlxd;
84 s16 nlxd;
85 lxd_t *lxd;
86 };
87
88 /*
89 * physical xd (pxd)
90 */
91 typedef struct {
92 unsigned len:24;
93 unsigned addr1:8;
94 u32 addr2;
95 } pxd_t;
96
97 /* xd_t field construction */
98
99 #define PXDlength(pxd, length32) ((pxd)->len = __cpu_to_le24(length32))
100 #define PXDaddress(pxd, address64)\
101 {\
102 (pxd)->addr1 = ((s64)address64) >> 32;\
103 (pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
104 }
105
106 /* xd_t field extraction */
107 #define lengthPXD(pxd) __le24_to_cpu((pxd)->len)
108 #define addressPXD(pxd)\
109 ( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
110
111 /* pxd list */
112 struct pxdlist {
113 s16 maxnpxd;
114 s16 npxd;
115 pxd_t pxd[8];
116 };
117
118
119 /*
120 * data extent descriptor (dxd)
121 */
122 typedef struct {
123 unsigned flag:8; /* 1: flags */
124 unsigned rsrvd:24; /* 3: */
125 u32 size; /* 4: size in byte */
126 unsigned len:24; /* 3: length in unit of fsblksize */
127 unsigned addr1:8; /* 1: address in unit of fsblksize */
128 u32 addr2; /* 4: address in unit of fsblksize */
129 } dxd_t; /* - 16 - */
130
131 /* dxd_t flags */
132 #define DXD_INDEX 0x80 /* B+-tree index */
133 #define DXD_INLINE 0x40 /* in-line data extent */
134 #define DXD_EXTENT 0x20 /* out-of-line single extent */
135 #define DXD_FILE 0x10 /* out-of-line file (inode) */
136 #define DXD_CORRUPT 0x08 /* Inconsistency detected */
137
138 /* dxd_t field construction
139 * Conveniently, the PXD macros work for DXD
140 */
141 #define DXDlength PXDlength
142 #define DXDaddress PXDaddress
143 #define lengthDXD lengthPXD
144 #define addressDXD addressPXD
145 #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
146 #define sizeDXD(dxd) le32_to_cpu((dxd)->size)
147
148 /*
149 * directory entry argument
150 */
151 struct component_name {
152 int namlen;
153 wchar_t *name;
154 };
155
156
157 /*
158 * DASD limit information - stored in directory inode
159 */
160 struct dasd {
161 u8 thresh; /* Alert Threshold (in percent) */
162 u8 delta; /* Alert Threshold delta (in percent) */
163 u8 rsrvd1;
164 u8 limit_hi; /* DASD limit (in logical blocks) */
165 u32 limit_lo; /* DASD limit (in logical blocks) */
166 u8 rsrvd2[3];
167 u8 used_hi; /* DASD usage (in logical blocks) */
168 u32 used_lo; /* DASD usage (in logical blocks) */
169 };
170
171 #define DASDLIMIT(dasdp) \
172 (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
173 #define setDASDLIMIT(dasdp, limit)\
174 {\
175 (dasdp)->limit_hi = ((u64)limit) >> 32;\
176 (dasdp)->limit_lo = __cpu_to_le32(limit);\
177 }
178 #define DASDUSED(dasdp) \
179 (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
180 #define setDASDUSED(dasdp, used)\
181 {\
182 (dasdp)->used_hi = ((u64)used) >> 32;\
183 (dasdp)->used_lo = __cpu_to_le32(used);\
184 }
185
186 #endif /* !_H_JFS_TYPES */
Cache object: d99ce33ca191ab7f47ea00e465317a64
|