Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hfs/hfsplus: move on-disk layout declarations into hfs_common.h

Currently, HFS declares on-disk layout's metadata structures
in fs/hfs/hfs.h and HFS+ declares it in fs/hfsplus/hfsplus_raw.h.
However, HFS and HFS+ on-disk layouts have some similarity and
overlapping in declarations. As a result, fs/hfs/hfs.h and
fs/hfsplus/hfsplus_raw.h contain multiple duplicated declarations.
Moreover, both HFS and HFS+ drivers contain completely similar
implemented functionality in multiple places.

This patch is moving the on-disk layout declarations from
fs/hfs/hfs.h and fs/hfsplus/hfsplus_raw.h into
include/linux/hfs_common.h with the goal to exclude
the duplication in declarations. Also, this patch prepares
the basis for creating a hfslib that can aggregate common
functionality without necessity to duplicate the same code
in HFS and HFS+ drivers.

Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
cc: Yangtao Li <frank.li@vivo.com>
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>

+645 -717
-42
fs/hfs/btree.h
··· 129 129 extern int hfs_brec_find(struct hfs_find_data *fd); 130 130 extern int hfs_brec_read(struct hfs_find_data *fd, void *rec, u32 rec_len); 131 131 extern int hfs_brec_goto(struct hfs_find_data *fd, int cnt); 132 - 133 - 134 - struct hfs_bnode_desc { 135 - __be32 next; /* (V) Number of the next node at this level */ 136 - __be32 prev; /* (V) Number of the prev node at this level */ 137 - u8 type; /* (F) The type of node */ 138 - u8 height; /* (F) The level of this node (leaves=1) */ 139 - __be16 num_recs; /* (V) The number of records in this node */ 140 - u16 reserved; 141 - } __packed; 142 - 143 - #define HFS_NODE_INDEX 0x00 /* An internal (index) node */ 144 - #define HFS_NODE_HEADER 0x01 /* The tree header node (node 0) */ 145 - #define HFS_NODE_MAP 0x02 /* Holds part of the bitmap of used nodes */ 146 - #define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */ 147 - 148 - struct hfs_btree_header_rec { 149 - __be16 depth; /* (V) The number of levels in this B-tree */ 150 - __be32 root; /* (V) The node number of the root node */ 151 - __be32 leaf_count; /* (V) The number of leaf records */ 152 - __be32 leaf_head; /* (V) The number of the first leaf node */ 153 - __be32 leaf_tail; /* (V) The number of the last leaf node */ 154 - __be16 node_size; /* (F) The number of bytes in a node (=512) */ 155 - __be16 max_key_len; /* (F) The length of a key in an index node */ 156 - __be32 node_count; /* (V) The total number of nodes */ 157 - __be32 free_nodes; /* (V) The number of unused nodes */ 158 - u16 reserved1; 159 - __be32 clump_size; /* (F) clump size. not usually used. */ 160 - u8 btree_type; /* (F) BTree type */ 161 - u8 reserved2; 162 - __be32 attributes; /* (F) attributes */ 163 - u32 reserved3[16]; 164 - } __packed; 165 - 166 - #define BTREE_ATTR_BADCLOSE 0x00000001 /* b-tree not closed properly. not 167 - used by hfsplus. */ 168 - #define HFS_TREE_BIGKEYS 0x00000002 /* key length is u16 instead of u8. 169 - used by hfsplus. */ 170 - #define HFS_TREE_VARIDXKEYS 0x00000004 /* variable key length instead of 171 - max key length. use din catalog 172 - b-tree but not in extents 173 - b-tree (hfsplus). */
+1 -268
fs/hfs/hfs.h
··· 9 9 #ifndef _HFS_H 10 10 #define _HFS_H 11 11 12 - /* offsets to various blocks */ 13 - #define HFS_DD_BLK 0 /* Driver Descriptor block */ 14 - #define HFS_PMAP_BLK 1 /* First block of partition map */ 15 - #define HFS_MDB_BLK 2 /* Block (w/i partition) of MDB */ 16 - 17 - /* magic numbers for various disk blocks */ 18 - #define HFS_DRVR_DESC_MAGIC 0x4552 /* "ER": driver descriptor map */ 19 - #define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */ 20 - #define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */ 21 - #define HFS_SUPER_MAGIC 0x4244 /* "BD": HFS MDB (super block) */ 22 - #define HFS_MFS_SUPER_MAGIC 0xD2D7 /* MFS MDB (super block) */ 23 - 24 - /* various FIXED size parameters */ 25 - #define HFS_SECTOR_SIZE 512 /* size of an HFS sector */ 26 - #define HFS_SECTOR_SIZE_BITS 9 /* log_2(HFS_SECTOR_SIZE) */ 27 - #define HFS_NAMELEN 31 /* maximum length of an HFS filename */ 28 - #define HFS_MAX_NAMELEN 128 29 - #define HFS_MAX_VALENCE 32767U 30 - 31 - /* Meanings of the drAtrb field of the MDB, 32 - * Reference: _Inside Macintosh: Files_ p. 2-61 33 - */ 34 - #define HFS_SB_ATTRIB_HLOCK (1 << 7) 35 - #define HFS_SB_ATTRIB_UNMNT (1 << 8) 36 - #define HFS_SB_ATTRIB_SPARED (1 << 9) 37 - #define HFS_SB_ATTRIB_INCNSTNT (1 << 11) 38 - #define HFS_SB_ATTRIB_SLOCK (1 << 15) 39 - 40 - /* Some special File ID numbers */ 41 - #define HFS_POR_CNID 1 /* Parent Of the Root */ 42 - #define HFS_ROOT_CNID 2 /* ROOT directory */ 43 - #define HFS_EXT_CNID 3 /* EXTents B-tree */ 44 - #define HFS_CAT_CNID 4 /* CATalog B-tree */ 45 - #define HFS_BAD_CNID 5 /* BAD blocks file */ 46 - #define HFS_ALLOC_CNID 6 /* ALLOCation file (HFS+) */ 47 - #define HFS_START_CNID 7 /* STARTup file (HFS+) */ 48 - #define HFS_ATTR_CNID 8 /* ATTRibutes file (HFS+) */ 49 - #define HFS_EXCH_CNID 15 /* ExchangeFiles temp id */ 50 - #define HFS_FIRSTUSER_CNID 16 51 - 52 - /* values for hfs_cat_rec.cdrType */ 53 - #define HFS_CDR_DIR 0x01 /* folder (directory) */ 54 - #define HFS_CDR_FIL 0x02 /* file */ 55 - #define HFS_CDR_THD 0x03 /* folder (directory) thread */ 56 - #define HFS_CDR_FTH 0x04 /* file thread */ 57 - 58 - /* legal values for hfs_ext_key.FkType and hfs_file.fork */ 59 - #define HFS_FK_DATA 0x00 60 - #define HFS_FK_RSRC 0xFF 61 - 62 - /* bits in hfs_fil_entry.Flags */ 63 - #define HFS_FIL_LOCK 0x01 /* locked */ 64 - #define HFS_FIL_THD 0x02 /* file thread */ 65 - #define HFS_FIL_DOPEN 0x04 /* data fork open */ 66 - #define HFS_FIL_ROPEN 0x08 /* resource fork open */ 67 - #define HFS_FIL_DIR 0x10 /* directory (always clear) */ 68 - #define HFS_FIL_NOCOPY 0x40 /* copy-protected file */ 69 - #define HFS_FIL_USED 0x80 /* open */ 70 - 71 - /* bits in hfs_dir_entry.Flags. dirflags is 16 bits. */ 72 - #define HFS_DIR_LOCK 0x01 /* locked */ 73 - #define HFS_DIR_THD 0x02 /* directory thread */ 74 - #define HFS_DIR_INEXPFOLDER 0x04 /* in a shared area */ 75 - #define HFS_DIR_MOUNTED 0x08 /* mounted */ 76 - #define HFS_DIR_DIR 0x10 /* directory (always set) */ 77 - #define HFS_DIR_EXPFOLDER 0x20 /* share point */ 78 - 79 - /* bits hfs_finfo.fdFlags */ 80 - #define HFS_FLG_INITED 0x0100 81 - #define HFS_FLG_LOCKED 0x1000 82 - #define HFS_FLG_INVISIBLE 0x4000 83 - 84 - /*======== HFS structures as they appear on the disk ========*/ 85 - 86 - /* Pascal-style string of up to 31 characters */ 87 - struct hfs_name { 88 - u8 len; 89 - u8 name[HFS_NAMELEN]; 90 - } __packed; 91 - 92 - struct hfs_point { 93 - __be16 v; 94 - __be16 h; 95 - } __packed; 96 - 97 - struct hfs_rect { 98 - __be16 top; 99 - __be16 left; 100 - __be16 bottom; 101 - __be16 right; 102 - } __packed; 103 - 104 - struct hfs_finfo { 105 - __be32 fdType; 106 - __be32 fdCreator; 107 - __be16 fdFlags; 108 - struct hfs_point fdLocation; 109 - __be16 fdFldr; 110 - } __packed; 111 - 112 - struct hfs_fxinfo { 113 - __be16 fdIconID; 114 - u8 fdUnused[8]; 115 - __be16 fdComment; 116 - __be32 fdPutAway; 117 - } __packed; 118 - 119 - struct hfs_dinfo { 120 - struct hfs_rect frRect; 121 - __be16 frFlags; 122 - struct hfs_point frLocation; 123 - __be16 frView; 124 - } __packed; 125 - 126 - struct hfs_dxinfo { 127 - struct hfs_point frScroll; 128 - __be32 frOpenChain; 129 - __be16 frUnused; 130 - __be16 frComment; 131 - __be32 frPutAway; 132 - } __packed; 133 - 134 - union hfs_finder_info { 135 - struct { 136 - struct hfs_finfo finfo; 137 - struct hfs_fxinfo fxinfo; 138 - } file; 139 - struct { 140 - struct hfs_dinfo dinfo; 141 - struct hfs_dxinfo dxinfo; 142 - } dir; 143 - } __packed; 144 - 145 - /* Cast to a pointer to a generic bkey */ 146 - #define HFS_BKEY(X) (((void)((X)->KeyLen)), ((struct hfs_bkey *)(X))) 147 - 148 - /* The key used in the catalog b-tree: */ 149 - struct hfs_cat_key { 150 - u8 key_len; /* number of bytes in the key */ 151 - u8 reserved; /* padding */ 152 - __be32 ParID; /* CNID of the parent dir */ 153 - struct hfs_name CName; /* The filename of the entry */ 154 - } __packed; 155 - 156 - /* The key used in the extents b-tree: */ 157 - struct hfs_ext_key { 158 - u8 key_len; /* number of bytes in the key */ 159 - u8 FkType; /* HFS_FK_{DATA,RSRC} */ 160 - __be32 FNum; /* The File ID of the file */ 161 - __be16 FABN; /* allocation blocks number*/ 162 - } __packed; 163 - 164 - typedef union hfs_btree_key { 165 - u8 key_len; /* number of bytes in the key */ 166 - struct hfs_cat_key cat; 167 - struct hfs_ext_key ext; 168 - } hfs_btree_key; 169 - 170 - #define HFS_MAX_CAT_KEYLEN (sizeof(struct hfs_cat_key) - sizeof(u8)) 171 - #define HFS_MAX_EXT_KEYLEN (sizeof(struct hfs_ext_key) - sizeof(u8)) 172 - 173 - typedef union hfs_btree_key btree_key; 174 - 175 - struct hfs_extent { 176 - __be16 block; 177 - __be16 count; 178 - }; 179 - typedef struct hfs_extent hfs_extent_rec[3]; 180 - 181 - /* The catalog record for a file */ 182 - struct hfs_cat_file { 183 - s8 type; /* The type of entry */ 184 - u8 reserved; 185 - u8 Flags; /* Flags such as read-only */ 186 - s8 Typ; /* file version number = 0 */ 187 - struct hfs_finfo UsrWds; /* data used by the Finder */ 188 - __be32 FlNum; /* The CNID */ 189 - __be16 StBlk; /* obsolete */ 190 - __be32 LgLen; /* The logical EOF of the data fork*/ 191 - __be32 PyLen; /* The physical EOF of the data fork */ 192 - __be16 RStBlk; /* obsolete */ 193 - __be32 RLgLen; /* The logical EOF of the rsrc fork */ 194 - __be32 RPyLen; /* The physical EOF of the rsrc fork */ 195 - __be32 CrDat; /* The creation date */ 196 - __be32 MdDat; /* The modified date */ 197 - __be32 BkDat; /* The last backup date */ 198 - struct hfs_fxinfo FndrInfo; /* more data for the Finder */ 199 - __be16 ClpSize; /* number of bytes to allocate 200 - when extending files */ 201 - hfs_extent_rec ExtRec; /* first extent record 202 - for the data fork */ 203 - hfs_extent_rec RExtRec; /* first extent record 204 - for the resource fork */ 205 - u32 Resrv; /* reserved by Apple */ 206 - } __packed; 207 - 208 - /* the catalog record for a directory */ 209 - struct hfs_cat_dir { 210 - s8 type; /* The type of entry */ 211 - u8 reserved; 212 - __be16 Flags; /* flags */ 213 - __be16 Val; /* Valence: number of files and 214 - dirs in the directory */ 215 - __be32 DirID; /* The CNID */ 216 - __be32 CrDat; /* The creation date */ 217 - __be32 MdDat; /* The modification date */ 218 - __be32 BkDat; /* The last backup date */ 219 - struct hfs_dinfo UsrInfo; /* data used by the Finder */ 220 - struct hfs_dxinfo FndrInfo; /* more data used by Finder */ 221 - u8 Resrv[16]; /* reserved by Apple */ 222 - } __packed; 223 - 224 - /* the catalog record for a thread */ 225 - struct hfs_cat_thread { 226 - s8 type; /* The type of entry */ 227 - u8 reserved[9]; /* reserved by Apple */ 228 - __be32 ParID; /* CNID of parent directory */ 229 - struct hfs_name CName; /* The name of this entry */ 230 - } __packed; 231 - 232 - /* A catalog tree record */ 233 - typedef union hfs_cat_rec { 234 - s8 type; /* The type of entry */ 235 - struct hfs_cat_file file; 236 - struct hfs_cat_dir dir; 237 - struct hfs_cat_thread thread; 238 - } hfs_cat_rec; 239 - 240 - struct hfs_mdb { 241 - __be16 drSigWord; /* Signature word indicating fs type */ 242 - __be32 drCrDate; /* fs creation date/time */ 243 - __be32 drLsMod; /* fs modification date/time */ 244 - __be16 drAtrb; /* fs attributes */ 245 - __be16 drNmFls; /* number of files in root directory */ 246 - __be16 drVBMSt; /* location (in 512-byte blocks) 247 - of the volume bitmap */ 248 - __be16 drAllocPtr; /* location (in allocation blocks) 249 - to begin next allocation search */ 250 - __be16 drNmAlBlks; /* number of allocation blocks */ 251 - __be32 drAlBlkSiz; /* bytes in an allocation block */ 252 - __be32 drClpSiz; /* clumpsize, the number of bytes to 253 - allocate when extending a file */ 254 - __be16 drAlBlSt; /* location (in 512-byte blocks) 255 - of the first allocation block */ 256 - __be32 drNxtCNID; /* CNID to assign to the next 257 - file or directory created */ 258 - __be16 drFreeBks; /* number of free allocation blocks */ 259 - u8 drVN[28]; /* the volume label */ 260 - __be32 drVolBkUp; /* fs backup date/time */ 261 - __be16 drVSeqNum; /* backup sequence number */ 262 - __be32 drWrCnt; /* fs write count */ 263 - __be32 drXTClpSiz; /* clumpsize for the extents B-tree */ 264 - __be32 drCTClpSiz; /* clumpsize for the catalog B-tree */ 265 - __be16 drNmRtDirs; /* number of directories in 266 - the root directory */ 267 - __be32 drFilCnt; /* number of files in the fs */ 268 - __be32 drDirCnt; /* number of directories in the fs */ 269 - u8 drFndrInfo[32]; /* data used by the Finder */ 270 - __be16 drEmbedSigWord; /* embedded volume signature */ 271 - __be32 drEmbedExtent; /* starting block number (xdrStABN) 272 - and number of allocation blocks 273 - (xdrNumABlks) occupied by embedded 274 - volume */ 275 - __be32 drXTFlSize; /* bytes in the extents B-tree */ 276 - hfs_extent_rec drXTExtRec; /* extents B-tree's first 3 extents */ 277 - __be32 drCTFlSize; /* bytes in the catalog B-tree */ 278 - hfs_extent_rec drCTExtRec; /* catalog B-tree's first 3 extents */ 279 - } __packed; 12 + #include <linux/hfs_common.h> 280 13 281 14 /*======== Data structures kept in memory ========*/ 282 15
-1
fs/hfs/hfs_fs.h
··· 18 18 19 19 #include <asm/byteorder.h> 20 20 #include <linux/uaccess.h> 21 - #include <linux/hfs_common.h> 22 21 23 22 #include "hfs.h" 24 23
-1
fs/hfsplus/hfsplus_fs.h
··· 16 16 #include <linux/buffer_head.h> 17 17 #include <linux/blkdev.h> 18 18 #include <linux/fs_context.h> 19 - #include <linux/hfs_common.h> 20 19 #include "hfsplus_raw.h" 21 20 22 21 /* Runtime config options */
+1 -393
fs/hfsplus/hfsplus_raw.h
··· 15 15 #define _LINUX_HFSPLUS_RAW_H 16 16 17 17 #include <linux/types.h> 18 - 19 - /* Some constants */ 20 - #define HFSPLUS_SECTOR_SIZE 512 21 - #define HFSPLUS_SECTOR_SHIFT 9 22 - #define HFSPLUS_VOLHEAD_SECTOR 2 23 - #define HFSPLUS_VOLHEAD_SIG 0x482b 24 - #define HFSPLUS_VOLHEAD_SIGX 0x4858 25 - #define HFSPLUS_SUPER_MAGIC 0x482b 26 - #define HFSPLUS_MIN_VERSION 4 27 - #define HFSPLUS_CURRENT_VERSION 5 28 - 29 - #define HFSP_WRAP_MAGIC 0x4244 30 - #define HFSP_WRAP_ATTRIB_SLOCK 0x8000 31 - #define HFSP_WRAP_ATTRIB_SPARED 0x0200 32 - 33 - #define HFSP_WRAPOFF_SIG 0x00 34 - #define HFSP_WRAPOFF_ATTRIB 0x0A 35 - #define HFSP_WRAPOFF_ABLKSIZE 0x14 36 - #define HFSP_WRAPOFF_ABLKSTART 0x1C 37 - #define HFSP_WRAPOFF_EMBEDSIG 0x7C 38 - #define HFSP_WRAPOFF_EMBEDEXT 0x7E 39 - 40 - #define HFSP_HIDDENDIR_NAME \ 41 - "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data" 42 - 43 - #define HFSP_HARDLINK_TYPE 0x686c6e6b /* 'hlnk' */ 44 - #define HFSP_HFSPLUS_CREATOR 0x6866732b /* 'hfs+' */ 45 - 46 - #define HFSP_SYMLINK_TYPE 0x736c6e6b /* 'slnk' */ 47 - #define HFSP_SYMLINK_CREATOR 0x72686170 /* 'rhap' */ 48 - 49 - #define HFSP_MOUNT_VERSION 0x482b4c78 /* 'H+Lx' */ 50 - 51 - /* Structures used on disk */ 52 - 53 - typedef __be32 hfsplus_cnid; 54 - typedef __be16 hfsplus_unichr; 55 - 56 - #define HFSPLUS_MAX_STRLEN 255 57 - #define HFSPLUS_ATTR_MAX_STRLEN 127 58 - 59 - /* A "string" as used in filenames, etc. */ 60 - struct hfsplus_unistr { 61 - __be16 length; 62 - hfsplus_unichr unicode[HFSPLUS_MAX_STRLEN]; 63 - } __packed; 64 - 65 - /* 66 - * A "string" is used in attributes file 67 - * for name of extended attribute 68 - */ 69 - struct hfsplus_attr_unistr { 70 - __be16 length; 71 - hfsplus_unichr unicode[HFSPLUS_ATTR_MAX_STRLEN]; 72 - } __packed; 73 - 74 - /* POSIX permissions */ 75 - struct hfsplus_perm { 76 - __be32 owner; 77 - __be32 group; 78 - u8 rootflags; 79 - u8 userflags; 80 - __be16 mode; 81 - __be32 dev; 82 - } __packed; 83 - 84 - #define HFSPLUS_FLG_NODUMP 0x01 85 - #define HFSPLUS_FLG_IMMUTABLE 0x02 86 - #define HFSPLUS_FLG_APPEND 0x04 87 - 88 - /* A single contiguous area of a file */ 89 - struct hfsplus_extent { 90 - __be32 start_block; 91 - __be32 block_count; 92 - } __packed; 93 - typedef struct hfsplus_extent hfsplus_extent_rec[8]; 94 - 95 - /* Information for a "Fork" in a file */ 96 - struct hfsplus_fork_raw { 97 - __be64 total_size; 98 - __be32 clump_size; 99 - __be32 total_blocks; 100 - hfsplus_extent_rec extents; 101 - } __packed; 102 - 103 - /* HFS+ Volume Header */ 104 - struct hfsplus_vh { 105 - __be16 signature; 106 - __be16 version; 107 - __be32 attributes; 108 - __be32 last_mount_vers; 109 - u32 reserved; 110 - 111 - __be32 create_date; 112 - __be32 modify_date; 113 - __be32 backup_date; 114 - __be32 checked_date; 115 - 116 - __be32 file_count; 117 - __be32 folder_count; 118 - 119 - __be32 blocksize; 120 - __be32 total_blocks; 121 - __be32 free_blocks; 122 - 123 - __be32 next_alloc; 124 - __be32 rsrc_clump_sz; 125 - __be32 data_clump_sz; 126 - hfsplus_cnid next_cnid; 127 - 128 - __be32 write_count; 129 - __be64 encodings_bmp; 130 - 131 - u32 finder_info[8]; 132 - 133 - struct hfsplus_fork_raw alloc_file; 134 - struct hfsplus_fork_raw ext_file; 135 - struct hfsplus_fork_raw cat_file; 136 - struct hfsplus_fork_raw attr_file; 137 - struct hfsplus_fork_raw start_file; 138 - } __packed; 139 - 140 - /* HFS+ volume attributes */ 141 - #define HFSPLUS_VOL_UNMNT (1 << 8) 142 - #define HFSPLUS_VOL_SPARE_BLK (1 << 9) 143 - #define HFSPLUS_VOL_NOCACHE (1 << 10) 144 - #define HFSPLUS_VOL_INCNSTNT (1 << 11) 145 - #define HFSPLUS_VOL_NODEID_REUSED (1 << 12) 146 - #define HFSPLUS_VOL_JOURNALED (1 << 13) 147 - #define HFSPLUS_VOL_SOFTLOCK (1 << 15) 148 - #define HFSPLUS_VOL_UNUSED_NODE_FIX (1 << 31) 149 - 150 - /* HFS+ BTree node descriptor */ 151 - struct hfs_bnode_desc { 152 - __be32 next; 153 - __be32 prev; 154 - s8 type; 155 - u8 height; 156 - __be16 num_recs; 157 - u16 reserved; 158 - } __packed; 159 - 160 - /* HFS+ BTree node types */ 161 - #define HFS_NODE_INDEX 0x00 /* An internal (index) node */ 162 - #define HFS_NODE_HEADER 0x01 /* The tree header node (node 0) */ 163 - #define HFS_NODE_MAP 0x02 /* Holds part of the bitmap of used nodes */ 164 - #define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */ 165 - 166 - /* HFS+ BTree header */ 167 - struct hfs_btree_header_rec { 168 - __be16 depth; 169 - __be32 root; 170 - __be32 leaf_count; 171 - __be32 leaf_head; 172 - __be32 leaf_tail; 173 - __be16 node_size; 174 - __be16 max_key_len; 175 - __be32 node_count; 176 - __be32 free_nodes; 177 - u16 reserved1; 178 - __be32 clump_size; 179 - u8 btree_type; 180 - u8 key_type; 181 - __be32 attributes; 182 - u32 reserved3[16]; 183 - } __packed; 184 - 185 - /* BTree attributes */ 186 - #define HFS_TREE_BIGKEYS 2 187 - #define HFS_TREE_VARIDXKEYS 4 188 - 189 - /* HFS+ BTree misc info */ 190 - #define HFSPLUS_TREE_HEAD 0 191 - #define HFSPLUS_NODE_MXSZ 32768 192 - #define HFSPLUS_ATTR_TREE_NODE_SIZE 8192 193 - #define HFSPLUS_BTREE_HDR_NODE_RECS_COUNT 3 194 - #define HFSPLUS_BTREE_HDR_USER_BYTES 128 195 - 196 - /* Some special File ID numbers (stolen from hfs.h) */ 197 - #define HFSPLUS_POR_CNID 1 /* Parent Of the Root */ 198 - #define HFSPLUS_ROOT_CNID 2 /* ROOT directory */ 199 - #define HFSPLUS_EXT_CNID 3 /* EXTents B-tree */ 200 - #define HFSPLUS_CAT_CNID 4 /* CATalog B-tree */ 201 - #define HFSPLUS_BAD_CNID 5 /* BAD blocks file */ 202 - #define HFSPLUS_ALLOC_CNID 6 /* ALLOCation file */ 203 - #define HFSPLUS_START_CNID 7 /* STARTup file */ 204 - #define HFSPLUS_ATTR_CNID 8 /* ATTRibutes file */ 205 - #define HFSPLUS_EXCH_CNID 15 /* ExchangeFiles temp id */ 206 - #define HFSPLUS_FIRSTUSER_CNID 16 /* first available user id */ 207 - 208 - /* btree key type */ 209 - #define HFSPLUS_KEY_CASEFOLDING 0xCF /* case-insensitive */ 210 - #define HFSPLUS_KEY_BINARY 0xBC /* case-sensitive */ 211 - 212 - /* HFS+ catalog entry key */ 213 - struct hfsplus_cat_key { 214 - __be16 key_len; 215 - hfsplus_cnid parent; 216 - struct hfsplus_unistr name; 217 - } __packed; 218 - 219 - #define HFSPLUS_CAT_KEYLEN (sizeof(struct hfsplus_cat_key)) 220 - 221 - /* Structs from hfs.h */ 222 - struct hfsp_point { 223 - __be16 v; 224 - __be16 h; 225 - } __packed; 226 - 227 - struct hfsp_rect { 228 - __be16 top; 229 - __be16 left; 230 - __be16 bottom; 231 - __be16 right; 232 - } __packed; 233 - 234 - 235 - /* HFS directory info (stolen from hfs.h */ 236 - struct DInfo { 237 - struct hfsp_rect frRect; 238 - __be16 frFlags; 239 - struct hfsp_point frLocation; 240 - __be16 frView; 241 - } __packed; 242 - 243 - struct DXInfo { 244 - struct hfsp_point frScroll; 245 - __be32 frOpenChain; 246 - __be16 frUnused; 247 - __be16 frComment; 248 - __be32 frPutAway; 249 - } __packed; 250 - 251 - /* HFS+ folder data (part of an hfsplus_cat_entry) */ 252 - struct hfsplus_cat_folder { 253 - __be16 type; 254 - __be16 flags; 255 - __be32 valence; 256 - hfsplus_cnid id; 257 - __be32 create_date; 258 - __be32 content_mod_date; 259 - __be32 attribute_mod_date; 260 - __be32 access_date; 261 - __be32 backup_date; 262 - struct hfsplus_perm permissions; 263 - struct_group_attr(info, __packed, 264 - struct DInfo user_info; 265 - struct DXInfo finder_info; 266 - ); 267 - __be32 text_encoding; 268 - __be32 subfolders; /* Subfolder count in HFSX. Reserved in HFS+. */ 269 - } __packed; 270 - 271 - /* HFS file info (stolen from hfs.h) */ 272 - struct FInfo { 273 - __be32 fdType; 274 - __be32 fdCreator; 275 - __be16 fdFlags; 276 - struct hfsp_point fdLocation; 277 - __be16 fdFldr; 278 - } __packed; 279 - 280 - struct FXInfo { 281 - __be16 fdIconID; 282 - u8 fdUnused[8]; 283 - __be16 fdComment; 284 - __be32 fdPutAway; 285 - } __packed; 286 - 287 - /* HFS+ file data (part of a cat_entry) */ 288 - struct hfsplus_cat_file { 289 - __be16 type; 290 - __be16 flags; 291 - u32 reserved1; 292 - hfsplus_cnid id; 293 - __be32 create_date; 294 - __be32 content_mod_date; 295 - __be32 attribute_mod_date; 296 - __be32 access_date; 297 - __be32 backup_date; 298 - struct hfsplus_perm permissions; 299 - struct_group_attr(info, __packed, 300 - struct FInfo user_info; 301 - struct FXInfo finder_info; 302 - ); 303 - __be32 text_encoding; 304 - u32 reserved2; 305 - 306 - struct hfsplus_fork_raw data_fork; 307 - struct hfsplus_fork_raw rsrc_fork; 308 - } __packed; 309 - 310 - /* File and folder flag bits */ 311 - #define HFSPLUS_FILE_LOCKED 0x0001 312 - #define HFSPLUS_FILE_THREAD_EXISTS 0x0002 313 - #define HFSPLUS_XATTR_EXISTS 0x0004 314 - #define HFSPLUS_ACL_EXISTS 0x0008 315 - #define HFSPLUS_HAS_FOLDER_COUNT 0x0010 /* Folder has subfolder count 316 - * (HFSX only) */ 317 - 318 - /* HFS+ catalog thread (part of a cat_entry) */ 319 - struct hfsplus_cat_thread { 320 - __be16 type; 321 - s16 reserved; 322 - hfsplus_cnid parentID; 323 - struct hfsplus_unistr nodeName; 324 - } __packed; 325 - 326 - #define HFSPLUS_MIN_THREAD_SZ 10 327 - 328 - /* A data record in the catalog tree */ 329 - typedef union { 330 - __be16 type; 331 - struct hfsplus_cat_folder folder; 332 - struct hfsplus_cat_file file; 333 - struct hfsplus_cat_thread thread; 334 - } __packed hfsplus_cat_entry; 335 - 336 - /* HFS+ catalog entry type */ 337 - #define HFSPLUS_FOLDER 0x0001 338 - #define HFSPLUS_FILE 0x0002 339 - #define HFSPLUS_FOLDER_THREAD 0x0003 340 - #define HFSPLUS_FILE_THREAD 0x0004 341 - 342 - /* HFS+ extents tree key */ 343 - struct hfsplus_ext_key { 344 - __be16 key_len; 345 - u8 fork_type; 346 - u8 pad; 347 - hfsplus_cnid cnid; 348 - __be32 start_block; 349 - } __packed; 350 - 351 - #define HFSPLUS_EXT_KEYLEN sizeof(struct hfsplus_ext_key) 352 - 353 - #define HFSPLUS_XATTR_FINDER_INFO_NAME "com.apple.FinderInfo" 354 - #define HFSPLUS_XATTR_ACL_NAME "com.apple.system.Security" 355 - 356 - #define HFSPLUS_ATTR_INLINE_DATA 0x10 357 - #define HFSPLUS_ATTR_FORK_DATA 0x20 358 - #define HFSPLUS_ATTR_EXTENTS 0x30 359 - 360 - /* HFS+ attributes tree key */ 361 - struct hfsplus_attr_key { 362 - __be16 key_len; 363 - __be16 pad; 364 - hfsplus_cnid cnid; 365 - __be32 start_block; 366 - struct hfsplus_attr_unistr key_name; 367 - } __packed; 368 - 369 - #define HFSPLUS_ATTR_KEYLEN sizeof(struct hfsplus_attr_key) 370 - 371 - /* HFS+ fork data attribute */ 372 - struct hfsplus_attr_fork_data { 373 - __be32 record_type; 374 - __be32 reserved; 375 - struct hfsplus_fork_raw the_fork; 376 - } __packed; 377 - 378 - /* HFS+ extension attribute */ 379 - struct hfsplus_attr_extents { 380 - __be32 record_type; 381 - __be32 reserved; 382 - struct hfsplus_extent extents; 383 - } __packed; 384 - 385 - #define HFSPLUS_MAX_INLINE_DATA_SIZE 3802 386 - 387 - /* HFS+ attribute inline data */ 388 - struct hfsplus_attr_inline_data { 389 - __be32 record_type; 390 - __be32 reserved1; 391 - u8 reserved2[6]; 392 - __be16 length; 393 - u8 raw_bytes[HFSPLUS_MAX_INLINE_DATA_SIZE]; 394 - } __packed; 395 - 396 - /* A data record in the attributes tree */ 397 - typedef union { 398 - __be32 record_type; 399 - struct hfsplus_attr_fork_data fork_data; 400 - struct hfsplus_attr_extents extents; 401 - struct hfsplus_attr_inline_data inline_data; 402 - } __packed hfsplus_attr_entry; 403 - 404 - /* HFS+ generic BTree key */ 405 - typedef union { 406 - __be16 key_len; 407 - struct hfsplus_cat_key cat; 408 - struct hfsplus_ext_key ext; 409 - struct hfsplus_attr_key attr; 410 - } __packed hfsplus_btree_key; 18 + #include <linux/hfs_common.h> 411 19 412 20 #endif
+10 -12
fs/hfsplus/xattr.c
··· 265 265 struct hfs_find_data cat_fd; 266 266 hfsplus_cat_entry entry; 267 267 u16 cat_entry_flags, cat_entry_type; 268 - u16 folder_finderinfo_len = sizeof(struct DInfo) + 269 - sizeof(struct DXInfo); 270 - u16 file_finderinfo_len = sizeof(struct FInfo) + 271 - sizeof(struct FXInfo); 268 + u16 folder_finderinfo_len = sizeof(DInfo) + sizeof(DXInfo); 269 + u16 file_finderinfo_len = sizeof(FInfo) + sizeof(FXInfo); 272 270 273 271 if ((!S_ISREG(inode->i_mode) && 274 272 !S_ISDIR(inode->i_mode)) || ··· 442 444 ssize_t res = 0; 443 445 struct hfs_find_data fd; 444 446 u16 entry_type; 445 - u16 folder_rec_len = sizeof(struct DInfo) + sizeof(struct DXInfo); 446 - u16 file_rec_len = sizeof(struct FInfo) + sizeof(struct FXInfo); 447 + u16 folder_rec_len = sizeof(DInfo) + sizeof(DXInfo); 448 + u16 file_rec_len = sizeof(FInfo) + sizeof(FXInfo); 447 449 u16 record_len = max(folder_rec_len, file_rec_len); 448 - u8 folder_finder_info[sizeof(struct DInfo) + sizeof(struct DXInfo)]; 449 - u8 file_finder_info[sizeof(struct FInfo) + sizeof(struct FXInfo)]; 450 + u8 folder_finder_info[sizeof(DInfo) + sizeof(DXInfo)]; 451 + u8 file_finder_info[sizeof(FInfo) + sizeof(FXInfo)]; 450 452 451 453 if (size >= record_len) { 452 454 res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd); ··· 610 612 struct inode *inode = d_inode(dentry); 611 613 struct hfs_find_data fd; 612 614 u16 entry_type; 613 - u8 folder_finder_info[sizeof(struct DInfo) + sizeof(struct DXInfo)]; 614 - u8 file_finder_info[sizeof(struct FInfo) + sizeof(struct FXInfo)]; 615 + u8 folder_finder_info[sizeof(DInfo) + sizeof(DXInfo)]; 616 + u8 file_finder_info[sizeof(FInfo) + sizeof(FXInfo)]; 615 617 unsigned long len, found_bit; 616 618 int xattr_name_len, symbols_count; 617 619 ··· 627 629 628 630 entry_type = hfs_bnode_read_u16(fd.bnode, fd.entryoffset); 629 631 if (entry_type == HFSPLUS_FOLDER) { 630 - len = sizeof(struct DInfo) + sizeof(struct DXInfo); 632 + len = sizeof(DInfo) + sizeof(DXInfo); 631 633 hfs_bnode_read(fd.bnode, folder_finder_info, 632 634 fd.entryoffset + 633 635 offsetof(struct hfsplus_cat_folder, user_info), 634 636 len); 635 637 found_bit = find_first_bit((void *)folder_finder_info, len*8); 636 638 } else if (entry_type == HFSPLUS_FILE) { 637 - len = sizeof(struct FInfo) + sizeof(struct FXInfo); 639 + len = sizeof(FInfo) + sizeof(FXInfo); 638 640 hfs_bnode_read(fd.bnode, file_finder_info, 639 641 fd.entryoffset + 640 642 offsetof(struct hfsplus_cat_file, user_info),
+633
include/linux/hfs_common.h
··· 17 17 pr_debug("pid %d:%s:%d %s(): " fmt, \ 18 18 current->pid, __FILE__, __LINE__, __func__, ##__VA_ARGS__) \ 19 19 20 + /* 21 + * Format of structures on disk 22 + * Information taken from Apple Technote #1150 (HFS Plus Volume Format) 23 + */ 24 + 25 + /* offsets to various blocks */ 26 + #define HFS_DD_BLK 0 /* Driver Descriptor block */ 27 + #define HFS_PMAP_BLK 1 /* First block of partition map */ 28 + #define HFS_MDB_BLK 2 /* Block (w/i partition) of MDB */ 29 + 30 + /* magic numbers for various disk blocks */ 31 + #define HFS_DRVR_DESC_MAGIC 0x4552 /* "ER": driver descriptor map */ 32 + #define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */ 33 + #define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */ 34 + #define HFS_SUPER_MAGIC 0x4244 /* "BD": HFS MDB (super block) */ 35 + #define HFS_MFS_SUPER_MAGIC 0xD2D7 /* MFS MDB (super block) */ 36 + 37 + #define HFSPLUS_VOLHEAD_SIG 0x482b 38 + #define HFSPLUS_VOLHEAD_SIGX 0x4858 39 + #define HFSPLUS_SUPER_MAGIC 0x482b 40 + 41 + #define HFSP_WRAP_MAGIC 0x4244 42 + #define HFSP_WRAP_ATTRIB_SLOCK 0x8000 43 + #define HFSP_WRAP_ATTRIB_SPARED 0x0200 44 + 45 + #define HFSP_WRAPOFF_SIG 0x00 46 + #define HFSP_WRAPOFF_ATTRIB 0x0A 47 + #define HFSP_WRAPOFF_ABLKSIZE 0x14 48 + #define HFSP_WRAPOFF_ABLKSTART 0x1C 49 + #define HFSP_WRAPOFF_EMBEDSIG 0x7C 50 + #define HFSP_WRAPOFF_EMBEDEXT 0x7E 51 + 52 + #define HFSP_HARDLINK_TYPE 0x686c6e6b /* 'hlnk' */ 53 + #define HFSP_HFSPLUS_CREATOR 0x6866732b /* 'hfs+' */ 54 + 55 + #define HFSP_SYMLINK_TYPE 0x736c6e6b /* 'slnk' */ 56 + #define HFSP_SYMLINK_CREATOR 0x72686170 /* 'rhap' */ 57 + 58 + #define HFSP_MOUNT_VERSION 0x482b4c78 /* 'H+Lx' */ 59 + 60 + #define HFSP_HIDDENDIR_NAME \ 61 + "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data" 62 + 63 + /* various FIXED size parameters */ 64 + #define HFS_SECTOR_SIZE 512 /* size of an HFS sector */ 65 + #define HFS_SECTOR_SIZE_BITS 9 /* log_2(HFS_SECTOR_SIZE) */ 66 + #define HFS_MAX_VALENCE 32767U 67 + 68 + #define HFSPLUS_SECTOR_SIZE HFS_SECTOR_SIZE 69 + #define HFSPLUS_SECTOR_SHIFT HFS_SECTOR_SIZE_BITS 70 + #define HFSPLUS_VOLHEAD_SECTOR 2 71 + #define HFSPLUS_MIN_VERSION 4 72 + #define HFSPLUS_CURRENT_VERSION 5 73 + 74 + #define HFS_NAMELEN 31 /* maximum length of an HFS filename */ 75 + #define HFS_MAX_NAMELEN 128 76 + 77 + #define HFSPLUS_MAX_STRLEN 255 78 + #define HFSPLUS_ATTR_MAX_STRLEN 127 79 + 80 + /* Meanings of the drAtrb field of the MDB, 81 + * Reference: _Inside Macintosh: Files_ p. 2-61 82 + */ 83 + #define HFS_SB_ATTRIB_HLOCK (1 << 7) 84 + #define HFS_SB_ATTRIB_UNMNT (1 << 8) 85 + #define HFS_SB_ATTRIB_SPARED (1 << 9) 86 + #define HFS_SB_ATTRIB_INCNSTNT (1 << 11) 87 + #define HFS_SB_ATTRIB_SLOCK (1 << 15) 88 + 89 + /* values for hfs_cat_rec.cdrType */ 90 + #define HFS_CDR_DIR 0x01 /* folder (directory) */ 91 + #define HFS_CDR_FIL 0x02 /* file */ 92 + #define HFS_CDR_THD 0x03 /* folder (directory) thread */ 93 + #define HFS_CDR_FTH 0x04 /* file thread */ 94 + 95 + /* legal values for hfs_ext_key.FkType and hfs_file.fork */ 96 + #define HFS_FK_DATA 0x00 97 + #define HFS_FK_RSRC 0xFF 98 + 99 + /* bits in hfs_fil_entry.Flags */ 100 + #define HFS_FIL_LOCK 0x01 /* locked */ 101 + #define HFS_FIL_THD 0x02 /* file thread */ 102 + #define HFS_FIL_DOPEN 0x04 /* data fork open */ 103 + #define HFS_FIL_ROPEN 0x08 /* resource fork open */ 104 + #define HFS_FIL_DIR 0x10 /* directory (always clear) */ 105 + #define HFS_FIL_NOCOPY 0x40 /* copy-protected file */ 106 + #define HFS_FIL_USED 0x80 /* open */ 107 + 108 + /* bits in hfs_dir_entry.Flags. dirflags is 16 bits. */ 109 + #define HFS_DIR_LOCK 0x01 /* locked */ 110 + #define HFS_DIR_THD 0x02 /* directory thread */ 111 + #define HFS_DIR_INEXPFOLDER 0x04 /* in a shared area */ 112 + #define HFS_DIR_MOUNTED 0x08 /* mounted */ 113 + #define HFS_DIR_DIR 0x10 /* directory (always set) */ 114 + #define HFS_DIR_EXPFOLDER 0x20 /* share point */ 115 + 116 + /* bits hfs_finfo.fdFlags */ 117 + #define HFS_FLG_INITED 0x0100 118 + #define HFS_FLG_LOCKED 0x1000 119 + #define HFS_FLG_INVISIBLE 0x4000 120 + 121 + /* Some special File ID numbers */ 122 + #define HFS_POR_CNID 1 /* Parent Of the Root */ 123 + #define HFSPLUS_POR_CNID HFS_POR_CNID 124 + #define HFS_ROOT_CNID 2 /* ROOT directory */ 125 + #define HFSPLUS_ROOT_CNID HFS_ROOT_CNID 126 + #define HFS_EXT_CNID 3 /* EXTents B-tree */ 127 + #define HFSPLUS_EXT_CNID HFS_EXT_CNID 128 + #define HFS_CAT_CNID 4 /* CATalog B-tree */ 129 + #define HFSPLUS_CAT_CNID HFS_CAT_CNID 130 + #define HFS_BAD_CNID 5 /* BAD blocks file */ 131 + #define HFSPLUS_BAD_CNID HFS_BAD_CNID 132 + #define HFS_ALLOC_CNID 6 /* ALLOCation file (HFS+) */ 133 + #define HFSPLUS_ALLOC_CNID HFS_ALLOC_CNID 134 + #define HFS_START_CNID 7 /* STARTup file (HFS+) */ 135 + #define HFSPLUS_START_CNID HFS_START_CNID 136 + #define HFS_ATTR_CNID 8 /* ATTRibutes file (HFS+) */ 137 + #define HFSPLUS_ATTR_CNID HFS_ATTR_CNID 138 + #define HFS_EXCH_CNID 15 /* ExchangeFiles temp id */ 139 + #define HFSPLUS_EXCH_CNID HFS_EXCH_CNID 140 + #define HFS_FIRSTUSER_CNID 16 /* first available user id */ 141 + #define HFSPLUS_FIRSTUSER_CNID HFS_FIRSTUSER_CNID 142 + 143 + /*======== HFS/HFS+ structures as they appear on the disk ========*/ 144 + 145 + typedef __be32 hfsplus_cnid; 146 + typedef __be16 hfsplus_unichr; 147 + 148 + /* Pascal-style string of up to 31 characters */ 149 + struct hfs_name { 150 + u8 len; 151 + u8 name[HFS_NAMELEN]; 152 + } __packed; 153 + 154 + /* A "string" as used in filenames, etc. */ 155 + struct hfsplus_unistr { 156 + __be16 length; 157 + hfsplus_unichr unicode[HFSPLUS_MAX_STRLEN]; 158 + } __packed; 159 + 160 + /* 161 + * A "string" is used in attributes file 162 + * for name of extended attribute 163 + */ 164 + struct hfsplus_attr_unistr { 165 + __be16 length; 166 + hfsplus_unichr unicode[HFSPLUS_ATTR_MAX_STRLEN]; 167 + } __packed; 168 + 169 + struct hfs_extent { 170 + __be16 block; 171 + __be16 count; 172 + }; 173 + typedef struct hfs_extent hfs_extent_rec[3]; 174 + 175 + /* A single contiguous area of a file */ 176 + struct hfsplus_extent { 177 + __be32 start_block; 178 + __be32 block_count; 179 + } __packed; 180 + typedef struct hfsplus_extent hfsplus_extent_rec[8]; 181 + 182 + /* Information for a "Fork" in a file */ 183 + struct hfsplus_fork_raw { 184 + __be64 total_size; 185 + __be32 clump_size; 186 + __be32 total_blocks; 187 + hfsplus_extent_rec extents; 188 + } __packed; 189 + 190 + struct hfs_mdb { 191 + __be16 drSigWord; /* Signature word indicating fs type */ 192 + __be32 drCrDate; /* fs creation date/time */ 193 + __be32 drLsMod; /* fs modification date/time */ 194 + __be16 drAtrb; /* fs attributes */ 195 + __be16 drNmFls; /* number of files in root directory */ 196 + __be16 drVBMSt; /* location (in 512-byte blocks) 197 + of the volume bitmap */ 198 + __be16 drAllocPtr; /* location (in allocation blocks) 199 + to begin next allocation search */ 200 + __be16 drNmAlBlks; /* number of allocation blocks */ 201 + __be32 drAlBlkSiz; /* bytes in an allocation block */ 202 + __be32 drClpSiz; /* clumpsize, the number of bytes to 203 + allocate when extending a file */ 204 + __be16 drAlBlSt; /* location (in 512-byte blocks) 205 + of the first allocation block */ 206 + __be32 drNxtCNID; /* CNID to assign to the next 207 + file or directory created */ 208 + __be16 drFreeBks; /* number of free allocation blocks */ 209 + u8 drVN[28]; /* the volume label */ 210 + __be32 drVolBkUp; /* fs backup date/time */ 211 + __be16 drVSeqNum; /* backup sequence number */ 212 + __be32 drWrCnt; /* fs write count */ 213 + __be32 drXTClpSiz; /* clumpsize for the extents B-tree */ 214 + __be32 drCTClpSiz; /* clumpsize for the catalog B-tree */ 215 + __be16 drNmRtDirs; /* number of directories in 216 + the root directory */ 217 + __be32 drFilCnt; /* number of files in the fs */ 218 + __be32 drDirCnt; /* number of directories in the fs */ 219 + u8 drFndrInfo[32]; /* data used by the Finder */ 220 + __be16 drEmbedSigWord; /* embedded volume signature */ 221 + __be32 drEmbedExtent; /* starting block number (xdrStABN) 222 + and number of allocation blocks 223 + (xdrNumABlks) occupied by embedded 224 + volume */ 225 + __be32 drXTFlSize; /* bytes in the extents B-tree */ 226 + hfs_extent_rec drXTExtRec; /* extents B-tree's first 3 extents */ 227 + __be32 drCTFlSize; /* bytes in the catalog B-tree */ 228 + hfs_extent_rec drCTExtRec; /* catalog B-tree's first 3 extents */ 229 + } __packed; 230 + 231 + /* HFS+ Volume Header */ 232 + struct hfsplus_vh { 233 + __be16 signature; 234 + __be16 version; 235 + __be32 attributes; 236 + __be32 last_mount_vers; 237 + u32 reserved; 238 + 239 + __be32 create_date; 240 + __be32 modify_date; 241 + __be32 backup_date; 242 + __be32 checked_date; 243 + 244 + __be32 file_count; 245 + __be32 folder_count; 246 + 247 + __be32 blocksize; 248 + __be32 total_blocks; 249 + __be32 free_blocks; 250 + 251 + __be32 next_alloc; 252 + __be32 rsrc_clump_sz; 253 + __be32 data_clump_sz; 254 + hfsplus_cnid next_cnid; 255 + 256 + __be32 write_count; 257 + __be64 encodings_bmp; 258 + 259 + u32 finder_info[8]; 260 + 261 + struct hfsplus_fork_raw alloc_file; 262 + struct hfsplus_fork_raw ext_file; 263 + struct hfsplus_fork_raw cat_file; 264 + struct hfsplus_fork_raw attr_file; 265 + struct hfsplus_fork_raw start_file; 266 + } __packed; 267 + 268 + /* HFS+ volume attributes */ 269 + #define HFSPLUS_VOL_UNMNT (1 << 8) 270 + #define HFSPLUS_VOL_SPARE_BLK (1 << 9) 271 + #define HFSPLUS_VOL_NOCACHE (1 << 10) 272 + #define HFSPLUS_VOL_INCNSTNT (1 << 11) 273 + #define HFSPLUS_VOL_NODEID_REUSED (1 << 12) 274 + #define HFSPLUS_VOL_JOURNALED (1 << 13) 275 + #define HFSPLUS_VOL_SOFTLOCK (1 << 15) 276 + #define HFSPLUS_VOL_UNUSED_NODE_FIX (1 << 31) 277 + 278 + struct hfs_point { 279 + __be16 v; 280 + __be16 h; 281 + } __packed; 282 + 283 + typedef struct hfs_point hfsp_point; 284 + 285 + struct hfs_rect { 286 + __be16 top; 287 + __be16 left; 288 + __be16 bottom; 289 + __be16 right; 290 + } __packed; 291 + 292 + typedef struct hfs_rect hfsp_rect; 293 + 294 + struct hfs_finfo { 295 + __be32 fdType; 296 + __be32 fdCreator; 297 + __be16 fdFlags; 298 + struct hfs_point fdLocation; 299 + __be16 fdFldr; 300 + } __packed; 301 + 302 + typedef struct hfs_finfo FInfo; 303 + 304 + struct hfs_fxinfo { 305 + __be16 fdIconID; 306 + u8 fdUnused[8]; 307 + __be16 fdComment; 308 + __be32 fdPutAway; 309 + } __packed; 310 + 311 + typedef struct hfs_fxinfo FXInfo; 312 + 313 + struct hfs_dinfo { 314 + struct hfs_rect frRect; 315 + __be16 frFlags; 316 + struct hfs_point frLocation; 317 + __be16 frView; 318 + } __packed; 319 + 320 + typedef struct hfs_dinfo DInfo; 321 + 322 + struct hfs_dxinfo { 323 + struct hfs_point frScroll; 324 + __be32 frOpenChain; 325 + __be16 frUnused; 326 + __be16 frComment; 327 + __be32 frPutAway; 328 + } __packed; 329 + 330 + typedef struct hfs_dxinfo DXInfo; 331 + 332 + union hfs_finder_info { 333 + struct { 334 + struct hfs_finfo finfo; 335 + struct hfs_fxinfo fxinfo; 336 + } file; 337 + struct { 338 + struct hfs_dinfo dinfo; 339 + struct hfs_dxinfo dxinfo; 340 + } dir; 341 + } __packed; 342 + 343 + /* The key used in the catalog b-tree: */ 344 + struct hfs_cat_key { 345 + u8 key_len; /* number of bytes in the key */ 346 + u8 reserved; /* padding */ 347 + __be32 ParID; /* CNID of the parent dir */ 348 + struct hfs_name CName; /* The filename of the entry */ 349 + } __packed; 350 + 351 + /* HFS+ catalog entry key */ 352 + struct hfsplus_cat_key { 353 + __be16 key_len; 354 + hfsplus_cnid parent; 355 + struct hfsplus_unistr name; 356 + } __packed; 357 + 358 + #define HFSPLUS_CAT_KEYLEN (sizeof(struct hfsplus_cat_key)) 359 + 360 + /* The key used in the extents b-tree: */ 361 + struct hfs_ext_key { 362 + u8 key_len; /* number of bytes in the key */ 363 + u8 FkType; /* HFS_FK_{DATA,RSRC} */ 364 + __be32 FNum; /* The File ID of the file */ 365 + __be16 FABN; /* allocation blocks number*/ 366 + } __packed; 367 + 368 + /* HFS+ extents tree key */ 369 + struct hfsplus_ext_key { 370 + __be16 key_len; 371 + u8 fork_type; 372 + u8 pad; 373 + hfsplus_cnid cnid; 374 + __be32 start_block; 375 + } __packed; 376 + 377 + #define HFSPLUS_EXT_KEYLEN sizeof(struct hfsplus_ext_key) 378 + 379 + typedef union hfs_btree_key { 380 + u8 key_len; /* number of bytes in the key */ 381 + struct hfs_cat_key cat; 382 + struct hfs_ext_key ext; 383 + } hfs_btree_key; 384 + 385 + #define HFS_MAX_CAT_KEYLEN (sizeof(struct hfs_cat_key) - sizeof(u8)) 386 + #define HFS_MAX_EXT_KEYLEN (sizeof(struct hfs_ext_key) - sizeof(u8)) 387 + 388 + typedef union hfs_btree_key btree_key; 389 + 390 + /* The catalog record for a file */ 391 + struct hfs_cat_file { 392 + s8 type; /* The type of entry */ 393 + u8 reserved; 394 + u8 Flags; /* Flags such as read-only */ 395 + s8 Typ; /* file version number = 0 */ 396 + struct hfs_finfo UsrWds; /* data used by the Finder */ 397 + __be32 FlNum; /* The CNID */ 398 + __be16 StBlk; /* obsolete */ 399 + __be32 LgLen; /* The logical EOF of the data fork*/ 400 + __be32 PyLen; /* The physical EOF of the data fork */ 401 + __be16 RStBlk; /* obsolete */ 402 + __be32 RLgLen; /* The logical EOF of the rsrc fork */ 403 + __be32 RPyLen; /* The physical EOF of the rsrc fork */ 404 + __be32 CrDat; /* The creation date */ 405 + __be32 MdDat; /* The modified date */ 406 + __be32 BkDat; /* The last backup date */ 407 + struct hfs_fxinfo FndrInfo; /* more data for the Finder */ 408 + __be16 ClpSize; /* number of bytes to allocate 409 + when extending files */ 410 + hfs_extent_rec ExtRec; /* first extent record 411 + for the data fork */ 412 + hfs_extent_rec RExtRec; /* first extent record 413 + for the resource fork */ 414 + u32 Resrv; /* reserved by Apple */ 415 + } __packed; 416 + 417 + /* the catalog record for a directory */ 418 + struct hfs_cat_dir { 419 + s8 type; /* The type of entry */ 420 + u8 reserved; 421 + __be16 Flags; /* flags */ 422 + __be16 Val; /* Valence: number of files and 423 + dirs in the directory */ 424 + __be32 DirID; /* The CNID */ 425 + __be32 CrDat; /* The creation date */ 426 + __be32 MdDat; /* The modification date */ 427 + __be32 BkDat; /* The last backup date */ 428 + struct hfs_dinfo UsrInfo; /* data used by the Finder */ 429 + struct hfs_dxinfo FndrInfo; /* more data used by Finder */ 430 + u8 Resrv[16]; /* reserved by Apple */ 431 + } __packed; 432 + 433 + /* the catalog record for a thread */ 434 + struct hfs_cat_thread { 435 + s8 type; /* The type of entry */ 436 + u8 reserved[9]; /* reserved by Apple */ 437 + __be32 ParID; /* CNID of parent directory */ 438 + struct hfs_name CName; /* The name of this entry */ 439 + } __packed; 440 + 441 + /* A catalog tree record */ 442 + typedef union hfs_cat_rec { 443 + s8 type; /* The type of entry */ 444 + struct hfs_cat_file file; 445 + struct hfs_cat_dir dir; 446 + struct hfs_cat_thread thread; 447 + } hfs_cat_rec; 448 + 449 + /* POSIX permissions */ 450 + struct hfsplus_perm { 451 + __be32 owner; 452 + __be32 group; 453 + u8 rootflags; 454 + u8 userflags; 455 + __be16 mode; 456 + __be32 dev; 457 + } __packed; 458 + 459 + #define HFSPLUS_FLG_NODUMP 0x01 460 + #define HFSPLUS_FLG_IMMUTABLE 0x02 461 + #define HFSPLUS_FLG_APPEND 0x04 462 + 463 + /* HFS/HFS+ BTree node descriptor */ 464 + struct hfs_bnode_desc { 465 + __be32 next; /* (V) Number of the next node at this level */ 466 + __be32 prev; /* (V) Number of the prev node at this level */ 467 + u8 type; /* (F) The type of node */ 468 + u8 height; /* (F) The level of this node (leaves=1) */ 469 + __be16 num_recs; /* (V) The number of records in this node */ 470 + u16 reserved; 471 + } __packed; 472 + 473 + /* HFS/HFS+ BTree node types */ 474 + #define HFS_NODE_INDEX 0x00 /* An internal (index) node */ 475 + #define HFS_NODE_HEADER 0x01 /* The tree header node (node 0) */ 476 + #define HFS_NODE_MAP 0x02 /* Holds part of the bitmap of used nodes */ 477 + #define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */ 478 + 479 + /* HFS/HFS+ BTree header */ 480 + struct hfs_btree_header_rec { 481 + __be16 depth; /* (V) The number of levels in this B-tree */ 482 + __be32 root; /* (V) The node number of the root node */ 483 + __be32 leaf_count; /* (V) The number of leaf records */ 484 + __be32 leaf_head; /* (V) The number of the first leaf node */ 485 + __be32 leaf_tail; /* (V) The number of the last leaf node */ 486 + __be16 node_size; /* (F) The number of bytes in a node (=512) */ 487 + __be16 max_key_len; /* (F) The length of a key in an index node */ 488 + __be32 node_count; /* (V) The total number of nodes */ 489 + __be32 free_nodes; /* (V) The number of unused nodes */ 490 + u16 reserved1; 491 + __be32 clump_size; /* (F) clump size. not usually used. */ 492 + u8 btree_type; /* (F) BTree type */ 493 + u8 key_type; 494 + __be32 attributes; /* (F) attributes */ 495 + u32 reserved3[16]; 496 + } __packed; 497 + 498 + /* BTree attributes */ 499 + #define BTREE_ATTR_BADCLOSE 0x00000001 /* b-tree not closed properly. not 500 + used by hfsplus. */ 501 + #define HFS_TREE_BIGKEYS 0x00000002 /* key length is u16 instead of u8. 502 + used by hfsplus. */ 503 + #define HFS_TREE_VARIDXKEYS 0x00000004 /* variable key length instead of 504 + max key length. use din catalog 505 + b-tree but not in extents 506 + b-tree (hfsplus). */ 507 + 508 + /* HFS+ BTree misc info */ 509 + #define HFSPLUS_TREE_HEAD 0 510 + #define HFSPLUS_NODE_MXSZ 32768 511 + #define HFSPLUS_ATTR_TREE_NODE_SIZE 8192 512 + #define HFSPLUS_BTREE_HDR_NODE_RECS_COUNT 3 513 + #define HFSPLUS_BTREE_HDR_USER_BYTES 128 514 + 515 + /* btree key type */ 516 + #define HFSPLUS_KEY_CASEFOLDING 0xCF /* case-insensitive */ 517 + #define HFSPLUS_KEY_BINARY 0xBC /* case-sensitive */ 518 + 519 + /* HFS+ folder data (part of an hfsplus_cat_entry) */ 520 + struct hfsplus_cat_folder { 521 + __be16 type; 522 + __be16 flags; 523 + __be32 valence; 524 + hfsplus_cnid id; 525 + __be32 create_date; 526 + __be32 content_mod_date; 527 + __be32 attribute_mod_date; 528 + __be32 access_date; 529 + __be32 backup_date; 530 + struct hfsplus_perm permissions; 531 + struct_group_attr(info, __packed, 532 + DInfo user_info; 533 + DXInfo finder_info; 534 + ); 535 + __be32 text_encoding; 536 + __be32 subfolders; /* Subfolder count in HFSX. Reserved in HFS+. */ 537 + } __packed; 538 + 539 + /* HFS+ file data (part of a cat_entry) */ 540 + struct hfsplus_cat_file { 541 + __be16 type; 542 + __be16 flags; 543 + u32 reserved1; 544 + hfsplus_cnid id; 545 + __be32 create_date; 546 + __be32 content_mod_date; 547 + __be32 attribute_mod_date; 548 + __be32 access_date; 549 + __be32 backup_date; 550 + struct hfsplus_perm permissions; 551 + struct_group_attr(info, __packed, 552 + FInfo user_info; 553 + FXInfo finder_info; 554 + ); 555 + __be32 text_encoding; 556 + u32 reserved2; 557 + 558 + struct hfsplus_fork_raw data_fork; 559 + struct hfsplus_fork_raw rsrc_fork; 560 + } __packed; 561 + 562 + /* File and folder flag bits */ 563 + #define HFSPLUS_FILE_LOCKED 0x0001 564 + #define HFSPLUS_FILE_THREAD_EXISTS 0x0002 565 + #define HFSPLUS_XATTR_EXISTS 0x0004 566 + #define HFSPLUS_ACL_EXISTS 0x0008 567 + #define HFSPLUS_HAS_FOLDER_COUNT 0x0010 /* Folder has subfolder count 568 + * (HFSX only) */ 569 + 570 + /* HFS+ catalog thread (part of a cat_entry) */ 571 + struct hfsplus_cat_thread { 572 + __be16 type; 573 + s16 reserved; 574 + hfsplus_cnid parentID; 575 + struct hfsplus_unistr nodeName; 576 + } __packed; 577 + 578 + #define HFSPLUS_MIN_THREAD_SZ 10 579 + 580 + /* A data record in the catalog tree */ 581 + typedef union { 582 + __be16 type; 583 + struct hfsplus_cat_folder folder; 584 + struct hfsplus_cat_file file; 585 + struct hfsplus_cat_thread thread; 586 + } __packed hfsplus_cat_entry; 587 + 588 + /* HFS+ catalog entry type */ 589 + #define HFSPLUS_FOLDER 0x0001 590 + #define HFSPLUS_FILE 0x0002 591 + #define HFSPLUS_FOLDER_THREAD 0x0003 592 + #define HFSPLUS_FILE_THREAD 0x0004 593 + 594 + #define HFSPLUS_XATTR_FINDER_INFO_NAME "com.apple.FinderInfo" 595 + #define HFSPLUS_XATTR_ACL_NAME "com.apple.system.Security" 596 + 597 + #define HFSPLUS_ATTR_INLINE_DATA 0x10 598 + #define HFSPLUS_ATTR_FORK_DATA 0x20 599 + #define HFSPLUS_ATTR_EXTENTS 0x30 600 + 601 + /* HFS+ attributes tree key */ 602 + struct hfsplus_attr_key { 603 + __be16 key_len; 604 + __be16 pad; 605 + hfsplus_cnid cnid; 606 + __be32 start_block; 607 + struct hfsplus_attr_unistr key_name; 608 + } __packed; 609 + 610 + #define HFSPLUS_ATTR_KEYLEN sizeof(struct hfsplus_attr_key) 611 + 612 + /* HFS+ fork data attribute */ 613 + struct hfsplus_attr_fork_data { 614 + __be32 record_type; 615 + __be32 reserved; 616 + struct hfsplus_fork_raw the_fork; 617 + } __packed; 618 + 619 + /* HFS+ extension attribute */ 620 + struct hfsplus_attr_extents { 621 + __be32 record_type; 622 + __be32 reserved; 623 + struct hfsplus_extent extents; 624 + } __packed; 625 + 626 + #define HFSPLUS_MAX_INLINE_DATA_SIZE 3802 627 + 628 + /* HFS+ attribute inline data */ 629 + struct hfsplus_attr_inline_data { 630 + __be32 record_type; 631 + __be32 reserved1; 632 + u8 reserved2[6]; 633 + __be16 length; 634 + u8 raw_bytes[HFSPLUS_MAX_INLINE_DATA_SIZE]; 635 + } __packed; 636 + 637 + /* A data record in the attributes tree */ 638 + typedef union { 639 + __be32 record_type; 640 + struct hfsplus_attr_fork_data fork_data; 641 + struct hfsplus_attr_extents extents; 642 + struct hfsplus_attr_inline_data inline_data; 643 + } __packed hfsplus_attr_entry; 644 + 645 + /* HFS+ generic BTree key */ 646 + typedef union { 647 + __be16 key_len; 648 + struct hfsplus_cat_key cat; 649 + struct hfsplus_ext_key ext; 650 + struct hfsplus_attr_key attr; 651 + } __packed hfsplus_btree_key; 652 + 20 653 #endif /* _HFS_COMMON_H_ */