]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_format.h
xnu-3248.60.10.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_format.h
index f0d60d8bbe2df79a13a76e85e9d982be5b308251..dcc1807243d10b55c129a8a54ce32cd9c139e920 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 
 #include <sys/types.h>
 #include <sys/appleapiopts.h>
+#include <hfs/hfs_unistr.h>
 
 /*
- * hfs_format.c
+ * hfs_format.h
  *
  * This file describes the on-disk format for HFS and HFS Plus volumes.
  * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
  *
  * http://developer.apple.com/technotes/tn/tn1150.html
  *
+ * Note: Starting 10.9, definition of struct HFSUniStr255 exists in hfs_unitstr.h
+ *
  */
 
 #ifdef __cplusplus
@@ -105,6 +108,13 @@ enum {
 #define FIRST_LINK_XATTR_NAME  "com.apple.system.hfs.firstlink"
 #define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12)
 
+/*
+ * The name space ID for generating an HFS volume UUID
+ *
+ * B3E20F39-F292-11D6-97A4-00306543ECAC
+ */
+#define HFS_UUID_NAMESPACE_ID  "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC"
+
 #endif /* __APPLE_API_PRIVATE */
 
 /*
@@ -125,17 +135,6 @@ enum {
 };
 
 
-#ifndef _HFSUNISTR255_DEFINED_
-#define _HFSUNISTR255_DEFINED_
-/* Unicode strings are used for HFS Plus file and folder names */
-struct HFSUniStr255 {
-       u_int16_t       length;         /* number of unicode characters */
-       u_int16_t       unicode[255];   /* unicode characters */
-} __attribute__((aligned(2), packed));
-typedef struct HFSUniStr255 HFSUniStr255;
-typedef const HFSUniStr255 *ConstHFSUniStr255Param;
-#endif /* _HFSUNISTR255_DEFINED_ */
-
 enum {
        kHFSMaxVolumeNameChars          = 27,
        kHFSMaxFileNameChars            = 31,
@@ -225,6 +224,21 @@ struct FndrOpaqueInfo {
 } __attribute__((aligned(2), packed));
 typedef struct FndrOpaqueInfo FndrOpaqueInfo;
 
+struct FndrExtendedDirInfo {
+       u_int32_t document_id;
+       u_int32_t date_added;
+       u_int16_t extended_flags;
+       u_int16_t reserved3;
+       u_int32_t write_gen_counter;
+} __attribute__((aligned(2), packed));
+
+struct FndrExtendedFileInfo {
+       u_int32_t document_id;
+       u_int32_t date_added;
+       u_int16_t extended_flags;
+       u_int16_t reserved2;
+       u_int32_t write_gen_counter;
+} __attribute__((aligned(2), packed));
 
 /* HFS Plus Fork data info - 80 bytes */
 struct HFSPlusForkData {
@@ -347,7 +361,25 @@ enum {
        kHFSHasLinkChainMask    = 0x0020,
 
        kHFSHasChildLinkBit     = 0x0006,       /* folder has a child that's a dir link */
-       kHFSHasChildLinkMask    = 0x0040
+       kHFSHasChildLinkMask    = 0x0040,
+
+       kHFSHasDateAddedBit     = 0x0007,       /* File/Folder has the date-added stored in the finder info. */
+       kHFSHasDateAddedMask    = 0x0080, 
+
+       kHFSFastDevPinnedBit    = 0x0008,       /* this file has been pinned to the fast-device by the hot-file code on cooperative fusion */
+       kHFSFastDevPinnedMask   = 0x0100,
+
+       kHFSDoNotFastDevPinBit  = 0x0009,       /* this file can not be pinned to the fast-device */
+       kHFSDoNotFastDevPinMask = 0x0200,
+
+       kHFSFastDevCandidateBit  = 0x000a,      /* this item is a potential candidate for fast-dev pinning (as are any of its descendents */
+       kHFSFastDevCandidateMask = 0x0400,
+
+       kHFSAutoCandidateBit     = 0x000b,      /* this item was automatically marked as a fast-dev candidate by the kernel */
+       kHFSAutoCandidateMask    = 0x0800
+
+       // There are only 4 flag bits remaining: 0x1000, 0x2000, 0x4000, 0x8000
+
 };
 
 
@@ -452,9 +484,9 @@ typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
 
 #ifdef __APPLE_API_UNSTABLE
 /*
      These are the types of records in the attribute B-tree.  The values were
      chosen so that they wouldn't conflict with the catalog record types.
-*/
*     These are the types of records in the attribute B-tree.  The values were
*     chosen so that they wouldn't conflict with the catalog record types.
+ */
 enum {
        kHFSPlusAttrInlineData  = 0x10,   /* attributes whose data fits in a b-tree node */
        kHFSPlusAttrForkData    = 0x20,   /* extent based attributes (data lives in extents) */
@@ -463,11 +495,11 @@ enum {
 
 
 /*
      HFSPlusAttrForkData
      For larger attributes, whose value is stored in allocation blocks.
      If the attribute has more than 8 extents, there will be additional
      records (of type HFSPlusAttrExtents) for this attribute.
-*/
*     HFSPlusAttrForkData
*     For larger attributes, whose value is stored in allocation blocks.
*     If the attribute has more than 8 extents, there will be additional
*     records (of type HFSPlusAttrExtents) for this attribute.
+ */
 struct HFSPlusAttrForkData {
        u_int32_t       recordType;             /* == kHFSPlusAttrForkData*/
        u_int32_t       reserved;
@@ -476,10 +508,10 @@ struct HFSPlusAttrForkData {
 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
 
 /*
      HFSPlusAttrExtents
      This record contains information about overflow extents for large,
      fragmented attributes.
-*/
*     HFSPlusAttrExtents
*     This record contains information about overflow extents for large,
*     fragmented attributes.
+ */
 struct HFSPlusAttrExtents {
        u_int32_t               recordType;     /* == kHFSPlusAttrExtents*/
        u_int32_t               reserved;
@@ -512,7 +544,7 @@ struct HFSPlusAttrInlineData {
 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
 
 
-/*     A generic Attribute Record*/
+/* A generic Attribute Record */
 union HFSPlusAttrRecord {
        u_int32_t               recordType;
        HFSPlusAttrInlineData   inlineData;   /* NOT USED */
@@ -555,7 +587,7 @@ enum {
 
 /* HFS and HFS Plus volume attribute bits */
 enum {
-                                                       /* Bits 0-6 are reserved (always cleared by MountVol call) */
+       /* Bits 0-6 are reserved (always cleared by MountVol call) */
        kHFSVolumeHardwareLockBit       = 7,            /* volume is locked by hardware */
        kHFSVolumeUnmountedBit          = 8,            /* volume was successfully unmounted */
        kHFSVolumeSparedBlocksBit       = 9,            /* volume has bad blocks spared */
@@ -565,19 +597,35 @@ enum {
        kHFSVolumeJournaledBit = 13,                    /* this volume has a journal on it */
        kHFSVolumeInconsistentBit = 14,                 /* serious inconsistencies detected at runtime */
        kHFSVolumeSoftwareLockBit       = 15,           /* volume is locked by software */
-
-       kHFSVolumeHardwareLockMask      = 1 << kHFSVolumeHardwareLockBit,
-       kHFSVolumeUnmountedMask         = 1 << kHFSVolumeUnmountedBit,
-       kHFSVolumeSparedBlocksMask      = 1 << kHFSVolumeSparedBlocksBit,
-       kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
-       kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
-       kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit,
-       kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit,
-       kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit,
-       kHFSVolumeSoftwareLockMask      = 1 << kHFSVolumeSoftwareLockBit,
-       kHFSMDBAttributesMask           = 0x8380
+       /*
+        * HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits.
+        * Therefore, bits 16-31 can only be used on HFS Plus.
+        */
+       kHFSUnusedNodeFixBit = 31,                              /* Unused nodes in the Catalog B-tree have been zero-filled.  See Radar #6947811. */
+       kHFSContentProtectionBit = 30,                  /* Volume has per-file content protection */
+
+       /***  Keep these in sync with the bits above ! ****/
+       kHFSVolumeHardwareLockMask              = 0x00000080,
+       kHFSVolumeUnmountedMask                 = 0x00000100,
+       kHFSVolumeSparedBlocksMask              = 0x00000200,
+       kHFSVolumeNoCacheRequiredMask   = 0x00000400,
+       kHFSBootVolumeInconsistentMask  = 0x00000800,
+       kHFSCatalogNodeIDsReusedMask    = 0x00001000,
+       kHFSVolumeJournaledMask                 = 0x00002000,
+       kHFSVolumeInconsistentMask              = 0x00004000,
+       kHFSVolumeSoftwareLockMask              = 0x00008000,
+       
+       /* Bits 16-31 are allocated from high to low */
+
+       kHFSContentProtectionMask               = 0x40000000,
+       kHFSUnusedNodeFixMask                   = 0x80000000,
+       
+       kHFSMDBAttributesMask                   = 0x8380
 };
 
+enum {
+       kHFSUnusedNodesFixDate = 0xc5ef2480             /* March 25, 2009 */
+};
 
 /* HFS Master Directory Block - 162 bytes */
 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
@@ -729,13 +777,26 @@ enum {
        kHFSBinaryCompare = 0xBC  /* binary compare (case-sensitive) */
 };
 
+#include <uuid/uuid.h>
+
 /* JournalInfoBlock - Structure that describes where our journal lives */
+
+// the original size of the reserved field in the JournalInfoBlock was
+// 32*sizeof(u_int32_t).  To keep the total size of the structure the 
+// same we subtract the size of new fields (currently: ext_jnl_uuid and
+// machine_uuid).  If you add additional fields, place them before the
+// reserved field and subtract their size in this macro.
+//
+#define JIB_RESERVED_SIZE  ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48)
+
 struct JournalInfoBlock {
        u_int32_t       flags;
        u_int32_t       device_signature[8];  // signature used to locate our device.
        u_int64_t       offset;               // byte offset to the journal on the device
        u_int64_t       size;                 // size in bytes of the journal
-       u_int32_t       reserved[32];
+       uuid_string_t   ext_jnl_uuid;
+       char            machine_serial_num[48];
+       char            reserved[JIB_RESERVED_SIZE];
 } __attribute__((aligned(2), packed));
 typedef struct JournalInfoBlock JournalInfoBlock;
 
@@ -745,6 +806,13 @@ enum {
     kJIJournalNeedInitMask      = 0x00000004
 };
 
+//
+// This the content type uuid for "external journal" GPT 
+// partitions.  Each instance of a partition also has a
+// uuid that uniquely identifies that instance.
+//
+#define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC"
+
 
 #ifdef __cplusplus
 }