The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/hfs/hfs_format.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 #ifndef __HFS_FORMAT__
   26 #define __HFS_FORMAT__
   27 
   28 #ifndef __HFSVOLUMES__
   29 
   30 #include <sys/types.h>
   31 #include <sys/appleapiopts.h>
   32 
   33 /*
   34  * hfs_format.c
   35  *
   36  * This file describes the on-disk format for HFS and HFS Plus volumes.
   37  * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
   38  *
   39  * http://developer.apple.com/technotes/tn/tn1150.html
   40  *
   41  */
   42 
   43 #ifdef __cplusplus
   44 extern "C" {
   45 #endif
   46 
   47 /* some on-disk hfs structures have 68K alignment (misaligned) */
   48 #pragma options align=mac68k
   49 
   50 /* Signatures used to differentiate between HFS and HFS Plus volumes */
   51 enum {
   52         kHFSSigWord             = 0x4244,       /* 'BD' in ASCII */
   53         kHFSPlusSigWord         = 0x482B,       /* 'H+' in ASCII */
   54         kHFSXSigWord            = 0x4858,       /* 'HX' in ASCII */
   55 
   56         kHFSPlusVersion         = 0x0004,       /* 'H+' volumes are version 4 only */
   57         kHFSXVersion            = 0x0005,       /* 'HX' volumes start with version 5 */
   58 
   59         kHFSPlusMountVersion    = 0x31302E30,   /* '10.0' for Mac OS X */
   60         kHFSJMountVersion       = 0x4846534a    /* 'HFSJ' for journaled HFS+ on OS X */
   61 };
   62 
   63 
   64 #ifdef __APPLE_API_PRIVATE
   65 /*
   66  * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
   67  * This directory and its contents are never exported from the filesystem under
   68  * Mac OS X.
   69  *
   70  * To make this folder name sort last,  it has embedded null prefix.
   71  * (0xC0, 0x80 in UTF-8)
   72  */
   73 #define HFSPLUSMETADATAFOLDER  "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
   74 
   75 /*
   76  * Files in the HFS Private Data folder have one of the following prefixes
   77  * followed by a decimal number (no leading zeros).  For indirect nodes this
   78  * number is a 32 bit random number.  For unlinked (deleted) files that are
   79  * still open, the number is the file ID for that file.
   80  *
   81  * e.g.  iNode7182000 and temp3296
   82  */
   83 #define HFS_INODE_PREFIX        "iNode"
   84 #define HFS_DELETE_PREFIX       "temp"
   85 
   86 #endif /* __APPLE_API_PRIVATE */
   87 
   88 /*
   89  * Indirect link files (hard links) have the following type/creator.
   90  */
   91 enum {
   92         kHardLinkFileType = 0x686C6E6B,  /* 'hlnk' */
   93         kHFSPlusCreator   = 0x6866732B   /* 'hfs+' */
   94 };
   95 
   96 
   97 #ifndef __FILES__
   98 /* Unicode strings are used for HFS Plus file and folder names */
   99 struct HFSUniStr255 {
  100         u_int16_t       length;         /* number of unicode characters */
  101         u_int16_t       unicode[255];   /* unicode characters */
  102 };
  103 typedef struct HFSUniStr255 HFSUniStr255;
  104 typedef const HFSUniStr255 *ConstHFSUniStr255Param;
  105 #endif /* __FILES__ */
  106 
  107 enum {
  108         kHFSMaxVolumeNameChars          = 27,
  109         kHFSMaxFileNameChars            = 31,
  110         kHFSPlusMaxFileNameChars        = 255
  111 };
  112 
  113 
  114 /* Extent overflow file data structures */
  115 
  116 /* HFS Extent key */
  117 struct HFSExtentKey {
  118         u_int8_t        keyLength;      /* length of key, excluding this field */
  119         u_int8_t        forkType;       /* 0 = data fork, FF = resource fork */
  120         u_int32_t       fileID;         /* file ID */
  121         u_int16_t       startBlock;     /* first file allocation block number in this extent */
  122 };
  123 typedef struct HFSExtentKey HFSExtentKey;
  124 
  125 /* HFS Plus Extent key */
  126 struct HFSPlusExtentKey {
  127         u_int16_t       keyLength;              /* length of key, excluding this field */
  128         u_int8_t        forkType;               /* 0 = data fork, FF = resource fork */
  129         u_int8_t        pad;                    /* make the other fields align on 32-bit boundary */
  130         u_int32_t       fileID;                 /* file ID */
  131         u_int32_t       startBlock;             /* first file allocation block number in this extent */
  132 };
  133 typedef struct HFSPlusExtentKey HFSPlusExtentKey;
  134 
  135 /* Number of extent descriptors per extent record */
  136 enum {
  137         kHFSExtentDensity       = 3,
  138         kHFSPlusExtentDensity   = 8
  139 };
  140 
  141 /* HFS extent descriptor */
  142 struct HFSExtentDescriptor {
  143         u_int16_t       startBlock;             /* first allocation block */
  144         u_int16_t       blockCount;             /* number of allocation blocks */
  145 };
  146 typedef struct HFSExtentDescriptor HFSExtentDescriptor;
  147 
  148 /* HFS Plus extent descriptor */
  149 struct HFSPlusExtentDescriptor {
  150         u_int32_t       startBlock;             /* first allocation block */
  151         u_int32_t       blockCount;             /* number of allocation blocks */
  152 };
  153 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
  154 
  155 /* HFS extent record */
  156 typedef HFSExtentDescriptor HFSExtentRecord[3];
  157 
  158 /* HFS Plus extent record */
  159 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
  160 
  161 
  162 /* Finder information */
  163 struct FndrFileInfo {
  164         u_int32_t       fdType;         /* file type */
  165         u_int32_t       fdCreator;      /* file creator */
  166         u_int16_t       fdFlags;        /* Finder flags */
  167         struct {
  168             int16_t     v;              /* file's location */
  169             int16_t     h;
  170         } fdLocation;
  171         int16_t         opaque;
  172 };
  173 typedef struct FndrFileInfo FndrFileInfo;
  174 
  175 struct FndrDirInfo {
  176         struct {                        /* folder's window rectangle */
  177             int16_t     top;
  178             int16_t     left;
  179             int16_t     bottom;
  180             int16_t     right;
  181         } frRect;
  182         unsigned short  frFlags;        /* Finder flags */
  183         struct {
  184             u_int16_t   v;              /* folder's location */
  185             u_int16_t   h;
  186         } frLocation;
  187         int16_t         opaque;
  188 };
  189 typedef struct FndrDirInfo FndrDirInfo;
  190 
  191 struct FndrOpaqueInfo {
  192         int8_t opaque[16];
  193 };
  194 typedef struct FndrOpaqueInfo FndrOpaqueInfo;
  195 
  196 
  197 /* HFS Plus Fork data info - 80 bytes */
  198 struct HFSPlusForkData {
  199         u_int64_t               logicalSize;    /* fork's logical size in bytes */
  200         u_int32_t               clumpSize;      /* fork's clump size in bytes */
  201         u_int32_t               totalBlocks;    /* total blocks used by this fork */
  202         HFSPlusExtentRecord     extents;        /* initial set of extents */
  203 };
  204 typedef struct HFSPlusForkData HFSPlusForkData;
  205 
  206 
  207 /* Mac OS X has 16 bytes worth of "BSD" info.
  208  *
  209  * Note:  Mac OS 9 implementations and applications
  210  * should preserve, but not change, this information.
  211  */
  212 struct HFSPlusBSDInfo {
  213         u_int32_t       ownerID;        /* user or group ID of file/folder owner */
  214         u_int32_t       groupID;        /* additional user of group ID */
  215         u_int8_t        adminFlags;     /* super-user changeable flags */
  216         u_int8_t        ownerFlags;     /* owner changeable flags */
  217         u_int16_t       fileMode;       /* file type and permission bits */
  218         union {
  219             u_int32_t   iNodeNum;       /* indirect node number (hard links only) */
  220             u_int32_t   linkCount;      /* links that refer to this indirect node */
  221             u_int32_t   rawDevice;      /* special file device (FBLK and FCHR only) */
  222         } special;
  223 };
  224 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
  225 
  226 
  227 /* Catalog file data structures */
  228 
  229 enum {
  230         kHFSRootParentID                = 1,    /* Parent ID of the root folder */
  231         kHFSRootFolderID                = 2,    /* Folder ID of the root folder */
  232         kHFSExtentsFileID               = 3,    /* File ID of the extents file */
  233         kHFSCatalogFileID               = 4,    /* File ID of the catalog file */
  234         kHFSBadBlockFileID              = 5,    /* File ID of the bad allocation block file */
  235         kHFSAllocationFileID            = 6,    /* File ID of the allocation file (HFS Plus only) */
  236         kHFSStartupFileID               = 7,    /* File ID of the startup file (HFS Plus only) */
  237         kHFSAttributesFileID            = 8,    /* File ID of the attribute file (HFS Plus only) */
  238         kHFSRepairCatalogFileID         = 14,   /* Used when rebuilding Catalog B-tree */
  239         kHFSBogusExtentFileID           = 15,   /* Used for exchanging extents in extents file */
  240         kHFSFirstUserCatalogNodeID      = 16
  241 };
  242 
  243 /* HFS catalog key */
  244 struct HFSCatalogKey {
  245         u_int8_t        keyLength;              /* key length (in bytes) */
  246         u_int8_t        reserved;               /* reserved (set to zero) */
  247         u_int32_t       parentID;               /* parent folder ID */
  248         u_char          nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
  249 };
  250 typedef struct HFSCatalogKey HFSCatalogKey;
  251 
  252 /* HFS Plus catalog key */
  253 struct HFSPlusCatalogKey {
  254         u_int16_t               keyLength;      /* key length (in bytes) */
  255         u_int32_t               parentID;       /* parent folder ID */
  256         HFSUniStr255            nodeName;       /* catalog node name */
  257 };
  258 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
  259 
  260 /* Catalog record types */
  261 enum {
  262         /* HFS Catalog Records */
  263         kHFSFolderRecord                = 0x0100,       /* Folder record */
  264         kHFSFileRecord                  = 0x0200,       /* File record */
  265         kHFSFolderThreadRecord          = 0x0300,       /* Folder thread record */
  266         kHFSFileThreadRecord            = 0x0400,       /* File thread record */
  267 
  268         /* HFS Plus Catalog Records */
  269         kHFSPlusFolderRecord            = 1,            /* Folder record */
  270         kHFSPlusFileRecord              = 2,            /* File record */
  271         kHFSPlusFolderThreadRecord      = 3,            /* Folder thread record */
  272         kHFSPlusFileThreadRecord        = 4             /* File thread record */
  273 };
  274 
  275 
  276 /* Catalog file record flags */
  277 enum {
  278         kHFSFileLockedBit       = 0x0000,       /* file is locked and cannot be written to */
  279         kHFSFileLockedMask      = 0x0001,
  280         kHFSThreadExistsBit     = 0x0001,       /* a file thread record exists for this file */
  281         kHFSThreadExistsMask    = 0x0002
  282 };
  283 
  284 
  285 /* HFS catalog folder record - 70 bytes */
  286 struct HFSCatalogFolder {
  287         int16_t                 recordType;             /* == kHFSFolderRecord */
  288         u_int16_t               flags;                  /* folder flags */
  289         u_int16_t               valence;                /* folder valence */
  290         u_int32_t               folderID;               /* folder ID */
  291         u_int32_t               createDate;             /* date and time of creation */
  292         u_int32_t               modifyDate;             /* date and time of last modification */
  293         u_int32_t               backupDate;             /* date and time of last backup */
  294         FndrDirInfo             userInfo;               /* Finder information */
  295         FndrOpaqueInfo          finderInfo;             /* additional Finder information */
  296         u_int32_t               reserved[4];            /* reserved - initialized as zero */
  297 };
  298 typedef struct HFSCatalogFolder HFSCatalogFolder;
  299 
  300 /* HFS Plus catalog folder record - 88 bytes */
  301 struct HFSPlusCatalogFolder {
  302         int16_t                 recordType;             /* == kHFSPlusFolderRecord */
  303         u_int16_t               flags;                  /* file flags */
  304         u_int32_t               valence;                /* folder's valence (limited to 2^16 in Mac OS) */
  305         u_int32_t               folderID;               /* folder ID */
  306         u_int32_t               createDate;             /* date and time of creation */
  307         u_int32_t               contentModDate;         /* date and time of last content modification */
  308         u_int32_t               attributeModDate;       /* date and time of last attribute modification */
  309         u_int32_t               accessDate;             /* date and time of last access (MacOS X only) */
  310         u_int32_t               backupDate;             /* date and time of last backup */
  311         HFSPlusBSDInfo          bsdInfo;                /* permissions (for MacOS X) */
  312         FndrDirInfo             userInfo;               /* Finder information */
  313         FndrOpaqueInfo          finderInfo;             /* additional Finder information */
  314         u_int32_t               textEncoding;           /* hint for name conversions */
  315         u_int32_t               reserved;               /* reserved - initialized as zero */
  316 };
  317 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
  318 
  319 /* HFS catalog file record - 102 bytes */
  320 struct HFSCatalogFile {
  321         int16_t                 recordType;             /* == kHFSFileRecord */
  322         u_int8_t                flags;                  /* file flags */
  323         int8_t                  fileType;               /* file type (unused ?) */
  324         FndrFileInfo            userInfo;               /* Finder information */
  325         u_int32_t               fileID;                 /* file ID */
  326         u_int16_t               dataStartBlock;         /* not used - set to zero */
  327         int32_t                 dataLogicalSize;        /* logical EOF of data fork */
  328         int32_t                 dataPhysicalSize;       /* physical EOF of data fork */
  329         u_int16_t               rsrcStartBlock;         /* not used - set to zero */
  330         int32_t                 rsrcLogicalSize;        /* logical EOF of resource fork */
  331         int32_t                 rsrcPhysicalSize;       /* physical EOF of resource fork */
  332         u_int32_t               createDate;             /* date and time of creation */
  333         u_int32_t               modifyDate;             /* date and time of last modification */
  334         u_int32_t               backupDate;             /* date and time of last backup */
  335         FndrOpaqueInfo          finderInfo;             /* additional Finder information */
  336         u_int16_t               clumpSize;              /* file clump size (not used) */
  337         HFSExtentRecord         dataExtents;            /* first data fork extent record */
  338         HFSExtentRecord         rsrcExtents;            /* first resource fork extent record */
  339         u_int32_t               reserved;               /* reserved - initialized as zero */
  340 };
  341 typedef struct HFSCatalogFile HFSCatalogFile;
  342 
  343 /* HFS Plus catalog file record - 248 bytes */
  344 struct HFSPlusCatalogFile {
  345         int16_t                 recordType;             /* == kHFSPlusFileRecord */
  346         u_int16_t               flags;                  /* file flags */
  347         u_int32_t               reserved1;              /* reserved - initialized as zero */
  348         u_int32_t               fileID;                 /* file ID */
  349         u_int32_t               createDate;             /* date and time of creation */
  350         u_int32_t               contentModDate;         /* date and time of last content modification */
  351         u_int32_t               attributeModDate;       /* date and time of last attribute modification */
  352         u_int32_t               accessDate;             /* date and time of last access (MacOS X only) */
  353         u_int32_t               backupDate;             /* date and time of last backup */
  354         HFSPlusBSDInfo          bsdInfo;                /* permissions (for MacOS X) */
  355         FndrFileInfo            userInfo;               /* Finder information */
  356         FndrOpaqueInfo          finderInfo;             /* additional Finder information */
  357         u_int32_t               textEncoding;           /* hint for name conversions */
  358         u_int32_t               reserved2;              /* reserved - initialized as zero */
  359 
  360         /* Note: these start on double long (64 bit) boundry */
  361         HFSPlusForkData         dataFork;               /* size and block data for data fork */
  362         HFSPlusForkData         resourceFork;           /* size and block data for resource fork */
  363 };
  364 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
  365 
  366 /* HFS catalog thread record - 46 bytes */
  367 struct HFSCatalogThread {
  368         int16_t         recordType;             /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
  369         int32_t         reserved[2];            /* reserved - initialized as zero */
  370         u_int32_t       parentID;               /* parent ID for this catalog node */
  371         u_char          nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
  372 };
  373 typedef struct HFSCatalogThread HFSCatalogThread;
  374 
  375 /* HFS Plus catalog thread record -- 264 bytes */
  376 struct HFSPlusCatalogThread {
  377         int16_t         recordType;             /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
  378         int16_t         reserved;               /* reserved - initialized as zero */
  379         u_int32_t       parentID;               /* parent ID for this catalog node */
  380         HFSUniStr255    nodeName;               /* name of this catalog node (variable length) */
  381 };
  382 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
  383 
  384 #ifdef __APPLE_API_UNSTABLE
  385 /*
  386         These are the types of records in the attribute B-tree.  The values were
  387         chosen so that they wouldn't conflict with the catalog record types.
  388 */
  389 enum {
  390         kHFSPlusAttrInlineData  = 0x10,         /* if size <  kAttrOverflowSize */
  391         kHFSPlusAttrForkData    = 0x20,         /* if size >= kAttrOverflowSize */
  392         kHFSPlusAttrExtents     = 0x30          /* overflow extents for large attributes */
  393 };
  394 
  395 
  396 /*
  397         HFSPlusAttrInlineData
  398         For small attributes, whose entire value is stored within this one
  399         B-tree record.
  400         There would not be any other records for this attribute.
  401 */
  402 struct HFSPlusAttrInlineData {
  403         u_int32_t       recordType;             /* == kHFSPlusAttrInlineData*/
  404         u_int32_t       reserved;
  405         u_int32_t       logicalSize;            /* size in bytes of userData*/
  406         u_int8_t        userData[2];            /* variable length; space allocated is a multiple of 2 bytes*/
  407 };
  408 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
  409 
  410 
  411 /*
  412         HFSPlusAttrForkData
  413         For larger attributes, whose value is stored in allocation blocks.
  414         If the attribute has more than 8 extents, there will be additonal
  415         records (of type HFSPlusAttrExtents) for this attribute.
  416 */
  417 struct HFSPlusAttrForkData {
  418         u_int32_t       recordType;             /* == kHFSPlusAttrForkData*/
  419         u_int32_t       reserved;
  420         HFSPlusForkData theFork;                /* size and first extents of value*/
  421 };
  422 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
  423 
  424 /*
  425         HFSPlusAttrExtents
  426         This record contains information about overflow extents for large,
  427         fragmented attributes.
  428 */
  429 struct HFSPlusAttrExtents {
  430         u_int32_t               recordType;     /* == kHFSPlusAttrExtents*/
  431         u_int32_t               reserved;
  432         HFSPlusExtentRecord     extents;        /* additional extents*/
  433 };
  434 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
  435 
  436 /*      A generic Attribute Record*/
  437 union HFSPlusAttrRecord {
  438         u_int32_t               recordType;
  439         HFSPlusAttrInlineData   inlineData;
  440         HFSPlusAttrForkData     forkData;
  441         HFSPlusAttrExtents      overflowExtents;
  442 };
  443 typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
  444 
  445 /* Key and node lengths */
  446 enum {
  447         kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
  448         kHFSExtentKeyMaximumLength      = sizeof(HFSExtentKey) - sizeof(u_int8_t),
  449         kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
  450         kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
  451         kHFSCatalogKeyMaximumLength     = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
  452         kHFSCatalogKeyMinimumLength     = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
  453         kHFSPlusCatalogMinNodeSize      = 4096,
  454         kHFSPlusExtentMinNodeSize       = 512,
  455         kHFSPlusAttrMinNodeSize         = 4096
  456 };
  457 #endif /* __APPLE_API_UNSTABLE */
  458 
  459 /* HFS and HFS Plus volume attribute bits */
  460 enum {
  461                                                         /* Bits 0-6 are reserved (always cleared by MountVol call) */
  462         kHFSVolumeHardwareLockBit       = 7,            /* volume is locked by hardware */
  463         kHFSVolumeUnmountedBit          = 8,            /* volume was successfully unmounted */
  464         kHFSVolumeSparedBlocksBit       = 9,            /* volume has bad blocks spared */
  465         kHFSVolumeNoCacheRequiredBit = 10,              /* don't cache volume blocks (i.e. RAM or ROM disk) */
  466         kHFSBootVolumeInconsistentBit = 11,             /* boot volume is inconsistent (System 7.6 and later) */
  467         kHFSCatalogNodeIDsReusedBit = 12,
  468         kHFSVolumeJournaledBit = 13,                    /* this volume has a journal on it */
  469         kHFSVolumeInconsistentBit = 14,                 /* serious inconsistencies detected at runtime */
  470         kHFSVolumeSoftwareLockBit       = 15,           /* volume is locked by software */
  471 
  472         kHFSVolumeHardwareLockMask      = 1 << kHFSVolumeHardwareLockBit,
  473         kHFSVolumeUnmountedMask         = 1 << kHFSVolumeUnmountedBit,
  474         kHFSVolumeSparedBlocksMask      = 1 << kHFSVolumeSparedBlocksBit,
  475         kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
  476         kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
  477         kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit,
  478         kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit,
  479         kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit,
  480         kHFSVolumeSoftwareLockMask      = 1 << kHFSVolumeSoftwareLockBit,
  481         kHFSMDBAttributesMask           = 0x8380
  482 };
  483 
  484 
  485 /* HFS Master Directory Block - 162 bytes */
  486 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
  487 struct HFSMasterDirectoryBlock {
  488         u_int16_t               drSigWord;      /* == kHFSSigWord */
  489         u_int32_t               drCrDate;       /* date and time of volume creation */
  490         u_int32_t               drLsMod;        /* date and time of last modification */
  491         u_int16_t               drAtrb;         /* volume attributes */
  492         u_int16_t               drNmFls;        /* number of files in root folder */
  493         u_int16_t               drVBMSt;        /* first block of volume bitmap */
  494         u_int16_t               drAllocPtr;     /* start of next allocation search */
  495         u_int16_t               drNmAlBlks;     /* number of allocation blocks in volume */
  496         u_int32_t               drAlBlkSiz;     /* size (in bytes) of allocation blocks */
  497         u_int32_t               drClpSiz;       /* default clump size */
  498         u_int16_t               drAlBlSt;       /* first allocation block in volume */
  499         u_int32_t               drNxtCNID;      /* next unused catalog node ID */
  500         u_int16_t               drFreeBks;      /* number of unused allocation blocks */
  501         u_char                  drVN[kHFSMaxVolumeNameChars + 1];  /* volume name */
  502         u_int32_t               drVolBkUp;      /* date and time of last backup */
  503         u_int16_t               drVSeqNum;      /* volume backup sequence number */
  504         u_int32_t               drWrCnt;        /* volume write count */
  505         u_int32_t               drXTClpSiz;     /* clump size for extents overflow file */
  506         u_int32_t               drCTClpSiz;     /* clump size for catalog file */
  507         u_int16_t               drNmRtDirs;     /* number of directories in root folder */
  508         u_int32_t               drFilCnt;       /* number of files in volume */
  509         u_int32_t               drDirCnt;       /* number of directories in volume */
  510         u_int32_t               drFndrInfo[8];  /* information used by the Finder */
  511         u_int16_t               drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
  512         HFSExtentDescriptor     drEmbedExtent;  /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
  513         u_int32_t               drXTFlSize;     /* size of extents overflow file */
  514         HFSExtentRecord         drXTExtRec;     /* extent record for extents overflow file */
  515         u_int32_t               drCTFlSize;     /* size of catalog file */
  516         HFSExtentRecord         drCTExtRec;     /* extent record for catalog file */
  517 };
  518 typedef struct HFSMasterDirectoryBlock  HFSMasterDirectoryBlock;
  519 
  520 
  521 #ifdef __APPLE_API_UNSTABLE
  522 #define SET_HFS_TEXT_ENCODING(hint)  \
  523         (0x656e6300 | ((hint) & 0xff))
  524 #define GET_HFS_TEXT_ENCODING(hint)  \
  525         (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
  526 #endif /* __APPLE_API_UNSTABLE */
  527 
  528 
  529 /* HFS Plus Volume Header - 512 bytes */
  530 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
  531 struct HFSPlusVolumeHeader {
  532         u_int16_t       signature;              /* == kHFSPlusSigWord */
  533         u_int16_t       version;                /* == kHFSPlusVersion */
  534         u_int32_t       attributes;             /* volume attributes */
  535         u_int32_t       lastMountedVersion;     /* implementation version which last mounted volume */
  536         u_int32_t       journalInfoBlock;       /* block addr of journal info (if volume is journaled, zero otherwise) */
  537 
  538         u_int32_t       createDate;             /* date and time of volume creation */
  539         u_int32_t       modifyDate;             /* date and time of last modification */
  540         u_int32_t       backupDate;             /* date and time of last backup */
  541         u_int32_t       checkedDate;            /* date and time of last disk check */
  542 
  543         u_int32_t       fileCount;              /* number of files in volume */
  544         u_int32_t       folderCount;            /* number of directories in volume */
  545 
  546         u_int32_t       blockSize;              /* size (in bytes) of allocation blocks */
  547         u_int32_t       totalBlocks;            /* number of allocation blocks in volume (includes this header and VBM*/
  548         u_int32_t       freeBlocks;             /* number of unused allocation blocks */
  549 
  550         u_int32_t       nextAllocation;         /* start of next allocation search */
  551         u_int32_t       rsrcClumpSize;          /* default resource fork clump size */
  552         u_int32_t       dataClumpSize;          /* default data fork clump size */
  553         u_int32_t       nextCatalogID;          /* next unused catalog node ID */
  554 
  555         u_int32_t       writeCount;             /* volume write count */
  556         u_int64_t       encodingsBitmap;        /* which encodings have been use  on this volume */
  557 
  558         u_int8_t        finderInfo[32];         /* information used by the Finder */
  559 
  560         HFSPlusForkData  allocationFile;        /* allocation bitmap file */
  561         HFSPlusForkData  extentsFile;           /* extents B-tree file */
  562         HFSPlusForkData  catalogFile;           /* catalog B-tree file */
  563         HFSPlusForkData  attributesFile;        /* extended attributes B-tree file */
  564         HFSPlusForkData  startupFile;           /* boot file (secondary loader) */
  565 };
  566 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
  567 
  568 
  569 /* B-tree structures */
  570 
  571 enum BTreeKeyLimits{
  572         kMaxKeyLength   = 520
  573 };
  574 
  575 union BTreeKey{
  576         u_int8_t        length8;
  577         u_int16_t       length16;
  578         u_int8_t        rawData [kMaxKeyLength+2];
  579 };
  580 typedef union BTreeKey BTreeKey;
  581 
  582 /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
  583 struct BTNodeDescriptor {
  584         u_int32_t       fLink;                  /* next node at this level*/
  585         u_int32_t       bLink;                  /* previous node at this level*/
  586         int8_t          kind;                   /* kind of node (leaf, index, header, map)*/
  587         u_int8_t        height;                 /* zero for header, map; child is one more than parent*/
  588         u_int16_t       numRecords;             /* number of records in this node*/
  589         u_int16_t       reserved;               /* reserved - initialized as zero */
  590 };
  591 typedef struct BTNodeDescriptor BTNodeDescriptor;
  592 
  593 /* Constants for BTNodeDescriptor kind */
  594 enum {
  595         kBTLeafNode     = -1,
  596         kBTIndexNode    = 0,
  597         kBTHeaderNode   = 1,
  598         kBTMapNode      = 2
  599 };
  600 
  601 /* BTHeaderRec -- The first record of a B-tree header node */
  602 struct BTHeaderRec {
  603         u_int16_t       treeDepth;              /* maximum height (usually leaf nodes) */
  604         u_int32_t       rootNode;               /* node number of root node */
  605         u_int32_t       leafRecords;            /* number of leaf records in all leaf nodes */
  606         u_int32_t       firstLeafNode;          /* node number of first leaf node */
  607         u_int32_t       lastLeafNode;           /* node number of last leaf node */
  608         u_int16_t       nodeSize;               /* size of a node, in bytes */
  609         u_int16_t       maxKeyLength;           /* reserved */
  610         u_int32_t       totalNodes;             /* total number of nodes in tree */
  611         u_int32_t       freeNodes;              /* number of unused (free) nodes in tree */
  612         u_int16_t       reserved1;              /* unused */
  613         u_int32_t       clumpSize;              /* reserved */
  614         u_int8_t        btreeType;              /* reserved */
  615         u_int8_t        keyCompareType;         /* Key string Comparison Type */
  616         u_int32_t       attributes;             /* persistent attributes about the tree */
  617         u_int32_t       reserved3[16];          /* reserved */
  618 };
  619 typedef struct BTHeaderRec BTHeaderRec;
  620 
  621 /* Constants for BTHeaderRec attributes */
  622 enum {
  623         kBTBadCloseMask          = 0x00000001,  /* reserved */
  624         kBTBigKeysMask           = 0x00000002,  /* key length field is 16 bits */
  625         kBTVariableIndexKeysMask = 0x00000004   /* keys in index nodes are variable length */
  626 };
  627 
  628 
  629 /* Catalog Key Name Comparison Type */
  630 enum {
  631         kHFSCaseFolding   = 0xCF,  /* case folding (case-insensitive) */
  632         kHFSBinaryCompare = 0xBC,  /* binary compare (case-sensitive) */
  633 };
  634 
  635 /* JournalInfoBlock - Structure that describes where our journal lives */
  636 struct JournalInfoBlock {
  637         u_int32_t       flags;
  638         u_int32_t       device_signature[8];  // signature used to locate our device.
  639         u_int64_t       offset;               // byte offset to the journal on the device
  640         u_int64_t       size;                 // size in bytes of the journal
  641         u_int32_t       reserved[32];
  642 };
  643 typedef struct JournalInfoBlock JournalInfoBlock;
  644 
  645 enum {
  646     kJIJournalInFSMask          = 0x00000001,
  647     kJIJournalOnOtherDeviceMask = 0x00000002,
  648     kJIJournalNeedInitMask      = 0x00000004
  649 };
  650 
  651 
  652 #pragma options align=reset
  653 
  654 #ifdef __cplusplus
  655 }
  656 #endif
  657 
  658 #else
  659 #warning    hfs_format.h is not compatible with HFSVolumes.h (include only one)
  660 #endif /* __HFSVOLUMES__ */
  661 
  662 #endif /* __HFS_FORMAT__ */

Cache object: 96bffe932f1459d68409e3a0dca63a31


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.