hfsplus_fs.h 16.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12
/*
 *  linux/include/linux/hfsplus_fs.h
 *
 * Copyright (C) 1999
 * Brad Boyer (flar@pants.nu)
 * (C) 2003 Ardis Technologies <roman@ardistech.com>
 *
 */

#ifndef _LINUX_HFSPLUS_FS_H
#define _LINUX_HFSPLUS_FS_H

13 14 15 16 17 18
#ifdef pr_fmt
#undef pr_fmt
#endif

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

L
Linus Torvalds 已提交
19
#include <linux/fs.h>
20
#include <linux/mutex.h>
L
Linus Torvalds 已提交
21
#include <linux/buffer_head.h>
22
#include <linux/blkdev.h>
L
Linus Torvalds 已提交
23 24 25 26 27 28 29 30 31
#include "hfsplus_raw.h"

#define DBG_BNODE_REFS	0x00000001
#define DBG_BNODE_MOD	0x00000002
#define DBG_CAT_MOD	0x00000004
#define DBG_INODE	0x00000008
#define DBG_SUPER	0x00000010
#define DBG_EXTENT	0x00000020
#define DBG_BITMAP	0x00000040
32
#define DBG_ATTR_MOD	0x00000080
33
#define DBG_ACL_MOD	0x00000100
L
Linus Torvalds 已提交
34

A
Anton Salikhmetov 已提交
35 36 37 38 39
#if 0
#define DBG_MASK	(DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD)
#define DBG_MASK	(DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE)
#define DBG_MASK	(DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
#endif
L
Linus Torvalds 已提交
40 41
#define DBG_MASK	(0)

42 43 44 45
#define hfs_dbg(flg, fmt, ...)					\
do {								\
	if (DBG_##flg & DBG_MASK)				\
		printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);	\
46 47
} while (0)

