Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/hfsplus_fs.h |
| 3 | * |
| 4 | * Copyright (C) 1999 |
| 5 | * Brad Boyer (flar@pants.nu) |
| 6 | * (C) 2003 Ardis Technologies <roman@ardistech.com> |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef _LINUX_HFSPLUS_FS_H |
| 11 | #define _LINUX_HFSPLUS_FS_H |
| 12 | |
| 13 | #include <linux/fs.h> |
Matthias Kaehlcke | 895c23f | 2008-07-25 01:46:36 -0700 | [diff] [blame] | 14 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/buffer_head.h> |
| 16 | #include "hfsplus_raw.h" |
| 17 | |
| 18 | #define DBG_BNODE_REFS 0x00000001 |
| 19 | #define DBG_BNODE_MOD 0x00000002 |
| 20 | #define DBG_CAT_MOD 0x00000004 |
| 21 | #define DBG_INODE 0x00000008 |
| 22 | #define DBG_SUPER 0x00000010 |
| 23 | #define DBG_EXTENT 0x00000020 |
| 24 | #define DBG_BITMAP 0x00000040 |
| 25 | |
| 26 | //#define DBG_MASK (DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD) |
| 27 | //#define DBG_MASK (DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE) |
| 28 | //#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT) |
| 29 | #define DBG_MASK (0) |
| 30 | |
| 31 | #define dprint(flg, fmt, args...) \ |
| 32 | if (flg & DBG_MASK) printk(fmt , ## args) |
| 33 | |
| 34 | /* Runtime config options */ |
| 35 | #define HFSPLUS_DEF_CR_TYPE 0x3F3F3F3F /* '????' */ |
| 36 | |
| 37 | #define HFSPLUS_TYPE_DATA 0x00 |
| 38 | #define HFSPLUS_TYPE_RSRC 0xFF |
| 39 | |
David Elliott | 2179d37 | 2006-01-18 17:43:08 -0800 | [diff] [blame] | 40 | typedef int (*btree_keycmp)(const hfsplus_btree_key *, const hfsplus_btree_key *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | #define NODE_HASH_SIZE 256 |
| 43 | |
| 44 | /* An HFS+ BTree held in memory */ |
| 45 | struct hfs_btree { |
| 46 | struct super_block *sb; |
| 47 | struct inode *inode; |
| 48 | btree_keycmp keycmp; |
| 49 | |
| 50 | u32 cnid; |
| 51 | u32 root; |
| 52 | u32 leaf_count; |
| 53 | u32 leaf_head; |
| 54 | u32 leaf_tail; |
| 55 | u32 node_count; |
| 56 | u32 free_nodes; |
| 57 | u32 attributes; |
| 58 | |
| 59 | unsigned int node_size; |
| 60 | unsigned int node_size_shift; |
| 61 | unsigned int max_key_len; |
| 62 | unsigned int depth; |
| 63 | |
| 64 | //unsigned int map1_size, map_size; |
| 65 | struct semaphore tree_lock; |
| 66 | |
| 67 | unsigned int pages_per_bnode; |
| 68 | spinlock_t hash_lock; |
| 69 | struct hfs_bnode *node_hash[NODE_HASH_SIZE]; |
| 70 | int node_hash_cnt; |
| 71 | }; |
| 72 | |
| 73 | struct page; |
| 74 | |
| 75 | /* An HFS+ BTree node in memory */ |
| 76 | struct hfs_bnode { |
| 77 | struct hfs_btree *tree; |
| 78 | |
| 79 | u32 prev; |
| 80 | u32 this; |
| 81 | u32 next; |
| 82 | u32 parent; |
| 83 | |
| 84 | u16 num_recs; |
| 85 | u8 type; |
| 86 | u8 height; |
| 87 | |
| 88 | struct hfs_bnode *next_hash; |
| 89 | unsigned long flags; |
| 90 | wait_queue_head_t lock_wq; |
| 91 | atomic_t refcnt; |
| 92 | unsigned int page_offset; |
| 93 | struct page *page[0]; |
| 94 | }; |
| 95 | |
| 96 | #define HFS_BNODE_LOCK 0 |
| 97 | #define HFS_BNODE_ERROR 1 |
| 98 | #define HFS_BNODE_NEW 2 |
| 99 | #define HFS_BNODE_DIRTY 3 |
| 100 | #define HFS_BNODE_DELETED 4 |
| 101 | |
| 102 | /* |
| 103 | * HFS+ superblock info (built from Volume Header on disk) |
| 104 | */ |
| 105 | |
| 106 | struct hfsplus_vh; |
| 107 | struct hfs_btree; |
| 108 | |
| 109 | struct hfsplus_sb_info { |
| 110 | struct buffer_head *s_vhbh; |
| 111 | struct hfsplus_vh *s_vhdr; |
| 112 | struct hfs_btree *ext_tree; |
| 113 | struct hfs_btree *cat_tree; |
| 114 | struct hfs_btree *attr_tree; |
| 115 | struct inode *alloc_file; |
| 116 | struct inode *hidden_dir; |
| 117 | struct nls_table *nls; |
| 118 | |
| 119 | /* Runtime variables */ |
| 120 | u32 blockoffset; |
| 121 | u32 sect_count; |
| 122 | int fs_shift; |
| 123 | |
| 124 | /* Stuff in host order from Vol Header */ |
| 125 | u32 alloc_blksz; |
| 126 | int alloc_blksz_shift; |
| 127 | u32 total_blocks; |
| 128 | u32 free_blocks; |
| 129 | u32 next_alloc; |
| 130 | u32 next_cnid; |
| 131 | u32 file_count; |
| 132 | u32 folder_count; |
| 133 | u32 data_clump_blocks, rsrc_clump_blocks; |
| 134 | |
| 135 | /* Config options */ |
| 136 | u32 creator; |
| 137 | u32 type; |
| 138 | |
| 139 | umode_t umask; |
| 140 | uid_t uid; |
| 141 | gid_t gid; |
| 142 | |
| 143 | int part, session; |
| 144 | |
| 145 | unsigned long flags; |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | struct hlist_head rsrc_inodes; |
| 148 | }; |
| 149 | |
| 150 | #define HFSPLUS_SB_WRITEBACKUP 0x0001 |
| 151 | #define HFSPLUS_SB_NODECOMPOSE 0x0002 |
Roman Zippel | b0b623c | 2005-11-29 19:34:41 -0800 | [diff] [blame] | 152 | #define HFSPLUS_SB_FORCE 0x0004 |
David Elliott | 2179d37 | 2006-01-18 17:43:08 -0800 | [diff] [blame] | 153 | #define HFSPLUS_SB_HFSX 0x0008 |
Duane Griffin | d45bce8 | 2007-07-15 23:41:23 -0700 | [diff] [blame] | 154 | #define HFSPLUS_SB_CASEFOLD 0x0010 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
| 156 | |
| 157 | struct hfsplus_inode_info { |
Matthias Kaehlcke | 895c23f | 2008-07-25 01:46:36 -0700 | [diff] [blame] | 158 | struct mutex extents_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | u32 clump_blocks, alloc_blocks; |
| 160 | sector_t fs_blocks; |
| 161 | /* Allocation extents from catalog record or volume header */ |
| 162 | hfsplus_extent_rec first_extents; |
| 163 | u32 first_blocks; |
| 164 | hfsplus_extent_rec cached_extents; |
| 165 | u32 cached_start, cached_blocks; |
| 166 | atomic_t opencnt; |
| 167 | |
| 168 | struct inode *rsrc_inode; |
| 169 | unsigned long flags; |
| 170 | |
Roman Zippel | 9a4cad9 | 2006-01-18 17:43:09 -0800 | [diff] [blame] | 171 | __be32 create_date; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | /* Device number in hfsplus_permissions in catalog */ |
| 173 | u32 dev; |
| 174 | /* BSD system and user file flags */ |
| 175 | u8 rootflags; |
| 176 | u8 userflags; |
| 177 | |
| 178 | struct list_head open_dir_list; |
| 179 | loff_t phys_size; |
| 180 | struct inode vfs_inode; |
| 181 | }; |
| 182 | |
| 183 | #define HFSPLUS_FLG_RSRC 0x0001 |
| 184 | #define HFSPLUS_FLG_EXT_DIRTY 0x0002 |
| 185 | #define HFSPLUS_FLG_EXT_NEW 0x0004 |
| 186 | |
| 187 | #define HFSPLUS_IS_DATA(inode) (!(HFSPLUS_I(inode).flags & HFSPLUS_FLG_RSRC)) |
| 188 | #define HFSPLUS_IS_RSRC(inode) (HFSPLUS_I(inode).flags & HFSPLUS_FLG_RSRC) |
| 189 | |
| 190 | struct hfs_find_data { |
| 191 | /* filled by caller */ |
| 192 | hfsplus_btree_key *search_key; |
| 193 | hfsplus_btree_key *key; |
| 194 | /* filled by find */ |
| 195 | struct hfs_btree *tree; |
| 196 | struct hfs_bnode *bnode; |
| 197 | /* filled by findrec */ |
| 198 | int record; |
| 199 | int keyoffset, keylength; |
| 200 | int entryoffset, entrylength; |
| 201 | }; |
| 202 | |
| 203 | struct hfsplus_readdir_data { |
| 204 | struct list_head list; |
| 205 | struct file *file; |
| 206 | struct hfsplus_cat_key key; |
| 207 | }; |
| 208 | |
| 209 | #define hfs_btree_open hfsplus_btree_open |
| 210 | #define hfs_btree_close hfsplus_btree_close |
| 211 | #define hfs_btree_write hfsplus_btree_write |
| 212 | #define hfs_bmap_alloc hfsplus_bmap_alloc |
| 213 | #define hfs_bmap_free hfsplus_bmap_free |
| 214 | #define hfs_bnode_read hfsplus_bnode_read |
| 215 | #define hfs_bnode_read_u16 hfsplus_bnode_read_u16 |
| 216 | #define hfs_bnode_read_u8 hfsplus_bnode_read_u8 |
| 217 | #define hfs_bnode_read_key hfsplus_bnode_read_key |
| 218 | #define hfs_bnode_write hfsplus_bnode_write |
| 219 | #define hfs_bnode_write_u16 hfsplus_bnode_write_u16 |
| 220 | #define hfs_bnode_clear hfsplus_bnode_clear |
| 221 | #define hfs_bnode_copy hfsplus_bnode_copy |
| 222 | #define hfs_bnode_move hfsplus_bnode_move |
| 223 | #define hfs_bnode_dump hfsplus_bnode_dump |
| 224 | #define hfs_bnode_unlink hfsplus_bnode_unlink |
| 225 | #define hfs_bnode_findhash hfsplus_bnode_findhash |
| 226 | #define hfs_bnode_find hfsplus_bnode_find |
| 227 | #define hfs_bnode_unhash hfsplus_bnode_unhash |
| 228 | #define hfs_bnode_free hfsplus_bnode_free |
| 229 | #define hfs_bnode_create hfsplus_bnode_create |
| 230 | #define hfs_bnode_get hfsplus_bnode_get |
| 231 | #define hfs_bnode_put hfsplus_bnode_put |
| 232 | #define hfs_brec_lenoff hfsplus_brec_lenoff |
| 233 | #define hfs_brec_keylen hfsplus_brec_keylen |
| 234 | #define hfs_brec_insert hfsplus_brec_insert |
| 235 | #define hfs_brec_remove hfsplus_brec_remove |
| 236 | #define hfs_find_init hfsplus_find_init |
| 237 | #define hfs_find_exit hfsplus_find_exit |
| 238 | #define __hfs_brec_find __hplusfs_brec_find |
| 239 | #define hfs_brec_find hfsplus_brec_find |
| 240 | #define hfs_brec_read hfsplus_brec_read |
| 241 | #define hfs_brec_goto hfsplus_brec_goto |
| 242 | #define hfs_part_find hfsplus_part_find |
| 243 | |
| 244 | /* |
| 245 | * definitions for ext2 flag ioctls (linux really needs a generic |
| 246 | * interface for this). |
| 247 | */ |
| 248 | |
| 249 | /* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support |
| 250 | * chattr/lsattr */ |
David Howells | 3669567 | 2006-08-29 19:06:16 +0100 | [diff] [blame] | 251 | #define HFSPLUS_IOC_EXT2_GETFLAGS FS_IOC_GETFLAGS |
| 252 | #define HFSPLUS_IOC_EXT2_SETFLAGS FS_IOC_SETFLAGS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
| 254 | |
| 255 | /* |
| 256 | * Functions in any *.c used in other files |
| 257 | */ |
| 258 | |
| 259 | /* bitmap.c */ |
| 260 | int hfsplus_block_allocate(struct super_block *, u32, u32, u32 *); |
| 261 | int hfsplus_block_free(struct super_block *, u32, u32); |
| 262 | |
| 263 | /* btree.c */ |
| 264 | struct hfs_btree *hfs_btree_open(struct super_block *, u32); |
| 265 | void hfs_btree_close(struct hfs_btree *); |
| 266 | void hfs_btree_write(struct hfs_btree *); |
| 267 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *); |
| 268 | void hfs_bmap_free(struct hfs_bnode *); |
| 269 | |
| 270 | /* bnode.c */ |
| 271 | void hfs_bnode_read(struct hfs_bnode *, void *, int, int); |
| 272 | u16 hfs_bnode_read_u16(struct hfs_bnode *, int); |
| 273 | u8 hfs_bnode_read_u8(struct hfs_bnode *, int); |
| 274 | void hfs_bnode_read_key(struct hfs_bnode *, void *, int); |
| 275 | void hfs_bnode_write(struct hfs_bnode *, void *, int, int); |
| 276 | void hfs_bnode_write_u16(struct hfs_bnode *, int, u16); |
| 277 | void hfs_bnode_clear(struct hfs_bnode *, int, int); |
| 278 | void hfs_bnode_copy(struct hfs_bnode *, int, |
| 279 | struct hfs_bnode *, int, int); |
| 280 | void hfs_bnode_move(struct hfs_bnode *, int, int, int); |
| 281 | void hfs_bnode_dump(struct hfs_bnode *); |
| 282 | void hfs_bnode_unlink(struct hfs_bnode *); |
| 283 | struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *, u32); |
| 284 | struct hfs_bnode *hfs_bnode_find(struct hfs_btree *, u32); |
| 285 | void hfs_bnode_unhash(struct hfs_bnode *); |
| 286 | void hfs_bnode_free(struct hfs_bnode *); |
| 287 | struct hfs_bnode *hfs_bnode_create(struct hfs_btree *, u32); |
| 288 | void hfs_bnode_get(struct hfs_bnode *); |
| 289 | void hfs_bnode_put(struct hfs_bnode *); |
| 290 | |
| 291 | /* brec.c */ |
| 292 | u16 hfs_brec_lenoff(struct hfs_bnode *, u16, u16 *); |
| 293 | u16 hfs_brec_keylen(struct hfs_bnode *, u16); |
| 294 | int hfs_brec_insert(struct hfs_find_data *, void *, int); |
| 295 | int hfs_brec_remove(struct hfs_find_data *); |
| 296 | |
| 297 | /* bfind.c */ |
| 298 | int hfs_find_init(struct hfs_btree *, struct hfs_find_data *); |
| 299 | void hfs_find_exit(struct hfs_find_data *); |
| 300 | int __hfs_brec_find(struct hfs_bnode *, struct hfs_find_data *); |
| 301 | int hfs_brec_find(struct hfs_find_data *); |
| 302 | int hfs_brec_read(struct hfs_find_data *, void *, int); |
| 303 | int hfs_brec_goto(struct hfs_find_data *, int); |
| 304 | |
| 305 | /* catalog.c */ |
David Elliott | 2179d37 | 2006-01-18 17:43:08 -0800 | [diff] [blame] | 306 | int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *); |
| 307 | int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *, u32, struct qstr *); |
| 309 | int hfsplus_find_cat(struct super_block *, u32, struct hfs_find_data *); |
| 310 | int hfsplus_create_cat(u32, struct inode *, struct qstr *, struct inode *); |
| 311 | int hfsplus_delete_cat(u32, struct inode *, struct qstr *); |
| 312 | int hfsplus_rename_cat(u32, struct inode *, struct qstr *, |
| 313 | struct inode *, struct qstr *); |
| 314 | |
Adrian Bunk | 4b0a8da | 2008-04-29 00:58:52 -0700 | [diff] [blame] | 315 | /* dir.c */ |
| 316 | extern const struct inode_operations hfsplus_dir_inode_operations; |
| 317 | extern const struct file_operations hfsplus_dir_operations; |
| 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | /* extents.c */ |
David Elliott | 2179d37 | 2006-01-18 17:43:08 -0800 | [diff] [blame] | 320 | int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | void hfsplus_ext_write_extent(struct inode *); |
| 322 | int hfsplus_get_block(struct inode *, sector_t, struct buffer_head *, int); |
| 323 | int hfsplus_free_fork(struct super_block *, u32, struct hfsplus_fork_raw *, int); |
| 324 | int hfsplus_file_extend(struct inode *); |
| 325 | void hfsplus_file_truncate(struct inode *); |
| 326 | |
| 327 | /* inode.c */ |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 328 | extern const struct address_space_operations hfsplus_aops; |
| 329 | extern const struct address_space_operations hfsplus_btree_aops; |
Duane Griffin | d45bce8 | 2007-07-15 23:41:23 -0700 | [diff] [blame] | 330 | extern struct dentry_operations hfsplus_dentry_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
| 332 | void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *); |
| 333 | void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); |
| 334 | int hfsplus_cat_read_inode(struct inode *, struct hfs_find_data *); |
| 335 | int hfsplus_cat_write_inode(struct inode *); |
| 336 | struct inode *hfsplus_new_inode(struct super_block *, int); |
| 337 | void hfsplus_delete_inode(struct inode *); |
| 338 | |
| 339 | /* ioctl.c */ |
| 340 | int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, |
| 341 | unsigned long arg); |
| 342 | int hfsplus_setxattr(struct dentry *dentry, const char *name, |
| 343 | const void *value, size_t size, int flags); |
| 344 | ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, |
| 345 | void *value, size_t size); |
| 346 | ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size); |
| 347 | |
| 348 | /* options.c */ |
Roman Zippel | 717dd80e | 2005-09-06 15:18:48 -0700 | [diff] [blame] | 349 | int hfsplus_parse_options(char *, struct hfsplus_sb_info *); |
| 350 | void hfsplus_fill_defaults(struct hfsplus_sb_info *); |
| 351 | int hfsplus_show_options(struct seq_file *, struct vfsmount *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
David Howells | 6352539 | 2008-02-07 00:15:40 -0800 | [diff] [blame] | 353 | /* super.c */ |
| 354 | struct inode *hfsplus_iget(struct super_block *, unsigned long); |
| 355 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | /* tables.c */ |
| 357 | extern u16 hfsplus_case_fold_table[]; |
| 358 | extern u16 hfsplus_decompose_table[]; |
| 359 | extern u16 hfsplus_compose_table[]; |
| 360 | |
| 361 | /* unicode.c */ |
David Elliott | 2179d37 | 2006-01-18 17:43:08 -0800 | [diff] [blame] | 362 | int hfsplus_strcasecmp(const struct hfsplus_unistr *, const struct hfsplus_unistr *); |
| 363 | int hfsplus_strcmp(const struct hfsplus_unistr *, const struct hfsplus_unistr *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | int hfsplus_uni2asc(struct super_block *, const struct hfsplus_unistr *, char *, int *); |
| 365 | int hfsplus_asc2uni(struct super_block *, struct hfsplus_unistr *, const char *, int); |
Duane Griffin | d45bce8 | 2007-07-15 23:41:23 -0700 | [diff] [blame] | 366 | int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str); |
| 367 | int hfsplus_compare_dentry(struct dentry *dentry, struct qstr *s1, struct qstr *s2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
| 369 | /* wrapper.c */ |
| 370 | int hfsplus_read_wrapper(struct super_block *); |
| 371 | |
| 372 | int hfs_part_find(struct super_block *, sector_t *, sector_t *); |
| 373 | |
| 374 | /* access macros */ |
| 375 | /* |
| 376 | static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb) |
| 377 | { |
| 378 | return sb->s_fs_info; |
| 379 | } |
| 380 | static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode) |
| 381 | { |
| 382 | return list_entry(inode, struct hfsplus_inode_info, vfs_inode); |
| 383 | } |
| 384 | */ |
| 385 | #define HFSPLUS_SB(super) (*(struct hfsplus_sb_info *)(super)->s_fs_info) |
| 386 | #define HFSPLUS_I(inode) (*list_entry(inode, struct hfsplus_inode_info, vfs_inode)) |
| 387 | |
| 388 | #if 1 |
| 389 | #define hfsplus_kmap(p) ({ struct page *__p = (p); kmap(__p); }) |
| 390 | #define hfsplus_kunmap(p) ({ struct page *__p = (p); kunmap(__p); __p; }) |
| 391 | #else |
| 392 | #define hfsplus_kmap(p) kmap(p) |
| 393 | #define hfsplus_kunmap(p) kunmap(p) |
| 394 | #endif |
| 395 | |
| 396 | #define sb_bread512(sb, sec, data) ({ \ |
| 397 | struct buffer_head *__bh; \ |
| 398 | sector_t __block; \ |
| 399 | loff_t __start; \ |
| 400 | int __offset; \ |
| 401 | \ |
| 402 | __start = (loff_t)(sec) << HFSPLUS_SECTOR_SHIFT;\ |
| 403 | __block = __start >> (sb)->s_blocksize_bits; \ |
| 404 | __offset = __start & ((sb)->s_blocksize - 1); \ |
| 405 | __bh = sb_bread((sb), __block); \ |
| 406 | if (likely(__bh != NULL)) \ |
| 407 | data = (void *)(__bh->b_data + __offset);\ |
| 408 | else \ |
| 409 | data = NULL; \ |
| 410 | __bh; \ |
| 411 | }) |
| 412 | |
| 413 | /* time macros */ |
| 414 | #define __hfsp_mt2ut(t) (be32_to_cpu(t) - 2082844800U) |
| 415 | #define __hfsp_ut2mt(t) (cpu_to_be32(t + 2082844800U)) |
| 416 | |
| 417 | /* compatibility */ |
| 418 | #define hfsp_mt2ut(t) (struct timespec){ .tv_sec = __hfsp_mt2ut(t) } |
| 419 | #define hfsp_ut2mt(t) __hfsp_ut2mt((t).tv_sec) |
| 420 | #define hfsp_now2mt() __hfsp_ut2mt(get_seconds()) |
| 421 | |
| 422 | #define kdev_t_to_nr(x) (x) |
| 423 | |
| 424 | #endif |