hfs.h revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _HFS_H
#define _HFS_H
/* WARNING : bn is used 2 times in theses macro */
/* so _never_ use side effect operators when using them */
/* Maximum number of blocks for the copy buffers */
#define BLOCK_MAX_BUFF 256
/* Maximum size of the copy buffers, in bytes */
#define BYTES_MAX_BUFF 8388608
/* Apple Creator Codes follow */
#define HFSP_VERSION 4
#define HFSX_VERSION 5
#define HFS_HARD_LOCK 7
#define HFS_UNMOUNTED 8
#define HFS_BAD_SPARED 9
#define HFS_SOFT_LOCK 15
#define HFSP_NO_CACHE 10
#define HFSP_INCONSISTENT 11
#define HFSP_REUSE_CNID 12
#define HFSP_JOURNALED 13
#define HFS_IDX_NODE 0x00
#define HFS_HDR_NODE 0x01
#define HFS_MAP_NODE 0x02
#define HFS_LEAF_NODE 0xFF
#define HFS_FIRST_REC 0x0E
#define HFS_NSD_HD_REC 0x78
#define HFS_MAP_REC 0xF8
#define HFS_DATA_FORK 0x00
#define HFS_RES_FORK 0xFF
#define HFS_CAT_DIR 0x01
#define HFS_CAT_FILE 0x02
#define HFS_CAT_DIR_TH 0x03
#define HFS_CAT_FILE_TH 0x04
#define HFSP_ATTR_INLINE 0x10
#define HFSP_ATTR_FORK 0x20
#define HFSP_ATTR_EXTENTS 0x30
#define HFS_ROOT_PAR_ID 0x01
#define HFS_ROOT_DIR_ID 0x02
#define HFS_XTENT_ID 0x03
#define HFS_CATALOG_ID 0x04
#define HFS_BAD_BLOCK_ID 0x05
#define HFSP_ALLOC_ID 0x06
#define HFSP_STARTUP_ID 0x07
#define HFSP_ATTRIB_ID 0x08
#define HFSP_BOGUS_ID 0x0F
#define HFSP_FIRST_AV_ID 0x10
#define HFSJ_JOURN_IN_FS 0x00
#define HFSJ_JOURN_OTHER_DEV 0x01
#define HFSJ_JOURN_NEED_INIT 0x02
#define HFSJ_HEADER_MAGIC 0x4a4e4c78
#define HFSJ_ENDIAN_MAGIC 0x12345678
#define HFS_EXT_NB 3
#define HFSP_EXT_NB 8
/* Define the filenames used by the FS extractor */
#ifdef HFS_EXTRACT_FS
#define HFS_MDB_FILENAME "mdb.hfs"
#define HFS_CATALOG_FILENAME "catalog.hfs"
#define HFS_EXTENTS_FILENAME "extents.hfs"
#define HFS_BITMAP_FILENAME "bitmap.hfs"
#define HFSP_VH_FILENAME "vh.hfsplus"
#define HFSP_CATALOG_FILENAME "catalog.hfsplus"
#define HFSP_EXTENTS_FILENAME "extents.hfsplus"
#define HFSP_BITMAP_FILENAME "bitmap.hfsplus"
#define HFSP_ATTRIB_FILENAME "attributes.hfsplus"
#define HFSP_STARTUP_FILENAME "startup.hfsplus"
#endif /* HFS_EXTRACT_FS */
/* ----------------------------------- */
/* -- HFS DATA STRUCTURES -- */
/* ----------------------------------- */
#ifdef __sun
#define __attribute__(X) /*nothing*/
#endif /* __sun */
/* Extent descriptor */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsExtDescriptor HfsExtDescriptor;
/* Volume header */
#ifdef __sun
#pragma pack(1)
#endif
char name[27];
union __attribute__ ((packed)) {
struct __attribute__ ((packed)) {
} legacy;
struct __attribute__ ((packed)) {
} embedded;
} old_new;
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsMasterDirectoryBlock HfsMasterDirectoryBlock;
/* B*-Tree Node Descriptor */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsNodeDescriptor HfsNodeDescriptor;
/* Header record of a whole B*-Tree */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsHeaderRecord HfsHeaderRecord;
/* Catalog key for B*-Tree lookup in the catalog file */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsCatalogKey HfsCatalogKey;
/* Extents overflow key for B*-Tree lookup */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsExtentKey HfsExtentKey;
/* Catalog subdata case directory */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
/* Catalog subdata case file */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
/* Catalog subdata case directory thread */
#ifdef __sun
#pragma pack(1)
#endif
char name[31];
};
#ifdef __sun
#pragma pack()
#endif
/* Catalog subdata case file thread */
/* Catalog data */
#ifdef __sun
#pragma pack(1)
#endif
union {
} sel;
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsCatalog HfsCatalog;
/* ------------------------------------ */
/* -- HFS+ DATA STRUCTURES -- */
/* ------------------------------------ */
/* documented since 2004 in tn1150 */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPPerms HfsPPerms;
/* HFS+ extent descriptor*/
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPExtDescriptor HfsPExtDescriptor;
/* HFS+ fork data structure */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPForkData HfsPForkData;
/* HFS+ catalog node ID */
typedef uint32_t HfsPNodeID;
/* HFS+ file names */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPUniStr255 HfsPUniStr255;
/* HFS+ volume header */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPVolumeHeader HfsPVolumeHeader;
/* HFS+ B-Tree Node Descriptor. Same as HFS btree. */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPNodeDescriptor HfsPNodeDescriptor;
/* Header record of a whole HFS+ B-Tree. */
#ifdef __sun
#pragma pack(1)
#endif
/* 0xBC = binary compare */
/* otherwise, reserved */
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPHeaderRecord HfsPHeaderRecord;
/* Catalog key for B-Tree lookup in the HFS+ catalog file */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPCatalogKey HfsPCatalogKey;
/* HFS+ catalog subdata case dir */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
/* HFS+ catalog subdata case file */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
/* HFS+ catalog subdata case thread */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPThread HfsPDirTh;
typedef struct _HfsPThread HfsPFileTh;
/* HFS+ Catalog leaf data */
#ifdef __sun
#pragma pack(1)
#endif
union {
} sel;
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPCatalog HfsPCatalog;
/* HFS+ extents file key */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPExtentKey HfsPExtentKey;
/* extent file data is HfsPExtDataRec */
/* Fork data attribute file */
#ifdef __sun
#pragma pack(1)
#endif
union __attribute__ ((packed)) {
} fork_res;
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPForkDataAttr HfsPForkDataAttr;
/* ----------- Journal data structures ----------- */
/* Info block : stored in a block # defined in the VH */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsJJournalInfoBlock HfsJJournalInfoBlock;
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsJJournalHeader HfsJJournalHeader;
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsJBlockInfo HfsJBlockInfo;
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsJBlockListHeader HfsJBlockListHeader;
/* ---------------------------------------- */
/* -- INTERNAL DATA STRUCTURES -- */
/* ---------------------------------------- */
/* Data of an opened HFS file */
struct _HfsPrivateFile {
};
typedef struct _HfsPrivateFile HfsPrivateFile;
/* To store bad block list */
struct _HfsPrivateLinkExtent {
struct _HfsPrivateLinkExtent* next;
};
typedef struct _HfsPrivateLinkExtent HfsPrivateLinkExtent;
/* HFS Filesystem specific data */
struct _HfsPrivateFSData {
unsigned int bad_blocks_xtent_nb;
char bad_blocks_loaded;
};
typedef struct _HfsPrivateFSData HfsPrivateFSData;
/* Generic btree key */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPrivateGenericKey HfsPrivateGenericKey;
/* ----- HFS+ ----- */
/* Data of an opened HFS file */
struct _HfsPPrivateFile {
};
typedef struct _HfsPPrivateFile HfsPPrivateFile;
struct _HfsPPrivateExtent {
};
typedef struct _HfsPPrivateExtent HfsPPrivateExtent;
/* To store bad block list */
struct _HfsPPrivateLinkExtent {
struct _HfsPPrivateLinkExtent* next;
};
typedef struct _HfsPPrivateLinkExtent HfsPPrivateLinkExtent;
/* HFS+ file system specific data */
struct _HfsPPrivateFSData {
unsigned int bad_blocks_xtent_nb;
char bad_blocks_loaded;
char free_geom; /* 1 = plus_geom must be freed */
};
typedef struct _HfsPPrivateFSData HfsPPrivateFSData;
/* Generic + btree key */
#ifdef __sun
#pragma pack(1)
#endif
};
#ifdef __sun
#pragma pack()
#endif
typedef struct _HfsPPrivateGenericKey HfsPPrivateGenericKey;
/* ---- common ---- */
/* node and lead record reference for a BTree search */
struct _HfsCPrivateLeafRec {
unsigned int node_size; /* in sectors */
unsigned int node_number;
unsigned int record_pos;
unsigned int record_number;
};
typedef struct _HfsCPrivateLeafRec HfsCPrivateLeafRec;
extern uint8_t* hfsp_block;
extern unsigned hfs_block_count;
extern unsigned hfsp_block_count;
#endif /* _HFS_H */