libparted 3.6
Loading...
Searching...
No Matches
jfs_types.h
Go to the documentation of this file.
1/*
2 * Copyright (c) International Business Machines Corp., 2000
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 3 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, see <http://www.gnu.org/licenses/>.
16 */
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#ifdef _JFS_UTILITY
31/* this is defined in asm/byteorder.h for i386, but
32 * is NOT defined in asm/byteorder.h for ppc (non-kernel).
33 * Until that is changed, we'll define it here. */
34#define __BYTEORDER_HAS_U64__
35
36#include <sys/types.h>
37//#include <asm/byteorder.h>
38typedef unsigned short UniChar;
39#else
40#include <linux/types.h>
41#include <linux/jfs_fs.h>
42#include <linux/nls.h>
43
44#ifndef _ULS_UNICHAR_DEFINED
45#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0))
46typedef wchar_t UniChar;
47#else
48typedef unsigned short UniChar;
49#endif
50#define _ULS_UNICHAR_DEFINED
51#endif
52#endif
53/* #include "endian24.h" */
54
55/*
56 * primitive types
57 */
58#ifdef _JFS_UTILITY
59typedef int8_t s8;
60typedef uint8_t u8;
61typedef int16_t s16;
62typedef uint16_t u16;
63typedef int32_t s32;
64typedef uint32_t u32;
65typedef int64_t s64;
66typedef uint64_t u64;
67
68#ifndef _UINT_TYPES
69 /* unicode includes also define these */
70typedef u16 uint16;
71typedef u32 uint32;
72#define _UINT_TYPES
73#endif
74
75typedef s8 int8;
76typedef u8 uint8;
77typedef s16 int16;
78typedef s32 int32;
79typedef s64 int64;
80typedef u64 uint64;
81
82#endif /* _JFS_UTILITY */
83/*
84 * Holdovers from OS/2. Try to get away from using these altogether.
85 */
86typedef unsigned long ULONG;
87typedef unsigned short USHORT;
88typedef unsigned char UCHAR;
89typedef void *PVOID;
90#define MAXPATHLEN 255
91
92
93/*
94 * Almost identical to Linux's timespec, but not quite
95 */
97 u32 tv_sec;
99};
100
101/*
102 * handy
103 */
104#undef MIN
105#define MIN(a,b) (((a)<(b))?(a):(b))
106#undef MAX
107#define MAX(a,b) (((a)>(b))?(a):(b))
108#undef ROUNDUP
109#define ROUNDUP(x, y) ( ((x) + ((y) - 1)) & ~((y) - 1) )
110
111#define LEFTMOSTONE 0x80000000
112#define HIGHORDER 0x80000000u /* high order bit on */
113#define ONES 0xffffffffu /* all bit on */
114
115typedef int boolean_t;
116#define TRUE 1
117#define FALSE 0
118
119/*
120 * logical xd (lxd)
121 */
122typedef struct {
123 unsigned len:24;
124 unsigned off1:8;
125 u32 off2;
126} lxd_t;
127
128/* lxd_t field construction */
129#define LXDlength(lxd, length32) ( (lxd)->len = length32 )
130#define LXDoffset(lxd, offset64)\
131{\
132 (lxd)->off1 = ((s64)offset64) >> 32;\
133 (lxd)->off2 = (offset64) & 0xffffffff;\
134}
135
136/* lxd_t field extraction */
137#define lengthLXD(lxd) ( (lxd)->len )
138#define offsetLXD(lxd)\
139 ( ((s64)((lxd)->off1)) << 32 | (lxd)->off2 )
140
141/* lxd list */
142typedef struct {
144 s16 nlxd;
146} lxdlist_t;
147
148/*
149 * physical xd (pxd)
150 */
151typedef struct {
152 unsigned len:24;
153 unsigned addr1:8;
154 u32 addr2;
155} pxd_t;
156
157/* xd_t field construction */
158
159#define PXDlength(pxd, length32) ((pxd)->len = __cpu_to_le24(length32))
160#define PXDaddress(pxd, address64)\
161{\
162 (pxd)->addr1 = ((s64)address64) >> 32;\
163 (pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
164}
165
166/* xd_t field extraction */
167#define lengthPXD(pxd) __le24_to_cpu((pxd)->len)
168#define addressPXD(pxd)\
169 ( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
170
171/* pxd list */
172typedef struct {
174 s16 npxd;
175 pxd_t pxd[8];
176} pxdlist_t;
177
178
179/*
180 * data extent descriptor (dxd)
181 */
182typedef struct {
183 unsigned flag:8; /* 1: flags */
184 unsigned rsrvd:24; /* 3: */
185 u32 size; /* 4: size in byte */
186 unsigned len:24; /* 3: length in unit of fsblksize */
187 unsigned addr1:8; /* 1: address in unit of fsblksize */
188 u32 addr2; /* 4: address in unit of fsblksize */
189} dxd_t; /* - 16 - */
190
191/* dxd_t flags */
192#define DXD_INDEX 0x80 /* B+-tree index */
193#define DXD_INLINE 0x40 /* in-line data extent */
194#define DXD_EXTENT 0x20 /* out-of-line single extent */
195#define DXD_FILE 0x10 /* out-of-line file (inode) */
196#define DXD_CORRUPT 0x08 /* Inconsistency detected */
197
198/* dxd_t field construction
199 * Conveniently, the PXD macros work for DXD
200 */
201#define DXDlength PXDlength
202#define DXDaddress PXDaddress
203#define lengthDXD lengthPXD
204#define addressDXD addressPXD
205
206/*
207 * directory entry argument
208 */
209typedef struct component_name {
213
214
215/*
216 * DASD limit information - stored in directory inode
217 */
218typedef struct dasd {
219 u8 thresh; /* Alert Threshold (in percent) */
220 u8 delta; /* Alert Threshold delta (in percent) */
222 u8 limit_hi; /* DASD limit (in logical blocks) */
223 u32 limit_lo; /* DASD limit (in logical blocks) */
224 u8 rsrvd2[3];
225 u8 used_hi; /* DASD usage (in logical blocks) */
226 u32 used_lo; /* DASD usage (in logical blocks) */
228
229#define DASDLIMIT(dasdp) \
230 (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
231#define setDASDLIMIT(dasdp, limit)\
232{\
233 (dasdp)->limit_hi = ((u64)limit) >> 32;\
234 (dasdp)->limit_lo = __cpu_to_le32(limit);\
235}
236#define DASDUSED(dasdp) \
237 (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
238#define setDASDUSED(dasdp, used)\
239{\
240 (dasdp)->used_hi = ((u64)used) >> 32;\
241 (dasdp)->used_lo = __cpu_to_le32(used);\
242}
243
244/*
245 * circular doubly-linked list (cdll)
246 *
247 * A circular doubly-linked list (cdll) is anchored by a pair of pointers,
248 * one to the head of the list and the other to the tail of the list.
249 * The elements are doubly linked so that an arbitrary element can be
250 * removed without a need to traverse the list.
251 * New elements can be added to the list before or after an existing element,
252 * at the head of the list, or at the tail of the list.
253 * A circle queue may be traversed in either direction.
254 *
255 * +----------+ +-------------------------------------+
256 * | | | |
257 * +->+-----+ | +->+-----+ +->+-----+ +->+-----+ |
258 * | | h +-+ | | h +--+ | n +----+ | n +--+
259 * | +-----+ | +-----+ | +-----+ | +-----+
260 * | | t +-+ +-----+ t | | | p +--+ | | p +--+
261 * | +-----+ | | | +-----+ | +-----+ | | +-----+ |
262 * +----------+ | +-----------------------+ | |
263 * | | | |
264 * | +-------------------------+
265 * | |
266 * +----------------------------+
267 */
268/*
269 * define header
270 *
271 * list header field definition in header element:
272 *
273 * type - type of list element struct embedding the link field
274 */
275#define CDLL_HEADER(type)\
276struct {\
277 struct type *head;\
278 struct type *tail;\
279}
280
284};
285
286/*
287 * define link
288 *
289 * list link field definition in list element:
290 *
291 * type - type of parent list element struct embedding the link field
292 */
293#define CDLL_ENTRY(type)\
294struct {\
295 struct type *next;\
296 struct type *prev;\
297}
298
302};
303
304/*
305 * initialize header
306 *
307 * header - ptr to the header field in the header element
308 */
309#define CDLL_INIT(header) {\
310 (header)->head = (void *)(header);\
311 (header)->tail = (void *)(header);\
312}
313
314/*
315 * scan list
316 *
317 * header - ptr to the header field in the header element
318 * elm - ptr to the element to be inserted
319 * field - name of the link field in the list element
320 *
321 * struct header_container *container;
322 * struct header_type *header;
323 * struct element_type *elm;
324 *
325 * header = &container->header_field;
326 * for (elm = header->head; elm != (void *)header; elm = elm->field.next)
327 */
328
329/*
330 * insert <elm> at head of list anchored at <header>
331 *
332 * header - ptr to the header field in the header element
333 * elm - ptr to the list element to be inserted
334 * field - name of the link field in the list element
335 */
336#define CDLL_INSERT_HEAD(header, elm, field) {\
337 (elm)->field.next = (header)->head;\
338 (elm)->field.prev = (void *)(header);\
339 if ((header)->tail == (void *)(header))\
340 (header)->tail = (elm);\
341 else\
342 (header)->head->field.prev = (elm);\
343 (header)->head = (elm);\
344}
345
346/*
347 * insert <elm> at tail of list anchored at <header>
348 *
349 * header - ptr to the header field in the header element
350 * elm - ptr to the list element to be inserted
351 * field - name of the link field in the list element
352 */
353#define CDLL_INSERT_TAIL(header, elm, field) {\
354 (elm)->field.next = (void *)(header);\
355 (elm)->field.prev = (header)->tail;\
356 if ((header)->head == (void *)(header))\
357 (header)->head = (elm);\
358 else\
359 (header)->tail->field.next = (elm);\
360 (header)->tail = (elm);\
361}
362
363/*
364 * insert <elm> after <listelm> of list anchored at <header>
365 *
366 * header - ptr to the header field in the header element
367 * listelm - ptr to the list element at insertion point
368 * elm - ptr to the list element to be inserted
369 * field - name of the link field in the list element
370 */
371#define CDLL_INSERT_AFTER(header, listelm, elm, field) {\
372 (elm)->field.next = (listelm)->field.next;\
373 (elm)->field.prev = (listelm);\
374 if ((listelm)->field.next == (void *)(header))\
375 (header)->tail = (elm);\
376 else\
377 (listelm)->field.next->field.prev = (elm);\
378 (listelm)->field.next = (elm);\
379}
380
381/*
382 * insert <elm> before <listelm> of list anchored at <header>
383 *
384 * header - ptr to the header field in the header element
385 * listelm - ptr to list element at insertion point
386 * elm - ptr to the element to be inserted
387 * field - name of the link field in the list element
388 */
389#define CDLL_INSERT_BEFORE(header, listelm, elm, field) {\
390 (elm)->field.next = (listelm);\
391 (elm)->field.prev = (listelm)->field.prev;\
392 if ((listelm)->field.prev == (void *)(header))\
393 (header)->head = (elm);\
394 else\
395 (listelm)->field.prev->field.next = (elm);\
396 (listelm)->field.prev = (elm);\
397}
398
399/*
400 * remove <elm> from list anchored at <header>
401 *
402 * header - ptr to the header field in the header element
403 * elm - ptr to the list element to be removed
404 * field - name of the link field in the list element
405 */
406#define CDLL_REMOVE(header, elm, field) {\
407 if ((elm)->field.next == (void *)(header))\
408 (header)->tail = (elm)->field.prev;\
409 else\
410 (elm)->field.next->field.prev = (elm)->field.prev;\
411 if ((elm)->field.prev == (void *)(header))\
412 (header)->head = (elm)->field.next;\
413 else\
414 (elm)->field.prev->field.next = (elm)->field.next;\
415}
416
417#define CDLL_MOVE_TO_HEAD(header, elm, field) {\
418 if ((elm)->field.prev != (void *)(header))\
419 {\
420 if ((elm)->field.next == (void *)(header))\
421 (header)->tail = (elm)->field.prev;\
422 else\
423 (elm)->field.next->field.prev = (elm)->field.prev;\
424 (elm)->field.prev->field.next = (elm)->field.next;\
425 (elm)->field.next = (header)->head;\
426 (elm)->field.prev = (void *)(header);\
427 (header)->head->field.prev = (elm);\
428 (header)->head = (elm);\
429 }\
430}
431
432#define CDLL_MOVE_TO_TAIL(header, elm, field) {\
433 if ((elm)->field.next != (void *)(header))\
434 {\
435 (elm)->field.next->field.prev = (elm)->field.prev;\
436 if ((elm)->field.prev == (void *)(header))\
437 (header)->head = (elm)->field.next;\
438 else\
439 (elm)->field.prev->field.next = (elm)->field.next;\
440 (elm)->field.next = (void *)(header);\
441 (elm)->field.prev = (header)->tail;\
442 (header)->tail->field.next = (elm);\
443 (header)->tail = (elm);\
444 }\
445}
446
447/*
448 * orphan list element
449 */
450#define CDLL_SELF(elm, field)\
451 (elm)->field.next = (elm)->field.prev = (elm);
452
453
454/*
455 * single head doubly-linked list
456 *
457 * A list is headed by a single head pointer.
458 * The elements are doubly linked so that an arbitrary element can be
459 * removed without a need to traverse the list.
460 * New elements can be added to the list at the head of the list, or
461 * after an existing element (NO insert at tail).
462 * A list may only be traversed in the forward direction.
463 * (note: the list is NULL terminated in next field.)
464 *
465 * +-----+ +->+-----+ +->+-----+ +->+-----+
466 * | NULL| | | h +--+ | n +----+ | NULL|
467 * +-----+ | +-----+ | +-----+ +-----+
468 * | | | p +--+ | p +--+
469 * | | +-----+ | +-----+ |
470 * +-----------------------+ |
471 * | |
472 * +-------------------------+
473 */
474#define LIST_HEADER(type)\
475struct {\
476 struct type *head;\
477}
478
479#define LIST_ENTRY(type)\
480struct {\
481 struct type *next;\
482 struct type **prev;\
483}
484
485#define LIST_INIT(header) { (header)->head = NULL; }
486
487/*
488 * scan list
489 *
490 * header - ptr to the header (field in header element)
491 * elm - ptr to the element to be inserted
492 * field - name of the link field in list element
493 *
494 * struct header_container *container;
495 * struct header_type *header;
496 * struct element_type *elm;
497 *
498 * header = &container->header_field;
499 * for (elm = header->head; elm; elm = elm->field.next)
500 */
501
502#define LIST_INSERT_HEAD(header, elm, field) {\
503 if (((elm)->field.next = (header)->head) != NULL)\
504 (header)->head->field.prev = &(elm)->field.next;\
505 (header)->head = (elm);\
506 (elm)->field.prev = &(header)->head;\
507}
508
509#define LIST_INSERT_AFTER(listelm, elm, field) {\
510 if (((elm)->field.next = (listelm)->field.next) != NULL)\
511 (listelm)->field.next->field.prev = &(elm)->field.next;\
512 (listelm)->field.next = (elm);\
513 (elm)->field.prev = &(listelm)->field.next;\
514}
515
516#define LIST_REMOVE(elm, field) {\
517 if ((elm)->field.next != NULL)\
518 (elm)->field.next->field.prev = (elm)->field.prev;\
519 *(elm)->field.prev = (elm)->field.next;\
520}
521
522#define LIST_SELF(elm, field) {\
523 (elm)->field.next = NULL;\
524 (elm)->field.prev = &(elm)->field.next;\
525}
526
527#endif /* !_H_JFS_TYPES */
void * PVOID
Definition: jfs_types.h:89
unsigned char UCHAR
Definition: jfs_types.h:88
unsigned short USHORT
Definition: jfs_types.h:87
unsigned short UniChar
Definition: jfs_types.h:48
struct component_name component_t
int boolean_t
Definition: jfs_types.h:115
struct dasd dasd_t
unsigned long ULONG
Definition: jfs_types.h:86
Definition: jfs_types.h:299
struct cdll_entry * prev
Definition: jfs_types.h:301
struct cdll_entry * next
Definition: jfs_types.h:300
Definition: jfs_types.h:281
struct cdll_header * head
Definition: jfs_types.h:282
struct cdll_header * tail
Definition: jfs_types.h:283
Definition: jfs_types.h:209
int namlen
Definition: jfs_types.h:210
UniChar * name
Definition: jfs_types.h:211
Definition: jfs_types.h:218
u32 limit_lo
Definition: jfs_types.h:223
u8 delta
Definition: jfs_types.h:220
u8 thresh
Definition: jfs_types.h:219
u8 used_hi
Definition: jfs_types.h:225
u8 rsrvd2[3]
Definition: jfs_types.h:224
u32 used_lo
Definition: jfs_types.h:226
u8 rsrvd1
Definition: jfs_types.h:221
u8 limit_hi
Definition: jfs_types.h:222
Definition: jfs_types.h:182
unsigned rsrvd
Definition: jfs_types.h:184
u32 size
Definition: jfs_types.h:185
u32 addr2
Definition: jfs_types.h:188
unsigned flag
Definition: jfs_types.h:183
unsigned addr1
Definition: jfs_types.h:187
unsigned len
Definition: jfs_types.h:186
Definition: jfs_types.h:122
unsigned len
Definition: jfs_types.h:123
u32 off2
Definition: jfs_types.h:125
unsigned off1
Definition: jfs_types.h:124
Definition: jfs_types.h:142
s16 nlxd
Definition: jfs_types.h:144
s16 maxnlxd
Definition: jfs_types.h:143
lxd_t * lxd
Definition: jfs_types.h:145
Definition: jfs_types.h:151
unsigned addr1
Definition: jfs_types.h:153
u32 addr2
Definition: jfs_types.h:154
unsigned len
Definition: jfs_types.h:152
Definition: jfs_types.h:172
s16 npxd
Definition: jfs_types.h:174
s16 maxnpxd
Definition: jfs_types.h:173
Definition: jfs_types.h:96
u32 tv_nsec
Definition: jfs_types.h:98
u32 tv_sec
Definition: jfs_types.h:97