48 49 50 51
#define hfs_dbg_cont(flg, fmt, ...)				\
do {								\
	if (DBG_##flg & DBG_MASK)				\
		pr_cont(fmt, ##__VA_ARGS__);			\
52
} while (0)
L
Linus Torvalds 已提交
53 54 55 56 57 58 59

/* Runtime config options */
#define HFSPLUS_DEF_CR_TYPE    0x3F3F3F3F  /* '????' */

#define HFSPLUS_TYPE_DATA 0x00
#define HFSPLUS_TYPE_RSRC 0xFF

60 61
typedef int (*btree_keycmp)(const hfsplus_btree_key *,
		const hfsplus_btree_key *);
L
Linus Torvalds 已提交
62 63 64

#define NODE_HASH_SIZE	256

65 66 67 68 69 70 71
/* B-tree mutex nested subclasses */
enum hfsplus_btree_mutex_classes {
	CATALOG_BTREE_MUTEX,
	EXTENTS_BTREE_MUTEX,
	ATTR_BTREE_MUTEX,
};

L
Linus Torvalds 已提交
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
/* An HFS+ BTree held in memory */
struct hfs_btree {
	struct super_block *sb;
	struct inode *inode;
	btree_keycmp keycmp;

	u32 cnid;
	u32 root;
	u32 leaf_count;
	u32 leaf_head;
	u32 leaf_tail;
	u32 node_count;
	u32 free_nodes;
	u32 attributes;

	unsigned int node_size;
	unsigned int node_size_shift;
	unsigned int max_key_len;
	unsigned int depth;

92
	struct mutex tree_lock;
L
Linus Torvalds 已提交
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

	unsigned int pages_per_bnode;
	spinlock_t hash_lock;
	struct hfs_bnode *node_hash[NODE_HASH_SIZE];
	int node_hash_cnt;
};

struct page;

/* An HFS+ BTree node in memory */
struct hfs_bnode {
	struct hfs_btree *tree;

	u32 prev;
	u32 this;
	u32 next;
	u32 parent;

	u16 num_recs;
	u8 type;
	u8 height;

	struct hfs_bnode *next_hash;
	unsigned long flags;
	wait_queue_head_t lock_wq;
	atomic_t refcnt;
	unsigned int page_offset;
	struct page *page[0];
};

#define HFS_BNODE_LOCK		0
#define HFS_BNODE_ERROR		1
#define HFS_BNODE_NEW		2
#define HFS_BNODE_DIRTY		3
#define HFS_BNODE_DELETED	4

129 130 131 132 133 134 135 136
/*
 * Attributes file states
 */
#define HFSPLUS_EMPTY_ATTR_TREE		0
#define HFSPLUS_CREATING_ATTR_TREE	1
#define HFSPLUS_VALID_ATTR_TREE		2
#define HFSPLUS_FAILED_ATTR_TREE	3

L
Linus Torvalds 已提交
137 138 139 140 141 142 143 144
/*
 * HFS+ superblock info (built from Volume Header on disk)
 */

struct hfsplus_vh;
struct hfs_btree;

struct hfsplus_sb_info {
145
	void *s_vhdr_buf;
L
Linus Torvalds 已提交
146
	struct hfsplus_vh *s_vhdr;
147
	void *s_backup_vhdr_buf;
148
	struct hfsplus_vh *s_backup_vhdr;
L
Linus Torvalds 已提交
149 150 151
	struct hfs_btree *ext_tree;
	struct hfs_btree *cat_tree;
	struct hfs_btree *attr_tree;
152
	atomic_t attr_tree_state;
L
Linus Torvalds 已提交
153 154 155 156 157 158
	struct inode *alloc_file;
	struct inode *hidden_dir;
	struct nls_table *nls;

	/* Runtime variables */
	u32 blockoffset;
159 160
	sector_t part_start;
	sector_t sect_count;
L
Linus Torvalds 已提交
161 162
	int fs_shift;

163
	/* immutable data from the volume header */
L
Linus Torvalds 已提交
164 165 166
	u32 alloc_blksz;
	int alloc_blksz_shift;
	u32 total_blocks;
167 168 169
	u32 data_clump_blocks, rsrc_clump_blocks;

	/* mutable data from the volume header, protected by alloc_mutex */
L
Linus Torvalds 已提交
170
	u32 free_blocks;
171 172 173
	struct mutex alloc_mutex;

	/* mutable data from the volume header, protected by vh_mutex */
L
Linus Torvalds 已提交
174 175 176
	u32 next_cnid;
	u32 file_count;
	u32 folder_count;
177
	struct mutex vh_mutex;
L
Linus Torvalds 已提交
178 179 180 181 182 183

	/* Config options */
	u32 creator;
	u32 type;

	umode_t umask;
184 185
	kuid_t uid;
	kgid_t gid;
L
Linus Torvalds 已提交
186 187 188

	int part, session;
	unsigned long flags;
189 190 191 192

	int work_queued;               /* non-zero delayed work is queued */
	struct delayed_work sync_work; /* FS sync delayed work */
	spinlock_t work_lock;          /* protects sync_work and work_queued */
L
Linus Torvalds 已提交
193 194
};

195 196 197 198 199
#define HFSPLUS_SB_WRITEBACKUP	0
#define HFSPLUS_SB_NODECOMPOSE	1
#define HFSPLUS_SB_FORCE	2
#define HFSPLUS_SB_HFSX		3
#define HFSPLUS_SB_CASEFOLD	4
200
#define HFSPLUS_SB_NOBARRIER	5
L
Linus Torvalds 已提交
201

C
Christoph Hellwig 已提交
202 203 204 205
static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
{
	return sb->s_fs_info;
}
L
Linus Torvalds 已提交
206 207 208 209 210


struct hfsplus_inode_info {
	atomic_t opencnt;

211 212 213 214 215 216 217 218 219 220
	/*
	 * Extent allocation information, protected by extents_lock.
	 */
	u32 first_blocks;
	u32 clump_blocks;
	u32 alloc_blocks;
	u32 cached_start;
	u32 cached_blocks;
	hfsplus_extent_rec first_extents;
	hfsplus_extent_rec cached_extents;
C
Christoph Hellwig 已提交
221
	unsigned int extent_state;
222
	struct mutex extents_lock;
L
Linus Torvalds 已提交
223

224 225 226 227
	/*
	 * Immutable data.
	 */
	struct inode *rsrc_inode;
R
Roman Zippel 已提交
228
	__be32 create_date;
C
Christoph Hellwig 已提交
229 230 231 232 233

	/*
	 * Protected by sbi->vh_mutex.
	 */
	u32 linkid;
L
Linus Torvalds 已提交
234

C
Christoph Hellwig 已提交
235 236 237 238 239
	/*
	 * Accessed using atomic bitops.
	 */
	unsigned long flags;

240 241 242 243
	/*
	 * Protected by i_mutex.
	 */
	sector_t fs_blocks;
244
	u8 userflags;		/* BSD user file flags */
245
	u32 subfolders;		/* Subfolder count (HFSX only) */
L
Linus Torvalds 已提交
246 247
	struct list_head open_dir_list;
	loff_t phys_size;
248

L
Linus Torvalds 已提交
249 250 251
	struct inode vfs_inode;
};

C
Christoph Hellwig 已提交
252 253 254 255
#define HFSPLUS_EXT_DIRTY	0x0001
#define HFSPLUS_EXT_NEW		0x0002

#define HFSPLUS_I_RSRC		0	/* represents a resource fork */
C
Christoph Hellwig 已提交
256 257 258
#define HFSPLUS_I_CAT_DIRTY	1	/* has changes in the catalog tree */
#define HFSPLUS_I_EXT_DIRTY	2	/* has changes in the extent tree */
#define HFSPLUS_I_ALLOC_DIRTY	3	/* has changes in the allocation file */
259
#define HFSPLUS_I_ATTR_DIRTY	4	/* has changes in the attributes tree */
L
Linus Torvalds 已提交
260

C
Christoph Hellwig 已提交
261 262
#define HFSPLUS_IS_RSRC(inode) \
	test_bit(HFSPLUS_I_RSRC, &HFSPLUS_I(inode)->flags)
L
Linus Torvalds 已提交
263

C
Christoph Hellwig 已提交
264 265 266 267
static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
{
	return list_entry(inode, struct hfsplus_inode_info, vfs_inode);
}
L
Linus Torvalds 已提交
268

C
Christoph Hellwig 已提交
269 270 271 272 273 274 275 276 277 278 279 280
/*
 * Mark an inode dirty, and also mark the btree in which the
 * specific type of metadata is stored.
 * For data or metadata that gets written back by into the catalog btree
 * by hfsplus_write_inode a plain mark_inode_dirty call is enough.
 */
static inline void hfsplus_mark_inode_dirty(struct inode *inode,
		unsigned int flag)
{
	set_bit(flag, &HFSPLUS_I(inode)->flags);
	mark_inode_dirty(inode);
}
L
Linus Torvalds 已提交
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300

struct hfs_find_data {
	/* filled by caller */
	hfsplus_btree_key *search_key;
	hfsplus_btree_key *key;
	/* filled by find */
	struct hfs_btree *tree;
	struct hfs_bnode *bnode;
	/* filled by findrec */
	int record;
	int keyoffset, keylength;
	int entryoffset, entrylength;
};

struct hfsplus_readdir_data {
	struct list_head list;
	struct file *file;
	struct hfsplus_cat_key key;
};

301 302 303 304 305 306 307 308 309
/*
 * Find minimum acceptible I/O size for an hfsplus sb.
 */
static inline unsigned short hfsplus_min_io_size(struct super_block *sb)
{
	return max_t(unsigned short, bdev_logical_block_size(sb->s_bdev),
		     HFSPLUS_SECTOR_SIZE);
}

L
Linus Torvalds 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
#define hfs_btree_open hfsplus_btree_open
#define hfs_btree_close hfsplus_btree_close
#define hfs_btree_write hfsplus_btree_write
#define hfs_bmap_alloc hfsplus_bmap_alloc
#define hfs_bmap_free hfsplus_bmap_free
#define hfs_bnode_read hfsplus_bnode_read
#define hfs_bnode_read_u16 hfsplus_bnode_read_u16
#define hfs_bnode_read_u8 hfsplus_bnode_read_u8
#define hfs_bnode_read_key hfsplus_bnode_read_key
#define hfs_bnode_write hfsplus_bnode_write
#define hfs_bnode_write_u16 hfsplus_bnode_write_u16
#define hfs_bnode_clear hfsplus_bnode_clear
#define hfs_bnode_copy hfsplus_bnode_copy
#define hfs_bnode_move hfsplus_bnode_move
#define hfs_bnode_dump hfsplus_bnode_dump
#define hfs_bnode_unlink hfsplus_bnode_unlink
#define hfs_bnode_findhash hfsplus_bnode_findhash
#define hfs_bnode_find hfsplus_bnode_find
#define hfs_bnode_unhash hfsplus_bnode_unhash
#define hfs_bnode_free hfsplus_bnode_free
#define hfs_bnode_create hfsplus_bnode_create
#define hfs_bnode_get hfsplus_bnode_get
#define hfs_bnode_put hfsplus_bnode_put
#define hfs_brec_lenoff hfsplus_brec_lenoff
#define hfs_brec_keylen hfsplus_brec_keylen
#define hfs_brec_insert hfsplus_brec_insert
#define hfs_brec_remove hfsplus_brec_remove
#define hfs_find_init hfsplus_find_init
#define hfs_find_exit hfsplus_find_exit
339
#define __hfs_brec_find __hfsplus_brec_find
L
Linus Torvalds 已提交
340 341 342 343 344 345 346 347 348 349 350 351
#define hfs_brec_find hfsplus_brec_find
#define hfs_brec_read hfsplus_brec_read
#define hfs_brec_goto hfsplus_brec_goto
#define hfs_part_find hfsplus_part_find

/*
 * definitions for ext2 flag ioctls (linux really needs a generic
 * interface for this).
 */

/* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support
 * chattr/lsattr */
352 353
#define HFSPLUS_IOC_EXT2_GETFLAGS	FS_IOC_GETFLAGS
#define HFSPLUS_IOC_EXT2_SETFLAGS	FS_IOC_SETFLAGS
L
Linus Torvalds 已提交
354 355


356 357 358 359 360
/*
 * hfs+-specific ioctl for making the filesystem bootable
 */
#define HFSPLUS_IOC_BLESS _IO('h', 0x80)

361 362 363 364
typedef int (*search_strategy_t)(struct hfs_bnode *,
				struct hfs_find_data *,
				int *, int *, int *);

L
Linus Torvalds 已提交
365 366 367 368
/*
 * Functions in any *.c used in other files
 */

369
/* attributes.c */
370
int __init hfsplus_create_attr_tree_cache(void);
371
void hfsplus_destroy_attr_tree_cache(void);
372 373 374 375
int hfsplus_attr_bin_cmp_key(const hfsplus_btree_key *k1,
			     const hfsplus_btree_key *k2);
int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key,
			   u32 cnid, const char *name);
376
hfsplus_attr_entry *hfsplus_alloc_attr_entry(void);
377 378 379
void hfsplus_destroy_attr_entry(hfsplus_attr_entry *entry);
int hfsplus_find_attr(struct super_block *sb, u32 cnid, const char *name,
		      struct hfs_find_data *fd);
380
int hfsplus_attr_exists(struct inode *inode, const char *name);
381 382 383
int hfsplus_create_attr(struct inode *inode, const char *name,
			const void *value, size_t size);
int hfsplus_delete_attr(struct inode *inode, const char *name);
384 385
int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid);

