linux/fs/hfsplus/hfsplus_raw.h
<<
>>
Prefs
   1/*
   2 *  linux/include/linux/hfsplus_raw.h
   3 *
   4 * Copyright (C) 1999
   5 * Brad Boyer (flar@pants.nu)
   6 * (C) 2003 Ardis Technologies <roman@ardistech.com>
   7 *
   8 * Format of structures on disk
   9 * Information taken from Apple Technote #1150 (HFS Plus Volume Format)
  10 *
  11 */
  12
  13#ifndef _LINUX_HFSPLUS_RAW_H
  14#define _LINUX_HFSPLUS_RAW_H
  15
  16#include <linux/types.h>
  17
  18/* Some constants */
  19#define HFSPLUS_SECTOR_SIZE        512
  20#define HFSPLUS_SECTOR_SHIFT         9
  21#define HFSPLUS_VOLHEAD_SECTOR       2
  22#define HFSPLUS_VOLHEAD_SIG     0x482b
  23#define HFSPLUS_VOLHEAD_SIGX    0x4858
  24#define HFSPLUS_SUPER_MAGIC     0x482b
  25#define HFSPLUS_MIN_VERSION          4
  26#define HFSPLUS_CURRENT_VERSION      5
  27
  28#define HFSP_WRAP_MAGIC         0x4244
  29#define HFSP_WRAP_ATTRIB_SLOCK  0x8000
  30#define HFSP_WRAP_ATTRIB_SPARED 0x0200
  31
  32#define HFSP_WRAPOFF_SIG          0x00
  33#define HFSP_WRAPOFF_ATTRIB       0x0A
  34#define HFSP_WRAPOFF_ABLKSIZE     0x14
  35#define HFSP_WRAPOFF_ABLKSTART    0x1C
  36#define HFSP_WRAPOFF_EMBEDSIG     0x7C
  37#define HFSP_WRAPOFF_EMBEDEXT     0x7E
  38
  39#define HFSP_HIDDENDIR_NAME \
  40        "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data"
  41
  42#define HFSP_HARDLINK_TYPE      0x686c6e6b      /* 'hlnk' */
  43#define HFSP_HFSPLUS_CREATOR    0x6866732b      /* 'hfs+' */
  44
  45#define HFSP_SYMLINK_TYPE       0x736c6e6b      /* 'slnk' */
  46#define HFSP_SYMLINK_CREATOR    0x72686170      /* 'rhap' */
  47
  48#define HFSP_MOUNT_VERSION      0x482b4c78      /* 'H+Lx' */
  49
  50/* Structures used on disk */
  51
  52typedef __be32 hfsplus_cnid;
  53typedef __be16 hfsplus_unichr;
  54
  55/* A "string" as used in filenames, etc. */
  56struct hfsplus_unistr {
  57        __be16 length;
  58        hfsplus_unichr unicode[255];
  59} __packed;
  60
  61#define HFSPLUS_MAX_STRLEN 255
  62
  63/* POSIX permissions */
  64struct hfsplus_perm {
  65        __be32 owner;
  66        __be32 group;
  67        u8  rootflags;
  68        u8  userflags;
  69        __be16 mode;
  70        __be32 dev;
  71} __packed;
  72
  73#define HFSPLUS_FLG_NODUMP      0x01
  74#define HFSPLUS_FLG_IMMUTABLE   0x02
  75#define HFSPLUS_FLG_APPEND      0x04
  76
  77/* A single contiguous area of a file */
  78struct hfsplus_extent {
  79        __be32 start_block;
  80        __be32 block_count;
  81} __packed;
  82typedef struct hfsplus_extent hfsplus_extent_rec[8];
  83
  84/* Information for a "Fork" in a file */
  85struct hfsplus_fork_raw {
  86        __be64 total_size;
  87        __be32 clump_size;
  88        __be32 total_blocks;
  89        hfsplus_extent_rec extents;
  90} __packed;
  91
  92/* HFS+ Volume Header */
  93struct hfsplus_vh {
  94        __be16 signature;
  95        __be16 version;
  96        __be32 attributes;
  97        __be32 last_mount_vers;
  98        u32 reserved;
  99
 100        __be32 create_date;
 101        __be32 modify_date;
 102        __be32 backup_date;
 103        __be32 checked_date;
 104
 105        __be32 file_count;
 106        __be32 folder_count;
 107
 108        __be32 blocksize;
 109        __be32 total_blocks;
 110        __be32 free_blocks;
 111
 112        __be32 next_alloc;
 113        __be32 rsrc_clump_sz;
 114        __be32 data_clump_sz;
 115        hfsplus_cnid next_cnid;
 116
 117        __be32 write_count;
 118        __be64 encodings_bmp;
 119
 120        u8 finder_info[32];
 121
 122        struct hfsplus_fork_raw alloc_file;
 123        struct hfsplus_fork_raw ext_file;
 124        struct hfsplus_fork_raw cat_file;
 125        struct hfsplus_fork_raw attr_file;
 126        struct hfsplus_fork_raw start_file;
 127} __packed;
 128
 129/* HFS+ volume attributes */
 130#define HFSPLUS_VOL_UNMNT               (1 << 8)
 131#define HFSPLUS_VOL_SPARE_BLK           (1 << 9)
 132#define HFSPLUS_VOL_NOCACHE             (1 << 10)
 133#define HFSPLUS_VOL_INCNSTNT            (1 << 11)
 134#define HFSPLUS_VOL_NODEID_REUSED       (1 << 12)
 135#define HFSPLUS_VOL_JOURNALED           (1 << 13)
 136#define HFSPLUS_VOL_SOFTLOCK            (1 << 15)
 137
 138/* HFS+ BTree node descriptor */
 139struct hfs_bnode_desc {
 140        __be32 next;
 141        __be32 prev;
 142        s8 type;
 143        u8 height;
 144        __be16 num_recs;
 145        u16 reserved;
 146} __packed;
 147
 148/* HFS+ BTree node types */
 149#define HFS_NODE_INDEX  0x00
 150#define HFS_NODE_HEADER 0x01
 151#define HFS_NODE_MAP    0x02
 152#define HFS_NODE_LEAF   0xFF
 153
 154/* HFS+ BTree header */
 155struct hfs_btree_header_rec {
 156        __be16 depth;
 157        __be32 root;
 158        __be32 leaf_count;
 159        __be32 leaf_head;
 160        __be32 leaf_tail;
 161        __be16 node_size;
 162        __be16 max_key_len;
 163        __be32 node_count;
 164        __be32 free_nodes;
 165        u16 reserved1;
 166        __be32 clump_size;
 167        u8 btree_type;
 168        u8 key_type;
 169        __be32 attributes;
 170        u32 reserved3[16];
 171} __packed;
 172
 173/* BTree attributes */
 174#define HFS_TREE_BIGKEYS        2
 175#define HFS_TREE_VARIDXKEYS     4
 176
 177/* HFS+ BTree misc info */
 178#define HFSPLUS_TREE_HEAD 0
 179#define HFSPLUS_NODE_MXSZ 32768
 180
 181/* Some special File ID numbers (stolen from hfs.h) */
 182#define HFSPLUS_POR_CNID                1       /* Parent Of the Root */
 183#define HFSPLUS_ROOT_CNID               2       /* ROOT directory */
 184#define HFSPLUS_EXT_CNID                3       /* EXTents B-tree */
 185#define HFSPLUS_CAT_CNID                4       /* CATalog B-tree */
 186#define HFSPLUS_BAD_CNID                5       /* BAD blocks file */
 187#define HFSPLUS_ALLOC_CNID              6       /* ALLOCation file */
 188#define HFSPLUS_START_CNID              7       /* STARTup file */
 189#define HFSPLUS_ATTR_CNID               8       /* ATTRibutes file */
 190#define HFSPLUS_EXCH_CNID               15      /* ExchangeFiles temp id */
 191#define HFSPLUS_FIRSTUSER_CNID          16      /* first available user id */
 192
 193/* btree key type */
 194#define HFSPLUS_KEY_CASEFOLDING         0xCF    /* case-insensitive */
 195#define HFSPLUS_KEY_BINARY              0xBC    /* case-sensitive */
 196
 197/* HFS+ catalog entry key */
 198struct hfsplus_cat_key {
 199        __be16 key_len;
 200        hfsplus_cnid parent;
 201        struct hfsplus_unistr name;
 202} __packed;
 203
 204#define HFSPLUS_CAT_KEYLEN      (sizeof(struct hfsplus_cat_key))
 205
 206/* Structs from hfs.h */
 207struct hfsp_point {
 208        __be16 v;
 209        __be16 h;
 210} __packed;
 211
 212struct hfsp_rect {
 213        __be16 top;
 214        __be16 left;
 215        __be16 bottom;
 216        __be16 right;
 217} __packed;
 218
 219
 220/* HFS directory info (stolen from hfs.h */
 221struct DInfo {
 222        struct hfsp_rect frRect;
 223        __be16 frFlags;
 224        struct hfsp_point frLocation;
 225        __be16 frView;
 226} __packed;
 227
 228struct DXInfo {
 229        struct hfsp_point frScroll;
 230        __be32 frOpenChain;
 231        __be16 frUnused;
 232        __be16 frComment;
 233        __be32 frPutAway;
 234} __packed;
 235
 236/* HFS+ folder data (part of an hfsplus_cat_entry) */
 237struct hfsplus_cat_folder {
 238        __be16 type;
 239        __be16 flags;
 240        __be32 valence;
 241        hfsplus_cnid id;
 242        __be32 create_date;
 243        __be32 content_mod_date;
 244        __be32 attribute_mod_date;
 245        __be32 access_date;
 246        __be32 backup_date;
 247        struct hfsplus_perm permissions;
 248        struct DInfo user_info;
 249        struct DXInfo finder_info;
 250        __be32 text_encoding;
 251        u32 reserved;
 252} __packed;
 253
 254/* HFS file info (stolen from hfs.h) */
 255struct FInfo {
 256        __be32 fdType;
 257        __be32 fdCreator;
 258        __be16 fdFlags;
 259        struct hfsp_point fdLocation;
 260        __be16 fdFldr;
 261} __packed;
 262
 263struct FXInfo {
 264        __be16 fdIconID;
 265        u8 fdUnused[8];
 266        __be16 fdComment;
 267        __be32 fdPutAway;
 268} __packed;
 269
 270/* HFS+ file data (part of a cat_entry) */
 271struct hfsplus_cat_file {
 272        __be16 type;
 273        __be16 flags;
 274        u32 reserved1;
 275        hfsplus_cnid id;
 276        __be32 create_date;
 277        __be32 content_mod_date;
 278        __be32 attribute_mod_date;
 279        __be32 access_date;
 280        __be32 backup_date;
 281        struct hfsplus_perm permissions;
 282        struct FInfo user_info;
 283        struct FXInfo finder_info;
 284        __be32 text_encoding;
 285        u32 reserved2;
 286
 287        struct hfsplus_fork_raw data_fork;
 288        struct hfsplus_fork_raw rsrc_fork;
 289} __packed;
 290
 291/* File attribute bits */
 292#define HFSPLUS_FILE_LOCKED             0x0001
 293#define HFSPLUS_FILE_THREAD_EXISTS      0x0002
 294
 295/* HFS+ catalog thread (part of a cat_entry) */
 296struct hfsplus_cat_thread {
 297        __be16 type;
 298        s16 reserved;
 299        hfsplus_cnid parentID;
 300        struct hfsplus_unistr nodeName;
 301} __packed;
 302
 303#define HFSPLUS_MIN_THREAD_SZ 10
 304
 305/* A data record in the catalog tree */
 306typedef union {
 307        __be16 type;
 308        struct hfsplus_cat_folder folder;
 309        struct hfsplus_cat_file file;
 310        struct hfsplus_cat_thread thread;
 311} __packed hfsplus_cat_entry;
 312
 313/* HFS+ catalog entry type */
 314#define HFSPLUS_FOLDER         0x0001
 315#define HFSPLUS_FILE           0x0002
 316#define HFSPLUS_FOLDER_THREAD  0x0003
 317#define HFSPLUS_FILE_THREAD    0x0004
 318
 319/* HFS+ extents tree key */
 320struct hfsplus_ext_key {
 321        __be16 key_len;
 322        u8 fork_type;
 323        u8 pad;
 324        hfsplus_cnid cnid;
 325        __be32 start_block;
 326} __packed;
 327
 328#define HFSPLUS_EXT_KEYLEN      sizeof(struct hfsplus_ext_key)
 329
 330/* HFS+ generic BTree key */
 331typedef union {
 332        __be16 key_len;
 333        struct hfsplus_cat_key cat;
 334        struct hfsplus_ext_key ext;
 335} __packed hfsplus_btree_key;
 336
 337#endif
 338