VirtualBox

source: vbox/trunk/include/iprt/formats/xfs.h@ 94480

Last change on this file since 94480 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.4 KB
Line 
1/* $Id: xfs.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * IPRT, XFS format.
4 */
5
6/*
7 * Copyright (C) 2018-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_formats_xfs_h
28#define IPRT_INCLUDED_formats_xfs_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34#include <iprt/assertcompile.h>
35
36
37/** @defgroup grp_rt_formats_xfs XFS filesystem structures and definitions
38 * @ingroup grp_rt_formats
39 * @{
40 */
41
42/*
43 * The filesystem structures were retrieved from:
44 * http://xfs.org/docs/xfsdocs-xml-dev/XFS_Filesystem_Structure//tmp/en-US/html/index.html and
45 * https://elixir.bootlin.com/linux/v4.9/source/fs/xfs/libxfs/xfs_format.h and
46 * https://righteousit.wordpress.com/
47 */
48
49/** XFS superblock offset from the beginning of the volume, this is constant. */
50#define XFS_SB_OFFSET UINT64_C(0)
51
52/** @name Common XFS types as defined in the spec.
53 * @{ */
54/** Unsigned 64 bit absolute inode number. */
55typedef uint64_t XFSINO;
56/** Signed 64 bit file offset. */
57typedef int64_t XFSFOFF;
58/** Signed 64 bit disk address. */
59typedef int64_t XFSDADDR;
60/** Unsinged 32 bit allocation group (AG) number. */
61typedef uint32_t XFSAGNUMBER;
62/** Unsigned 32 bit AG relative block number. */
63typedef uint32_t XFSAGBLOCK;
64/** Unsigned 32 bit extent length in blocks. */
65typedef uint32_t XFSEXTLEN;
66/** Signed 32 bit number of extents in a file. */
67typedef int32_t XFSEXTNUM;
68/** Unsigned 32 bit block number for directories and extended attributes. */
69typedef uint32_t XFSDABLK;
70/** Unsigned 32 bit hash of a directory file name or extended attribute name. */
71typedef uint32_t XFSDAHASH;
72/** Unsigned 64 bit filesystem block number combining AG number and block offset into the AG. */
73typedef uint64_t XFSDFSBNO;
74/** Unsigned 64 bit raw filesystem block number. */
75typedef uint64_t XFSDRFSBNO;
76/** Unsigned 64 bit extent number in the real-time device. */
77typedef uint64_t XFSDRTBNO;
78/** Unsigned 64 bit block offset int oa file. */
79typedef uint64_t XFSDFILOFF;
80/** Unsigned 64 bit block count for a file. */
81typedef uint64_t XFSDFILBLKS;
82/** @} */
83
84/**
85 * XFS superblock.
86 */
87#pragma pack(1)
88typedef struct XFSSUPERBLOCK
89{
90 /** 0x00: Magic number to identify the superblock. */
91 uint32_t u32Magic;
92 /** 0x04: Size of smallest allocation unit in bytes. */
93 uint32_t cbBlock;
94 /** 0x04: Number of blocks available for data and metadata. */
95 XFSDRFSBNO cBlocks;
96 /** 0x0c: Number of block in the real-time device. */
97 XFSDRFSBNO cBlocksRtDev;
98 /** 0x14: Number of extents on real-time device. */
99 XFSDRTBNO cExtentsRtDev;
100 /** 0x1c: UUID of the filesystem. */
101 uint8_t abUuid[16];
102 /** 0x2c: First block of the filesystem journal. */
103 XFSDFSBNO uBlockJournal;
104 /** 0x34: Inode number of the root directory. */
105 XFSINO uInodeRoot;
106 /** Inode for the real-time extent bitmap. */
107 XFSINO uInodeBitmapRtExt;
108 /** Inode for the real-time bitmap summary. */
109 XFSINO uInodeBitmapSummary;
110 /** Extent size on the real-time device in blocks. */
111 XFSAGBLOCK cRtExtent;
112 /** Size of an AG in blocks. */
113 XFSAGBLOCK cAgBlocks;
114 /** Number of AGs in hte filesystem. */
115 XFSAGNUMBER cAg;
116 /** Number of real-time bitmap blocks. */
117 XFSEXTLEN cRtBitmapBlocks;
118 /** Number of blocks for the journal. */
119 XFSEXTLEN cJournalBlocks;
120 /** Version number (actually flag bitmaps of features). */
121 uint16_t fVersion;
122 /** Sector size of the underlying medium. */
123 uint16_t cbSector;
124 /** Size of an inode in bytes. */
125 uint16_t cbInode;
126 /** Number of inodes stored in one block. */
127 uint16_t cInodesPerBlock;
128 /** Name of the filesystem. */
129 char achFsName[12];
130 /** Block size as log2 (number of bits to shift left). */
131 uint8_t cBlockSzLog;
132 /** Sector size as log2 (number of bits to shift left). */
133 uint8_t cSectorSzLog;
134 /** Inode size as log2 (number of bits to shift left). */
135 uint8_t cInodeSzLog;
136 /** Number of inodes per block as log2. */
137 uint8_t cInodesPerBlockLog;
138 /** Number of AG blocks as log2 (number of bits to shift left). */
139 uint8_t cAgBlocksLog;
140 /** Number of extent blocks as log2. */
141 uint8_t cExtentsRtDevLog;
142 /** Flag when the filesystem is in the process of being created. */
143 uint8_t fInProgress;
144 /** Maximum percentage of the filesystem usable for inodes. */
145 uint8_t cInodeMaxPct;
146 /** Global number of inodes allocated (only mainted on the first superblock). */
147 uint64_t cInodesGlobal;
148 /** Global number of free inodes (only mainted on the first superblock). */
149 uint64_t cInodesGlobalFree;
150 /** Global count of free data blocks on the filesystem (only mainted on the first superblock). */
151 uint64_t cBlocksFree;
152 /** Global count of free extents on the real-time device (only mainted on the first superblock). */
153 uint64_t cExtentsRtFree;
154 /** Inode containing the user quotas. */
155 XFSINO uInodeQuotaUsr;
156 /** Inode containing the group/project quotas. */
157 XFSINO uInodeQuotaGrp;
158 /** Quota flags. */
159 uint16_t fQuotaFlags;
160 /** Misc flags. */
161 uint8_t fFlagsMisc;
162 /** Reserved MBZ. */
163 uint8_t uSharedVn;
164 /** Number of filesystem blocks for the inode chunk alignment. */
165 XFSEXTLEN cBlocksInodeAlignment;
166 /** Raid stripe size in blocks. */
167 uint32_t cBlocksRaidStripe;
168 /** Raid width in number of blocks. */
169 uint32_t cBlocksRaidWidth;
170 /** Multiplier for determining the allocation size for directory blocks as log2. */
171 uint8_t cDirBlockAllocLog;
172 /** Sub volume sector size as log2 if an external journal device is used. */
173 uint8_t cLogDevSubVolSectorSzLog;
174 /** Sector size of the device an external journal is stored as log2. */
175 uint16_t cLogDevSectorSzLog;
176 /** Log devices stripe size. */
177 uint32_t cLogDevRaidStripe;
178 /** Additional features which may be active. */
179 uint32_t fFeatures2;
180 /** Padding. */
181 uint32_t u32Padding0;
182 /** From here follow data only available from version 5 and later. */
183 /** Read/Write feature flags. */
184 uint32_t fFeaturesRw;
185 /** Read-only feature flags. */
186 uint32_t fFeaturesRo;
187 /** Read/Write incompatible feature flags. */
188 uint32_t fFeaturesIncompatRw;
189 /** Read/Write incompatible feature flags for the journal. */
190 uint32_t fFeaturesJrnlIncompatRw;
191 /** CRC32 checksum for the superblock. */
192 uint32_t u32Chksum;
193 /** Sparse inode alignment. */
194 uint32_t u32SparseInodeAlignment;
195 /** Project quota inode. */
196 XFSINO uInodeProjectQuota;
197 /** Log sequence number of last superblock update. */
198 uint64_t uJrnlSeqSbUpdate;
199 /** UUID used when INCOMPAT_META_UUID is used. */
200 uint8_t abUuidMeta[16];
201 /** Inode if INCOMPATMETA_RMAPBT is used. */
202 XFSINO uInodeRm;
203} XFSSUPERBLOCK;
204#pragma pack()
205AssertCompileSize(XFSSUPERBLOCK, 272);
206/** Pointer to an XFS superblock. */
207typedef XFSSUPERBLOCK *PXFSSUPERBLOCK;
208/** Pointer to a const XFS superblock. */
209typedef const XFSSUPERBLOCK *PCXFSSUPERBLOCK;
210
211/** XFS superblock magic. */
212#define XFS_SB_MAGIC RT_MAKE_U32_FROM_U8('B', 'S', 'F', 'X')
213
214/** @name XFS_SB_VERSION_F_XXX - Version/Feature flags.
215 * @{ */
216/** Retrieves the version part of the field. */
217#define XFS_SB_VERSION_GET(a_fVersion) ((a_fVersion) & 0xf)
218/** Version number for filesystem 5.3, 6.0.1 and 6.1. */
219#define XFS_SB_VERSION_1 1
220/** Version number for filesystem 6.2 - attributes. */
221#define XFS_SB_VERSION_2 2
222/** Version number for filesystem 6.2 - new inode version. */
223#define XFS_SB_VERSION_3 3
224/** Version number for filesystem 6.2+ - new bitmask version. */
225#define XFS_SB_VERSION_4 4
226/** Introduced checksums in the metadata. */
227#define XFS_SB_VERSION_5 5
228/** Extended attributes are used for at least one inode. */
229#define XFS_SB_VERSION_F_ATTR RT_BIT_32(4)
230/** At least one inode use 32-bit nlink values. */
231#define XFS_SB_VERSION_F_NLINK RT_BIT_32(5)
232/** Quotas are enabled on the filesystem. */
233#define XFS_SB_VERSION_F_QUOTA RT_BIT_32(6)
234/** Set if XFSSUPERBLOCK::cBlocksInodeAlignment is used. */
235#define XFS_SB_VERSION_F_ALIGN RT_BIT_32(7)
236/** Set if XFSSUPERBLOCK::cBlocksRaidStripe and XFSSUPERBLOCK::cBlocksRaidWidth are used. */
237#define XFS_SB_VERSION_F_DALIGN RT_BIT_32(8)
238/** Set if XFSSUPERBLOCK::uSharedVn is used. */
239#define XFS_SB_VERSION_F_SHARED RT_BIT_32(9)
240/** Version 2 journaling is used. */
241#define XFS_SB_VERSION_F_LOGV2 RT_BIT_32(10)
242/** Set if sector size is not 512 bytes. */
243#define XFS_SB_VERSION_F_SECTOR RT_BIT_32(11)
244/** Set if unwritten extents are used (always set). */
245#define XFS_SB_VERSION_F_EXTFLG RT_BIT_32(12)
246/** Version 2 directories are used (always set). */
247#define XFS_SB_VERSION_F_DIRV2 RT_BIT_32(13)
248/** Set if XFSSUPERBLOCK::fFeatures2 is used. */
249#define XFS_SB_VERSION_F_FEAT2 RT_BIT_32(14)
250/** @} */
251
252/** @name XFS_SB_QUOTA_F_XXX - Quota flags
253 * @{ */
254/** User quota accounting enabled. */
255#define XFS_SB_QUOTA_F_USR_ACCT RT_BIT(0)
256/** User quotas are enforced. */
257#define XFS_SB_QUOTA_F_USR_ENFD RT_BIT(1)
258/** User quotas have been checked and updated on disk. */
259#define XFS_SB_QUOTA_F_USR_CHKD RT_BIT(2)
260/** Project quota accounting is enabled. */
261#define XFS_SB_QUOTA_F_PROJ_ACCT RT_BIT(3)
262/** Other quotas are enforced. */
263#define XFS_SB_QUOTA_F_OTH_ENFD RT_BIT(4)
264/** Other quotas have been checked and updated on disk. */
265#define XFS_SB_QUOTA_F_OTH_CHKD RT_BIT(5)
266/** Group quota accounting enabled. */
267#define XFS_SB_QUOTA_F_GRP_ACCT RT_BIT(6)
268/** @} */
269
270/** @name XFS_SB_FEATURES2_F_XXX - Additional features
271 * @{ */
272/** Global counters are lazy and are only updated when the filesystem is cleanly unmounted. */
273#define XFS_SB_FEATURES2_F_LAZYSBCOUNT RT_BIT_32(1)
274/** Extended attributes version 2. */
275#define XFS_SB_FEATURES2_F_ATTR2 RT_BIT_32(3)
276/** Parent pointers, inodes must have an extended attribute pointing to the parent inode. */
277#define XFS_SB_FEATURES2_F_PARENT RT_BIT_32(4)
278/** @} */
279
280
281/**
282 * XFS AG free space block.
283 */
284typedef struct XFSAGF
285{
286 /** Magic number. */
287 uint32_t u32Magic;
288 /** Header version number. */
289 uint32_t uVersion;
290 /** AG number for the sector. */
291 uint32_t uSeqNo;
292 /** Length of the AG in filesystem blocks. */
293 uint32_t cLengthBlocks;
294 /** Block numbers for the roots of the free space B+trees. */
295 uint32_t auRoots[3];
296 /** Depths of the free space B+trees. */
297 uint32_t acLvls[3];
298 /** Index of the first free list block. */
299 uint32_t idxFreeListFirst;
300 /** Index of the last free list block. */
301 uint32_t idxFreeListLast;
302 /** Number of blocks in the free list. */
303 uint32_t cFreeListBlocks;
304 /** Current number of free blocks in the AG. */
305 uint32_t cFreeBlocks;
306 /** Longest number of contiguous free blocks in the AG. */
307 uint32_t cFreeBlocksLongest;
308 /** Number of blocks used for the free space B+-trees. */
309 uint32_t cBlocksBTrees;
310 /** UUID of filesystem the AG belongs to. */
311 uint8_t abUuid[16];
312 /** Number of blocks used for the reverse map. */
313 uint32_t cBlocksRevMap;
314 /** Number of blocks used for the refcount B+-tree. */
315 uint32_t cBlocksRefcountBTree;
316 /** Block number for the refcount tree root. */
317 uint32_t uRootRefcount;
318 /** Depth of the refcount B+-tree. */
319 uint32_t cLvlRefcount;
320 /** Reserved contiguous space for future extensions. */
321 uint64_t au64Rsvd[14];
322 /** Last write sequence number. */
323 uint64_t uSeqNoLastWrite;
324 /** CRC of the AGF. */
325 uint32_t uChkSum;
326 /** Padding to 64 bit alignment. */
327 uint32_t uAlignment0;
328} XFSAGF;
329/** Pointer to a AG free space block. */
330typedef XFSAGF *PXFSAGF;
331/** Poiner to a const AG free space block. */
332typedef const XFSAGF *PCXFSAGF;
333
334/** AGF magic. */
335#define XFS_AGF_MAGIC RT_MAKE_U32_FROM_U8('F', 'G', 'A', 'X')
336/** The current valid AGF version. */
337#define XFS_AGF_VERSION 1
338
339
340/**
341 * XFS AG inode information.
342 */
343typedef struct XFSAGI
344{
345 /** Magic number. */
346 uint32_t u32Magic;
347 /** Header version number. */
348 uint32_t uVersion;
349 /** AG number for the sector. */
350 uint32_t uSeqNo;
351 /** Length of the AG in filesystem blocks. */
352 uint32_t cLengthBlocks;
353 /** Count of allocated inodes. */
354 uint32_t cInodesAlloc;
355 /** Block number of the inode tree root. */
356 uint32_t uRootInode;
357 /** Depth of the inode B+-tree. */
358 uint32_t cLvlsInode;
359 /** Newest allocated inode. */
360 uint32_t uInodeNew;
361 /** Last directory inode chunk. */
362 uint32_t uInodeDir;
363 /** Hash table of unlinked but still referenced inodes. */
364 uint32_t au32HashUnlinked[64];
365 /** UUID of filesystem. */
366 uint8_t abUuid[16];
367 /** CRC of the AGI. */
368 uint32_t uChkSum;
369 /** Padding. */
370 uint32_t uAlignment0;
371 /** Last write sequence number. */
372 uint64_t uSeqNoLastWrite;
373 /** Block number of the free inode tree. */
374 uint32_t uRootFreeInode;
375 /** Depth of the free inode B+-tree. */
376 uint32_t cLvlsFreeInode;
377} XFSAGI;
378/** Pointer to a AG inode information. */
379typedef XFSAGI *PXFSAGI;
380/** Pointer to a const AG inode information. */
381typedef const XFSAGI *PCXFSAGI;
382
383/** AGI magic. */
384#define XFS_AGI_MAGIC RT_MAKE_U32_FROM_U8('I', 'G', 'A', 'X')
385/** The current valid AGI version. */
386#define XFS_AGI_VERSION 1
387
388
389/**
390 * XFS timestamp structure.
391 */
392typedef struct XFSTIMESTAMP
393{
394 /** 0x00: The second part of the timestamp since the epoch. */
395 int32_t cSecEpoch;
396 /** 0x04: Nanosecond part of the timestamp. */
397 int32_t cNanoSec;
398} XFSTIMESTAMP;
399/** Pointer to a XFS timestamp. */
400typedef XFSTIMESTAMP *PXFSTIMESTAMP;
401/** Poiner to a const CFS timestamp. */
402typedef const XFSTIMESTAMP *PCXFSTIMESTAMP;
403
404
405/**
406 * The inode core structure.
407 */
408typedef struct XFSINODECORE
409{
410 /** 0x00: Magic value. */
411 uint16_t u16Magic;
412 /** 0x02: File mode and access bits (XFS_INODE_MODE_XXX). */
413 uint16_t fMode;
414 /** 0x04: Inode version. */
415 int8_t iVersion;
416 /** 0x05: The format of the data fork. */
417 int8_t enmFormat;
418 /** 0x06: Number of links to this inode from directories for v1 inodes. */
419 uint16_t cOnLinks;
420 /** 0x08: Owners UID. */
421 uint32_t uUid;
422 /** 0x0c: Owners GID. */
423 uint32_t uGid;
424 /** 0x10: The number of links to this inode for v2 inodes. */
425 uint32_t cLinks;
426 /** 0x14: Project ID for v2 inodes (not used for v1, low 16bits). */
427 uint16_t uProjIdLow;
428 /** 0x16: Project ID for v2 inodes (not used for v1, high 16bits). */
429 uint16_t uProjIdHigh;
430 /** 0x18: Padding. */
431 uint8_t abPad0[6];
432 /** 0x1e: Flush counter. */
433 uint16_t cFlush;
434 /** 0x20: Last accessed timestamp. */
435 XFSTIMESTAMP TsLastAccessed;
436 /** 0x28: Last modified timestamp. */
437 XFSTIMESTAMP TsLastModified;
438 /** 0x30: Inode created/modified timestamp. */
439 XFSTIMESTAMP TsCreatedModified;
440 /** 0x38: Number of bytes in the file. */
441 uint64_t cbInode;
442 /** 0x40: Number of direct and B-Tree blocks used for the forks. */
443 uint64_t cBlocks;
444 /** 0x48: Minimum extent size for the inode. */
445 uint32_t cExtentBlocksMin;
446 /** 0x4c: Number of extents in the data fork. */
447 uint32_t cExtentsData;
448 /** 0x50: Number of extents in the attribute fork. */
449 uint16_t cExtentsAttr;
450 /** 0x52: Offset of the attribute fork from the start of the inode. */
451 uint8_t offAttrFork;
452 /** 0x53: Attribute fork format. */
453 int8_t enmFormatAttr;
454 /** 0x54: DMIG event mask. */
455 uint32_t fEvtMaskDmig;
456 /** 0x58: DMIG state info. */
457 uint16_t uStateDmig;
458 /** 0x5a: Inode flags. */
459 uint16_t fFlags;
460 /** 0x5c: Generation number. */
461 uint32_t cGeneration;
462 /** 0x60: AGI unlinked list pointer. */
463 uint32_t offBlockUnlinkedNext;
464 /** The following fields are for v3 inodes only. */
465 /** 0x64: The CRC of the inode. */
466 uint32_t uChkSum;
467 /** 0x68: Number of attribute changes. */
468 uint64_t cAttrChanges;
469 /** 0x70: Last flush sequence number. */
470 uint64_t uFlushSeqNo;
471 /** 0x78: Additional flags. */
472 uint64_t fFlags2;
473 /** 0x80: Basic COW extent size. */
474 uint32_t cExtentCowMin;
475 /** 0x84: Padding for future expansion. */
476 uint8_t abPad1[12];
477 /** 0x90: Inode creation timestamp. */
478 XFSTIMESTAMP TsCreation;
479 /** 0x98: The inode number. */
480 uint64_t uInode;
481 /** 0x100: Filesystem UUID the inode belongs to. */
482 uint8_t abUuid[16];
483} XFSINODECORE;
484AssertCompileSizeAlignment(XFSINODECORE, 8);
485/** Pointer to a inode core. */
486typedef XFSINODECORE *PXFSINODECORE;
487/** Pointer to a const inode core. */
488typedef const XFSINODECORE *PCXFSINODECORE;
489
490/** Inode magic. */
491#define XFS_INODE_MAGIC RT_MAKE_U16_FROM_U8('N', 'I')
492
493/** @name XFS_INODE_MODE_XXX - File mode
494 * @{ */
495/** Others can execute the file. */
496#define XFS_INODE_MODE_EXEC_OTHER RT_BIT(0)
497/** Others can write to the file. */
498#define XFS_INODE_MODE_WRITE_OTHER RT_BIT(1)
499/** Others can read the file. */
500#define XFS_INODE_MODE_READ_OTHER RT_BIT(2)
501/** Members of the same group can execute the file. */
502#define XFS_INODE_MODE_EXEC_GROUP RT_BIT(3)
503/** Members of the same group can write to the file. */
504#define XFS_INODE_MODE_WRITE_GROUP RT_BIT(4)
505/** Members of the same group can read the file. */
506#define XFS_INODE_MODE_READ_GROUP RT_BIT(5)
507/** Owner can execute the file. */
508#define XFS_INODE_MODE_EXEC_OWNER RT_BIT(6)
509/** Owner can write to the file. */
510#define XFS_INODE_MODE_WRITE_OWNER RT_BIT(7)
511/** Owner can read the file. */
512#define XFS_INODE_MODE_READ_OWNER RT_BIT(8)
513/** Sticky file mode. */
514#define XFS_INODE_MODE_STICKY RT_BIT(9)
515/** File is set GID. */
516#define XFS_INODE_MODE_SET_GROUP_ID RT_BIT(10)
517/** File is set UID. */
518#define XFS_INODE_MODE_SET_USER_ID RT_BIT(11)
519/** @} */
520
521/** @name XFS_INODE_MODE_TYPE_XXX - File type
522 * @{ */
523/** Inode represents a FIFO. */
524#define XFS_INODE_MODE_TYPE_FIFO UINT16_C(0x1000)
525/** Inode represents a character device. */
526#define XFS_INODE_MODE_TYPE_CHAR UINT16_C(0x2000)
527/** Inode represents a directory. */
528#define XFS_INODE_MODE_TYPE_DIR UINT16_C(0x4000)
529/** Inode represents a block device. */
530#define XFS_INODE_MODE_TYPE_BLOCK UINT16_C(0x6000)
531/** Inode represents a regular file. */
532#define XFS_INODE_MODE_TYPE_REGULAR UINT16_C(0x8000)
533/** Inode represents a symlink. */
534#define XFS_INODE_MODE_TYPE_SYMLINK UINT16_C(0xa000)
535/** Inode represents a socket. */
536#define XFS_INODE_MODE_TYPE_SOCKET UINT16_C(0xc000)
537/** Returns the inode type from the combined mode field. */
538#define XFS_INODE_MODE_TYPE_GET_TYPE(a_Mode) ((a_Mode) & 0xf000)
539/** @} */
540
541/** @name XFS_INODE_FORMAT_XXX - Inode data fork format.
542 * @{ */
543/** Device node data. */
544#define XFS_INODE_FORMAT_DEV 0
545/** Inline data. */
546#define XFS_INODE_FORMAT_LOCAL 1
547/** Array of extent descriptors. */
548#define XFS_INODE_FORMAT_EXTENTS 2
549/** Data fork contains root of B-Tree. */
550#define XFS_INODE_FORMAT_BTREE 3
551/** Data fork contains UUID. */
552#define XFS_INODE_FORMAT_UUID 4
553/** @} */
554
555/** @name XFS_INODE_F_XXX - Inode flags.
556 * @{ */
557/** File data blocks are stored in the real-time device area. */
558#define XFS_INODE_F_RTDEV RT_BIT(0)
559/** File space has been pre-allocated. */
560#define XFS_INODE_F_PREALLOC RT_BIT(1)
561/** Use new real-time bitmap format. */
562#define XFS_INODE_F_NEWRTBITMAP RT_BIT(2)
563/** Inode is immutable. */
564#define XFS_INODE_F_IMMUTABLE RT_BIT(3)
565/** Inode is append only. */
566#define XFS_INODE_F_APPEND RT_BIT(4)
567/** Inode is written synchronously. */
568#define XFS_INODE_F_SYNC RT_BIT(5)
569/** The last accessed timestamp is not updated. */
570#define XFS_INODE_F_NOATIME RT_BIT(6)
571/** The inode is not dumpable via dump(1). */
572#define XFS_INODE_F_NODUMP RT_BIT(7)
573/** Create with real-time bit set. */
574#define XFS_INODE_F_RTINHERIT RT_BIT(8)
575/** Create with parents project ID. */
576#define XFS_INODE_F_PROJIDINHERIT RT_BIT(9)
577/** Deny symlink creation. */
578#define XFS_INODE_F_NOSYMLINKS RT_BIT(10)
579/** Inode extent size allocator hint. */
580#define XFS_INODE_F_EXTSIZEHINT RT_BIT(11)
581/** Inode extent size is inherited. */
582#define XFS_INODE_F_EXTSIZEINHERIT RT_BIT(12)
583/** Do not defrag/reorganize the inode. */
584#define XFS_INODE_F_NODEFRAG RT_BIT(13)
585/** Use filestream allocator. */
586#define XFS_INODE_F_FILESTREAM RT_BIT(14)
587/** @} */
588
589/** @name XFS_INODE_F2_XXX - Inode flags number 2 (XFSINODECORE::fFlags2).
590 * @{ */
591/** Use DAX for the inode. */
592#define XFS_INODE_F2_DAX RT_BIT_64(0)
593/** Blocks use reference counting for sharing. */
594#define XFS_INODE_F2_REFLINK RT_BIT_64(1)
595/** Inode COW extent size hint is valid. */
596#define XFS_INODE_F2_COWEXTSIZEHINT RT_BIT_64(2)
597/** @} */
598
599
600/**
601 * Inode B-Tree record.
602 */
603typedef struct XFSINODEBTREEREC
604{
605 /** 0x00: Starting inode number. */
606 uint32_t uInodeStart;
607 /** 0x04: Version dependent data. */
608 union
609 {
610 /** Full (old) version. */
611 struct
612 {
613 /** 0x04: Number of free inodes. */
614 uint32_t cInodesFree;
615 } Full;
616 /** Sparse (new) version. */
617 struct
618 {
619 /** 0x04: Hole mask for sparse chunks. */
620 uint16_t bmHoles;
621 /** 0x06: Total number of inodes. */
622 uint8_t cInodes;
623 /** 0x07: Number of free inodes. */
624 uint8_t cInodesFree;
625 } Sparse;
626 } u;
627 /** 0x08: Free inode mask. */
628 uint64_t bmInodesFree;
629} XFSINODEBTREEREC;
630/** Pointer to an inode B-Tree record. */
631typedef XFSINODEBTREEREC *PXFSINODEBTREEREC;
632/** Pointer to a const inode B-Tree record. */
633typedef const XFSINODEBTREEREC *PCXFSINODEBTREEREC;
634
635
636/**
637 * XFS B+Tree root header.
638 */
639typedef struct XFSBTREEROOTHDR
640{
641 /** 0x00: Tree level. */
642 uint16_t iLvl;
643 /** 0x02: Number of records. */
644 uint16_t cRecs;
645} XFSBTREEROOTHDR;
646/** Pointer to a B+Tree root header */
647typedef XFSBTREEROOTHDR *PXFSBTREEROOTHDR;
648/** Pointer to a const B+Tree root header. */
649typedef const XFSBTREEROOTHDR *PCXFSBTREEROOTHDR;
650
651
652/**
653 * XFS B+Tree intermediate/leave node header.
654 */
655typedef struct XFSBTREENODEHDR
656{
657 /** 0x00: Magic identifying the node. */
658 uint32_t u32Magic;
659 /** 0x04: Tree level. */
660 uint16_t iLvl;
661 /** 0x06: Number of records. */
662 uint16_t cRecs;
663 /** 0x08: Block number of the left sibling. */
664 uint64_t uSibLeft;
665 /** 0x10: Block number of the right sibling. */
666 uint64_t uSibRight;
667} XFSBTREENODEHDR;
668/** Pointer to a B+Tree intermediate/leave node header. */
669typedef XFSBTREENODEHDR *PXFSBTREENODEHDR;
670/** Pointer to a const B+Tree intermediate/leave node header. */
671typedef const XFSBTREENODEHDR *PCXFSBTREENODEHDR;
672
673/** @name XFS_BTREENODEHDR_XXX - B+Tree node related defines.
674 * @{ */
675/** Magic for the tree node header. */
676#define XFS_BTREENODEHDR_MAGIC RT_MAKE_U32_FROM_U8('P', 'A', 'M', 'B')
677/** @} */
678
679
680/**
681 * XFS Extent.
682 */
683typedef struct XFSEXTENT
684{
685 /** 0x00: Low 64 bits. */
686 uint64_t u64Low;
687 /** 0x08: High 64 bits. */
688 uint64_t u64High;
689} XFSEXTENT;
690/** Pointer to an XFS extent. */
691typedef XFSEXTENT *PXFSEXTENT;
692/** Pointer to a const XFS extent. */
693typedef const XFSEXTENT *PCXFSEXTENT;
694
695/** @name XFS_EXTENT_XXX - Extent related getters.
696 * @{ */
697/** Returns whether the extent is allocated but unwritten (true) or a normal extent (false). */
698#define XFS_EXTENT_IS_UNWRITTEN(a_pExtent) (RT_BOOL((a_pExtent)->u64High & RT_BIT_64(63)))
699/** Returns the number of blocks the extent covers. */
700#define XFS_EXTENT_GET_BLOCK_COUNT(a_pExtent) ((a_pExtent)->u64Low & UINT64_C(0x1fffff))
701/** Returns the absolute block number where the data is stored on the disk. */
702#define XFS_EXTENT_GET_DISK_BLOCK(a_pExtent) ( (((a_pExtent)->u64High & UINT64_C(0x1ff)) << 42) \
703 | (((a_pExtent)->u64Low & UINT64_C(0xffffffffffe00000)) >> 21))
704/** Returns the logical inode block offset. */
705#define XFS_EXTENT_GET_LOGICAL_BLOCK(a_pExtent) (((a_pExtent)->u64High & UINT64_C(0x7ffffffffffffe00)) >> 9)
706/** @} */
707
708/** @} */
709
710#endif /* !IPRT_INCLUDED_formats_xfs_h */
711
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette