|
|
1.1 root 1: /* xfs.h - an extraction from xfsprogs-1.3.5/include/xfs* into one file */
2: /*
3: * GRUB -- GRand Unified Bootloader
4: * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
5: * Copyright (C) 2001 Free Software Foundation, Inc.
6: *
7: * This program is free software; you can redistribute it and/or modify it
8: * under the terms of version 2 of the GNU General Public License as
9: * published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it would be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14: *
15: * Further, this software is distributed without any warranty that it is
16: * free of the rightful claim of any third person regarding infringement
17: * or the like. Any license provided herein, whether implied or
18: * otherwise, applies only to this software file. Patent licenses, if
19: * any, provided herein do not apply to combinations of this program with
20: * other software, or any other product whatsoever.
21: *
22: * You should have received a copy of the GNU General Public License along
23: * with this program; if not, write the Free Software Foundation, Inc.,
24: * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25: *
26: * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27: * Mountain View, CA 94043, or:
28: *
29: * http://www.sgi.com
30: *
31: * For further information regarding this notice, see:
32: *
33: * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34: */
35:
36: #ifndef _BITS_TYPES_H
37: typedef signed char __int8_t;
38: typedef unsigned char __uint8_t;
39: typedef short __int16_t;
40: typedef unsigned short __uint16_t;
41: typedef int __int32_t;
42: typedef unsigned int __uint32_t;
43: typedef long long __int64_t;
44: typedef unsigned long long __uint64_t;
45: #endif
46:
47: typedef __uint64_t xfs_ino_t;
48: typedef __uint32_t xfs_agino_t;
49: typedef __int64_t xfs_daddr_t;
50: typedef __int64_t xfs_off_t;
51: typedef __uint8_t uuid_t[16];
52:
53:
54: /* those are from xfs_types.h */
55:
56: typedef __uint32_t xfs_agblock_t; /* blockno in alloc. group */
57: typedef __uint32_t xfs_extlen_t; /* extent length in blocks */
58: typedef __uint32_t xfs_agnumber_t; /* allocation group number */
59: typedef __int32_t xfs_extnum_t; /* # of extents in a file */
60: typedef __int16_t xfs_aextnum_t; /* # extents in an attribute fork */
61: typedef __int64_t xfs_fsize_t; /* bytes in a file */
62:
63: typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */
64: typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */
65:
66: /*
67: * Disk based types:
68: */
69: typedef __uint64_t xfs_dfsbno_t; /* blockno in filesystem (agno|agbno) */
70: typedef __uint64_t xfs_drfsbno_t; /* blockno in filesystem (raw) */
71: typedef __uint64_t xfs_drtbno_t; /* extent (block) in realtime area */
72: typedef __uint64_t xfs_dfiloff_t; /* block number in a file */
73:
74: typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */
75: typedef __uint64_t xfs_fileoff_t; /* block number in a file */
76: typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */
77:
78:
79: /* those are from xfs_sb.h */
80:
81: #define XFS_SB_MAGIC 0x58465342 /* 'XFSB'*/
82: #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
83: #define XFS_SB_VERSION_NUMBITS 0x000f
84:
85: typedef struct xfs_sb
86: {
87: __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
88: __uint32_t sb_blocksize; /* logical block size, bytes */
89: xfs_drfsbno_t sb_dblocks; /* number of data blocks */
90: xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
91: xfs_drtbno_t sb_rextents; /* number of realtime extents */
92: uuid_t sb_uuid; /* file system unique id */
93: xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
94: xfs_ino_t sb_rootino; /* root inode number */
95: xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
96: xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
97: xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
98: xfs_agblock_t sb_agblocks; /* size of an allocation group */
99: xfs_agnumber_t sb_agcount; /* number of allocation groups */
100: xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
101: xfs_extlen_t sb_logblocks; /* number of log blocks */
102: __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
103: __uint16_t sb_sectsize; /* volume sector size, bytes */
104: __uint16_t sb_inodesize; /* inode size, bytes */
105: __uint16_t sb_inopblock; /* inodes per block */
106: char sb_fname[12]; /* file system name */
107: __uint8_t sb_blocklog; /* log2 of sb_blocksize */
108: __uint8_t sb_sectlog; /* log2 of sb_sectsize */
109: __uint8_t sb_inodelog; /* log2 of sb_inodesize */
110: __uint8_t sb_inopblog; /* log2 of sb_inopblock */
111: __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
112: __uint8_t sb_rextslog; /* log2 of sb_rextents */
113: __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
114: __uint8_t sb_imax_pct; /* max % of fs for inode space */
115: /* statistics */
116: /*
117: * These fields must remain contiguous. If you really
118: * want to change their layout, make sure you fix the
119: * code in xfs_trans_apply_sb_deltas().
120: */
121: __uint64_t sb_icount; /* allocated inodes */
122: __uint64_t sb_ifree; /* free inodes */
123: __uint64_t sb_fdblocks; /* free data blocks */
124: __uint64_t sb_frextents; /* free realtime extents */
125: /*
126: * End contiguous fields.
127: */
128: xfs_ino_t sb_uquotino; /* user quota inode */
129: xfs_ino_t sb_gquotino; /* group quota inode */
130: __uint16_t sb_qflags; /* quota flags */
131: __uint8_t sb_flags; /* misc. flags */
132: __uint8_t sb_shared_vn; /* shared version number */
133: xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
134: __uint32_t sb_unit; /* stripe or raid unit */
135: __uint32_t sb_width; /* stripe or raid width */
136: __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
137: __uint8_t sb_dummy[7]; /* padding */
138: } xfs_sb_t;
139:
140:
141: /* those are from xfs_btree.h */
142:
143: /*
144: * Long form header: bmap btrees.
145: */
146: typedef struct xfs_btree_lblock
147: {
148: __uint32_t bb_magic; /* magic number for block type */
149: __uint16_t bb_level; /* 0 is a leaf */
150: __uint16_t bb_numrecs; /* current # of data records */
151: xfs_dfsbno_t bb_leftsib; /* left sibling block or NULLDFSBNO */
152: xfs_dfsbno_t bb_rightsib; /* right sibling block or NULLDFSBNO */
153: } xfs_btree_lblock_t;
154:
155: /*
156: * Combined header and structure, used by common code.
157: */
158: typedef struct xfs_btree_hdr
159: {
160: __uint32_t bb_magic; /* magic number for block type */
161: __uint16_t bb_level; /* 0 is a leaf */
162: __uint16_t bb_numrecs; /* current # of data records */
163: } xfs_btree_hdr_t;
164:
165: typedef struct xfs_btree_block
166: {
167: xfs_btree_hdr_t bb_h; /* header */
168: union {
169: struct {
170: xfs_agblock_t bb_leftsib;
171: xfs_agblock_t bb_rightsib;
172: } s; /* short form pointers */
173: struct {
174: xfs_dfsbno_t bb_leftsib;
175: xfs_dfsbno_t bb_rightsib;
176: } l; /* long form pointers */
177: } bb_u; /* rest */
178: } xfs_btree_block_t;
179:
180: /* those are from xfs_bmap_btree.h */
181:
182: /*
183: * Bmap root header, on-disk form only.
184: */
185: typedef struct xfs_bmdr_block
186: {
187: __uint16_t bb_level; /* 0 is a leaf */
188: __uint16_t bb_numrecs; /* current # of data records */
189: } xfs_bmdr_block_t;
190:
191: /*
192: * Bmap btree record and extent descriptor.
193: * For 32-bit kernels,
194: * l0:31 is an extent flag (value 1 indicates non-normal).
195: * l0:0-30 and l1:9-31 are startoff.
196: * l1:0-8, l2:0-31, and l3:21-31 are startblock.
197: * l3:0-20 are blockcount.
198: * For 64-bit kernels,
199: * l0:63 is an extent flag (value 1 indicates non-normal).
200: * l0:9-62 are startoff.
201: * l0:0-8 and l1:21-63 are startblock.
202: * l1:0-20 are blockcount.
203: */
204:
205: #define BMBT_USE_64 1
206:
207: typedef struct xfs_bmbt_rec_32
208: {
209: __uint32_t l0, l1, l2, l3;
210: } xfs_bmbt_rec_32_t;
211: typedef struct xfs_bmbt_rec_64
212: {
213: __uint64_t l0, l1;
214: } xfs_bmbt_rec_64_t;
215:
216: #if BMBT_USE_64
217: typedef __uint64_t xfs_bmbt_rec_base_t; /* use this for casts */
218: typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
219: #else /* !BMBT_USE_64 */
220: typedef __uint32_t xfs_bmbt_rec_base_t; /* use this for casts */
221: typedef xfs_bmbt_rec_32_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
222: #endif /* BMBT_USE_64 */
223:
224: /*
225: * Key structure for non-leaf levels of the tree.
226: */
227: typedef struct xfs_bmbt_key
228: {
229: xfs_dfiloff_t br_startoff; /* starting file offset */
230: } xfs_bmbt_key_t, xfs_bmdr_key_t;
231:
232: typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; /* btree pointer type */
233: /* btree block header type */
234: typedef struct xfs_btree_lblock xfs_bmbt_block_t;
235:
236:
237: /* those are from xfs_dir2.h */
238: /*
239: * Directory version 2.
240: * There are 4 possible formats:
241: * shortform
242: * single block - data with embedded leaf at the end
243: * multiple data blocks, single leaf+freeindex block
244: * data blocks, node&leaf blocks (btree), freeindex blocks
245: *
246: * The shortform format is in xfs_dir2_sf.h.
247: * The single block format is in xfs_dir2_block.h.
248: * The data block format is in xfs_dir2_data.h.
249: * The leaf and freeindex block formats are in xfs_dir2_leaf.h.
250: * Node blocks are the same as the other version, in xfs_da_btree.h.
251: */
252:
253: /*
254: * Byte offset in data block and shortform entry.
255: */
256: typedef __uint16_t xfs_dir2_data_off_t;
257:
258: /*
259: * Byte offset in a directory.
260: */
261: typedef xfs_off_t xfs_dir2_off_t;
262:
263: /* those are from xfs_da_btree.h */
264: /*========================================================================
265: * Directory Structure when greater than XFS_LBSIZE(mp) bytes.
266: *========================================================================*/
267:
268: /*
269: * This structure is common to both leaf nodes and non-leaf nodes in the Btree.
270: *
271: * Is is used to manage a doubly linked list of all blocks at the same
272: * level in the Btree, and to identify which type of block this is.
273: */
274: #define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */
275: #define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */
276:
277: typedef struct xfs_da_blkinfo {
278: xfs_dablk_t forw; /* previous block in list */
279: xfs_dablk_t back; /* following block in list */
280: __uint16_t magic; /* validity check on block */
281: __uint16_t pad; /* unused */
282: } xfs_da_blkinfo_t;
283:
284: /*
285: * This is the structure of the root and intermediate nodes in the Btree.
286: * The leaf nodes are defined above.
287: *
288: * Entries are not packed.
289: *
290: * Since we have duplicate keys, use a binary search but always follow
291: * all match in the block, not just the first match found.
292: */
293:
294: typedef struct xfs_da_intnode {
295: struct xfs_da_node_hdr { /* constant-structure header block */
296: xfs_da_blkinfo_t info; /* block type, links, etc. */
297: __uint16_t count; /* count of active entries */
298: __uint16_t level; /* level above leaves (leaf == 0) */
299: } hdr;
300: struct xfs_da_node_entry {
301: xfs_dahash_t hashval; /* hash value for this descendant */
302: xfs_dablk_t before; /* Btree block before this key */
303: } btree[1]; /* variable sized array of keys */
304: } xfs_da_intnode_t;
305:
306:
307: /* those are from xfs_dir2_data.h */
308: /*
309: * Directory format 2, data block structures.
310: */
311:
312: /*
313: * Constants.
314: */
315: #define XFS_DIR2_DATA_FREE_TAG 0xffff
316: #define XFS_DIR2_DATA_FD_COUNT 3
317:
318: /*
319: * Structures.
320: */
321:
322: /*
323: * Describe a free area in the data block.
324: * The freespace will be formatted as a xfs_dir2_data_unused_t.
325: */
326: typedef struct xfs_dir2_data_free {
327: xfs_dir2_data_off_t offset; /* start of freespace */
328: xfs_dir2_data_off_t length; /* length of freespace */
329: } xfs_dir2_data_free_t;
330:
331: /*
332: * Header for the data blocks.
333: * Always at the beginning of a directory-sized block.
334: * The code knows that XFS_DIR2_DATA_FD_COUNT is 3.
335: */
336: typedef struct xfs_dir2_data_hdr {
337: __uint32_t magic; /* XFS_DIR2_DATA_MAGIC */
338: /* or XFS_DIR2_BLOCK_MAGIC */
339: xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
340: } xfs_dir2_data_hdr_t;
341:
342: /*
343: * Active entry in a data block. Aligned to 8 bytes.
344: * Tag appears as the last 2 bytes.
345: */
346: typedef struct xfs_dir2_data_entry {
347: xfs_ino_t inumber; /* inode number */
348: __uint8_t namelen; /* name length */
349: __uint8_t name[1]; /* name bytes, no null */
350: /* variable offset */
351: xfs_dir2_data_off_t tag; /* starting offset of us */
352: } xfs_dir2_data_entry_t;
353:
354: /*
355: * Unused entry in a data block. Aligned to 8 bytes.
356: * Tag appears as the last 2 bytes.
357: */
358: typedef struct xfs_dir2_data_unused {
359: __uint16_t freetag; /* XFS_DIR2_DATA_FREE_TAG */
360: xfs_dir2_data_off_t length; /* total free length */
361: /* variable offset */
362: xfs_dir2_data_off_t tag; /* starting offset of us */
363: } xfs_dir2_data_unused_t;
364:
365: typedef union {
366: xfs_dir2_data_entry_t entry;
367: xfs_dir2_data_unused_t unused;
368: } xfs_dir2_data_union_t;
369:
370:
371: /* those are from xfs_dir2_leaf.h */
372: /*
373: * Directory version 2, leaf block structures.
374: */
375:
376: /*
377: * Leaf block header.
378: */
379: typedef struct xfs_dir2_leaf_hdr {
380: xfs_da_blkinfo_t info; /* header for da routines */
381: __uint16_t count; /* count of entries */
382: __uint16_t stale; /* count of stale entries */
383: } xfs_dir2_leaf_hdr_t;
384:
385:
386: /* those are from xfs_dir2_block.h */
387: /*
388: * xfs_dir2_block.h
389: * Directory version 2, single block format structures
390: */
391:
392: /*
393: * The single block format is as follows:
394: * xfs_dir2_data_hdr_t structure
395: * xfs_dir2_data_entry_t and xfs_dir2_data_unused_t structures
396: * xfs_dir2_leaf_entry_t structures
397: * xfs_dir2_block_tail_t structure
398: */
399:
400: #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */
401:
402: typedef struct xfs_dir2_block_tail {
403: __uint32_t count; /* count of leaf entries */
404: __uint32_t stale; /* count of stale lf entries */
405: } xfs_dir2_block_tail_t;
406:
407:
408: /* those are from xfs_dir2_sf.h */
409:
410: /*
411: * Directory layout when stored internal to an inode.
412: *
413: * Small directories are packed as tightly as possible so as to
414: * fit into the literal area of the inode.
415: */
416:
417: /*
418: * Inode number stored as 8 8-bit values.
419: */
420: typedef struct { __uint8_t i[8]; } xfs_dir2_ino8_t;
421:
422: /*
423: * Inode number stored as 4 8-bit values.
424: * Works a lot of the time, when all the inode numbers in a directory
425: * fit in 32 bits.
426: */
427: typedef struct { __uint8_t i[4]; } xfs_dir2_ino4_t;
428:
429: typedef union {
430: xfs_dir2_ino8_t i8;
431: xfs_dir2_ino4_t i4;
432: } xfs_dir2_inou_t;
433:
434: /*
435: * Normalized offset (in a data block) of the entry, really xfs_dir2_data_off_t.
436: * Only need 16 bits, this is the byte offset into the single block form.
437: */
438: typedef struct { __uint8_t i[2]; } xfs_dir2_sf_off_t;
439:
440: /*
441: * The parent directory has a dedicated field, and the self-pointer must
442: * be calculated on the fly.
443: *
444: * Entries are packed toward the top as tightly as possible. The header
445: * and the elements must be bcopy()'d out into a work area to get correct
446: * alignment for the inode number fields.
447: */
448: typedef struct xfs_dir2_sf_hdr {
449: __uint8_t count; /* count of entries */
450: __uint8_t i8count; /* count of 8-byte inode #s */
451: xfs_dir2_inou_t parent; /* parent dir inode number */
452: } xfs_dir2_sf_hdr_t;
453:
454: typedef struct xfs_dir2_sf_entry {
455: __uint8_t namelen; /* actual name length */
456: xfs_dir2_sf_off_t offset; /* saved offset */
457: __uint8_t name[1]; /* name, variable size */
458: xfs_dir2_inou_t inumber; /* inode number, var. offset */
459: } xfs_dir2_sf_entry_t;
460:
461: typedef struct xfs_dir2_sf {
462: xfs_dir2_sf_hdr_t hdr; /* shortform header */
463: xfs_dir2_sf_entry_t list[1]; /* shortform entries */
464: } xfs_dir2_sf_t;
465:
466: /* those are from xfs_dinode.h */
467:
468: #define XFS_DINODE_VERSION_1 1
469: #define XFS_DINODE_VERSION_2 2
470: #define XFS_DINODE_MAGIC 0x494e /* 'IN' */
471:
472: /*
473: * Disk inode structure.
474: * This is just the header; the inode is expanded to fill a variable size
475: * with the last field expanding. It is split into the core and "other"
476: * because we only need the core part in the in-core inode.
477: */
478: typedef struct xfs_timestamp {
479: __int32_t t_sec; /* timestamp seconds */
480: __int32_t t_nsec; /* timestamp nanoseconds */
481: } xfs_timestamp_t;
482:
483: /*
484: * Note: Coordinate changes to this structure with the XFS_DI_* #defines
485: * below and the offsets table in xfs_ialloc_log_di().
486: */
487: typedef struct xfs_dinode_core
488: {
489: __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
490: __uint16_t di_mode; /* mode and type of file */
491: __int8_t di_version; /* inode version */
492: __int8_t di_format; /* format of di_c data */
493: __uint16_t di_onlink; /* old number of links to file */
494: __uint32_t di_uid; /* owner's user id */
495: __uint32_t di_gid; /* owner's group id */
496: __uint32_t di_nlink; /* number of links to file */
497: __uint16_t di_projid; /* owner's project id */
498: __uint8_t di_pad[10]; /* unused, zeroed space */
499: xfs_timestamp_t di_atime; /* time last accessed */
500: xfs_timestamp_t di_mtime; /* time last modified */
501: xfs_timestamp_t di_ctime; /* time created/inode modified */
502: xfs_fsize_t di_size; /* number of bytes in file */
503: xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */
504: xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
505: xfs_extnum_t di_nextents; /* number of extents in data fork */
506: xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/
507: __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
508: __int8_t di_aformat; /* format of attr fork's data */
509: __uint32_t di_dmevmask; /* DMIG event mask */
510: __uint16_t di_dmstate; /* DMIG state info */
511: __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
512: __uint32_t di_gen; /* generation number */
513: } xfs_dinode_core_t;
514:
515: typedef struct xfs_dinode
516: {
517: xfs_dinode_core_t di_core;
518: xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */
519: union {
520: xfs_bmdr_block_t di_bmbt; /* btree root block */
521: xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */
522: xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
523: char di_c[1]; /* local contents */
524: } di_u;
525: } xfs_dinode_t;
526:
527: /*
528: * Values for di_format
529: */
530: typedef enum xfs_dinode_fmt
531: {
532: XFS_DINODE_FMT_DEV, /* CHR, BLK: di_dev */
533: XFS_DINODE_FMT_LOCAL, /* DIR, REG: di_c */
534: /* LNK: di_symlink */
535: XFS_DINODE_FMT_EXTENTS, /* DIR, REG, LNK: di_bmx */
536: XFS_DINODE_FMT_BTREE, /* DIR, REG, LNK: di_bmbt */
537: XFS_DINODE_FMT_UUID /* MNT: di_uuid */
538: } xfs_dinode_fmt_t;
539:
540: /*
541: * File types (mode field)
542: */
543: #define IFMT 0170000 /* type of file */
544: #define IFDIR 0040000 /* directory */
545: #define IFREG 0100000 /* regular */
546: #define IFLNK 0120000 /* symbolic link */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.