L
Linus Torvalds 已提交
386
/* bitmap.c */
387 388 389
int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset,
			   u32 *max);
int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count);
L
Linus Torvalds 已提交
390 391

/* btree.c */
392 393 394 395 396 397 398
u32 hfsplus_calc_btree_clump_size(u32 block_size, u32 node_size, u64 sectors,
				  int file_id);
struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id);
void hfs_btree_close(struct hfs_btree *tree);
int hfs_btree_write(struct hfs_btree *tree);
struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree);
void hfs_bmap_free(struct hfs_bnode *node);
L
Linus Torvalds 已提交
399 400

/* bnode.c */
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len);
u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off);
u8 hfs_bnode_read_u8(struct hfs_bnode *node, int off);
void hfs_bnode_read_key(struct hfs_bnode *node, void *key, int off);
void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len);
void hfs_bnode_write_u16(struct hfs_bnode *node, int off, u16 data);
void hfs_bnode_clear(struct hfs_bnode *node, int off, int len);
void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
		    struct hfs_bnode *src_node, int src, int len);
void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len);
void hfs_bnode_dump(struct hfs_bnode *node);
void hfs_bnode_unlink(struct hfs_bnode *node);
struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid);
void hfs_bnode_unhash(struct hfs_bnode *node);
struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree, u32 num);
void hfs_bnode_free(struct hfs_bnode *node);
struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num);
void hfs_bnode_get(struct hfs_bnode *node);
void hfs_bnode_put(struct hfs_bnode *node);
bool hfs_bnode_need_zeroout(struct hfs_btree *tree);
L
Linus Torvalds 已提交
421 422

/* brec.c */
423 424 425 426
u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off);
u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec);
int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len);
int hfs_brec_remove(struct hfs_find_data *fd);
L
Linus Torvalds 已提交
427 428

/* bfind.c */
429 430 431 432 433 434 435 436 437 438 439
int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd);
void hfs_find_exit(struct hfs_find_data *fd);
int hfs_find_1st_rec_by_cnid(struct hfs_bnode *bnode, struct hfs_find_data *fd,
			     int *begin, int *end, int *cur_rec);
int hfs_find_rec_by_key(struct hfs_bnode *bnode, struct hfs_find_data *fd,
			int *begin, int *end, int *cur_rec);
int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd,
		    search_strategy_t rec_found);
int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare);
int hfs_brec_read(struct hfs_find_data *fd, void *rec, int rec_len);
int hfs_brec_goto(struct hfs_find_data *fd, int cnt);
L
Linus Torvalds 已提交
440 441

/* catalog.c */
442 443 444 445
int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1,
			     const hfsplus_btree_key *k2);
int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
			    const hfsplus_btree_key *k2);
S
Sougata Santra 已提交
446
int hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
447
			   u32 parent, struct qstr *str);
S
Sougata Santra 已提交
448 449
void hfsplus_cat_build_key_with_cnid(struct super_block *sb,
				     hfsplus_btree_key *key, u32 parent);
450
void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms);
451 452 453 454 455 456 457
int hfsplus_find_cat(struct super_block *sb, u32 cnid,
		     struct hfs_find_data *fd);
int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str,
		       struct inode *inode);
int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str);
int hfsplus_rename_cat(u32 cnid, struct inode *src_dir, struct qstr *src_name,
		       struct inode *dst_dir, struct qstr *dst_name);
L
Linus Torvalds 已提交
458

A
Adrian Bunk 已提交
459 460 461 462
/* dir.c */
extern const struct inode_operations hfsplus_dir_inode_operations;
extern const struct file_operations hfsplus_dir_operations;

L
Linus Torvalds 已提交
463
/* extents.c */
464 465 466 467 468 469 470 471 472
int hfsplus_ext_cmp_key(const hfsplus_btree_key *k1,
			const hfsplus_btree_key *k2);
int hfsplus_ext_write_extent(struct inode *inode);
int hfsplus_get_block(struct inode *inode, sector_t iblock,
		      struct buffer_head *bh_result, int create);
int hfsplus_free_fork(struct super_block *sb, u32 cnid,
		      struct hfsplus_fork_raw *fork, int type);
int hfsplus_file_extend(struct inode *inode, bool zeroout);
void hfsplus_file_truncate(struct inode *inode);
L
Linus Torvalds 已提交
473 474

/* inode.c */
475 476
extern const struct address_space_operations hfsplus_aops;
extern const struct address_space_operations hfsplus_btree_aops;
477
extern const struct dentry_operations hfsplus_dentry_operations;
L
Linus Torvalds 已提交
478

479 480 481 482 483 484 485 486
struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode);
void hfsplus_delete_inode(struct inode *inode);
void hfsplus_inode_read_fork(struct inode *inode,
			     struct hfsplus_fork_raw *fork);
void hfsplus_inode_write_fork(struct inode *inode,
			      struct hfsplus_fork_raw *fork);
int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
int hfsplus_cat_write_inode(struct inode *inode);
487 488
int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
		       int datasync);
L
Linus Torvalds 已提交
489 490

/* ioctl.c */
491
long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
L
Linus Torvalds 已提交
492 493

/* options.c */
494
void hfsplus_fill_defaults(struct hfsplus_sb_info *opts);
495
int hfsplus_parse_options_remount(char *input, int *force);
496 497 498 499 500 501
int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi);
int hfsplus_show_options(struct seq_file *seq, struct dentry *root);

/* part_tbl.c */
int hfs_part_find(struct super_block *sb, sector_t *part_start,
		  sector_t *part_size);
L
Linus Torvalds 已提交
502

503
/* super.c */
504
struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino);
505
void hfsplus_mark_mdb_dirty(struct super_block *sb);
506

L
Linus Torvalds 已提交
507 508 509 510 511 512
/* tables.c */
extern u16 hfsplus_case_fold_table[];
extern u16 hfsplus_decompose_table[];
extern u16 hfsplus_compose_table[];

/* unicode.c */
513 514 515 516 517 518 519 520
int hfsplus_strcasecmp(const struct hfsplus_unistr *s1,
		       const struct hfsplus_unistr *s2);
int hfsplus_strcmp(const struct hfsplus_unistr *s1,
		   const struct hfsplus_unistr *s2);
int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr,
		    char *astr, int *len_p);
int hfsplus_asc2uni(struct super_block *sb, struct hfsplus_unistr *ustr,
		    int max_unistr_len, const char *astr, int len);
521
int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str);
522 523 524
int hfsplus_compare_dentry(const struct dentry *parent,
			   const struct dentry *dentry, unsigned int len,
			   const char *str, const struct qstr *name);
L
Linus Torvalds 已提交
525 526

/* wrapper.c */
527 528 529
int hfsplus_submit_bio(struct super_block *sb, sector_t sector, void *buf,
		       void **data, int rw);
int hfsplus_read_wrapper(struct super_block *sb);
L
Linus Torvalds 已提交
530 531 532 533 534 535 536 537 538 539 540

/* time macros */
#define __hfsp_mt2ut(t)		(be32_to_cpu(t) - 2082844800U)
#define __hfsp_ut2mt(t)		(cpu_to_be32(t + 2082844800U))

/* compatibility */
#define hfsp_mt2ut(t)		(struct timespec){ .tv_sec = __hfsp_mt2ut(t) }
#define hfsp_ut2mt(t)		__hfsp_ut2mt((t).tv_sec)
#define hfsp_now2mt()		__hfsp_ut2mt(get_seconds())

#endif