hfsplus: over 80 character lines clean-up
[deliverable/linux.git] / fs / hfsplus / hfsplus_fs.h
CommitLineData
1da177e4
LT
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>
895c23f8 14#include <linux/mutex.h>
1da177e4
LT
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
2753cc28
AS
40typedef int (*btree_keycmp)(const hfsplus_btree_key *,
41 const hfsplus_btree_key *);
1da177e4
LT
42
43#define NODE_HASH_SIZE 256
44
45/* An HFS+ BTree held in memory */
46struct hfs_btree {
47 struct super_block *sb;
48 struct inode *inode;
49 btree_keycmp keycmp;
50
51 u32 cnid;
52 u32 root;
53 u32 leaf_count;
54 u32 leaf_head;
55 u32 leaf_tail;
56 u32 node_count;
57 u32 free_nodes;
58 u32 attributes;
59
60 unsigned int node_size;
61 unsigned int node_size_shift;
62 unsigned int max_key_len;
63 unsigned int depth;
64
65 //unsigned int map1_size, map_size;
467c3d9c 66 struct mutex tree_lock;
1da177e4
LT
67
68 unsigned int pages_per_bnode;
69 spinlock_t hash_lock;
70 struct hfs_bnode *node_hash[NODE_HASH_SIZE];
71 int node_hash_cnt;
72};
73
74struct page;
75
76/* An HFS+ BTree node in memory */
77struct hfs_bnode {
78 struct hfs_btree *tree;
79
80 u32 prev;
81 u32 this;
82 u32 next;
83 u32 parent;
84
85 u16 num_recs;
86 u8 type;
87 u8 height;
88
89 struct hfs_bnode *next_hash;
90 unsigned long flags;
91 wait_queue_head_t lock_wq;
92 atomic_t refcnt;
93 unsigned int page_offset;
94 struct page *page[0];
95};
96
97#define HFS_BNODE_LOCK 0
98#define HFS_BNODE_ERROR 1
99#define HFS_BNODE_NEW 2
100#define HFS_BNODE_DIRTY 3
101#define HFS_BNODE_DELETED 4
102
103/*
104 * HFS+ superblock info (built from Volume Header on disk)
105 */
106
107struct hfsplus_vh;
108struct hfs_btree;
109
110struct hfsplus_sb_info {
1da177e4 111 struct hfsplus_vh *s_vhdr;
52399b17 112 struct hfsplus_vh *s_backup_vhdr;
1da177e4
LT
113 struct hfs_btree *ext_tree;
114 struct hfs_btree *cat_tree;
115 struct hfs_btree *attr_tree;
116 struct inode *alloc_file;
117 struct inode *hidden_dir;
118 struct nls_table *nls;
119
120 /* Runtime variables */
121 u32 blockoffset;
52399b17
CH
122 sector_t part_start;
123 sector_t sect_count;
1da177e4
LT
124 int fs_shift;
125
7ac9fb9c 126 /* immutable data from the volume header */
1da177e4
LT
127 u32 alloc_blksz;
128 int alloc_blksz_shift;
129 u32 total_blocks;
7ac9fb9c
CH
130 u32 data_clump_blocks, rsrc_clump_blocks;
131
132 /* mutable data from the volume header, protected by alloc_mutex */
1da177e4 133 u32 free_blocks;
7ac9fb9c
CH
134 struct mutex alloc_mutex;
135
136 /* mutable data from the volume header, protected by vh_mutex */
1da177e4
LT
137 u32 next_cnid;
138 u32 file_count;
139 u32 folder_count;
7ac9fb9c 140 struct mutex vh_mutex;
1da177e4
LT
141
142 /* Config options */
143 u32 creator;
144 u32 type;
145
146 umode_t umask;
147 uid_t uid;
148 gid_t gid;
149
150 int part, session;
151
152 unsigned long flags;
1da177e4
LT
153};
154
84adede3
CH
155#define HFSPLUS_SB_WRITEBACKUP 0
156#define HFSPLUS_SB_NODECOMPOSE 1
157#define HFSPLUS_SB_FORCE 2
158#define HFSPLUS_SB_HFSX 3
159#define HFSPLUS_SB_CASEFOLD 4
34a2d313 160#define HFSPLUS_SB_NOBARRIER 5
1da177e4 161
e3494705
CH
162static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
163{
164 return sb->s_fs_info;
165}
166
1da177e4
LT
167
168struct hfsplus_inode_info {
1da177e4
LT
169 atomic_t opencnt;
170
7fcc99f4
CH
171 /*
172 * Extent allocation information, protected by extents_lock.
173 */
174 u32 first_blocks;
175 u32 clump_blocks;
176 u32 alloc_blocks;
177 u32 cached_start;
178 u32 cached_blocks;
179 hfsplus_extent_rec first_extents;
180 hfsplus_extent_rec cached_extents;
b33b7921 181 unsigned int extent_state;
7fcc99f4 182 struct mutex extents_lock;
1da177e4 183
7fcc99f4
CH
184 /*
185 * Immutable data.
186 */
187 struct inode *rsrc_inode;
9a4cad95 188 __be32 create_date;
f6089ff8
CH
189
190 /*
191 * Protected by sbi->vh_mutex.
192 */
193 u32 linkid;
1da177e4 194
b33b7921
CH
195 /*
196 * Accessed using atomic bitops.
197 */
198 unsigned long flags;
199
7fcc99f4
CH
200 /*
201 * Protected by i_mutex.
202 */
203 sector_t fs_blocks;
722c55d1 204 u8 userflags; /* BSD user file flags */
1da177e4
LT
205 struct list_head open_dir_list;
206 loff_t phys_size;
7fcc99f4 207
1da177e4
LT
208 struct inode vfs_inode;
209};
210
b33b7921
CH
211#define HFSPLUS_EXT_DIRTY 0x0001
212#define HFSPLUS_EXT_NEW 0x0002
213
214#define HFSPLUS_I_RSRC 0 /* represents a resource fork */
e3494705
CH
215#define HFSPLUS_I_CAT_DIRTY 1 /* has changes in the catalog tree */
216#define HFSPLUS_I_EXT_DIRTY 2 /* has changes in the extent tree */
217#define HFSPLUS_I_ALLOC_DIRTY 3 /* has changes in the allocation file */
1da177e4 218
b33b7921
CH
219#define HFSPLUS_IS_RSRC(inode) \
220 test_bit(HFSPLUS_I_RSRC, &HFSPLUS_I(inode)->flags)
1da177e4 221
e3494705
CH
222static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
223{
224 return list_entry(inode, struct hfsplus_inode_info, vfs_inode);
225}
226
227/*
228 * Mark an inode dirty, and also mark the btree in which the
229 * specific type of metadata is stored.
230 * For data or metadata that gets written back by into the catalog btree
231 * by hfsplus_write_inode a plain mark_inode_dirty call is enough.
232 */
233static inline void hfsplus_mark_inode_dirty(struct inode *inode,
234 unsigned int flag)
235{
236 set_bit(flag, &HFSPLUS_I(inode)->flags);
237 mark_inode_dirty(inode);
238}
239
1da177e4
LT
240struct hfs_find_data {
241 /* filled by caller */
242 hfsplus_btree_key *search_key;
243 hfsplus_btree_key *key;
244 /* filled by find */
245 struct hfs_btree *tree;
246 struct hfs_bnode *bnode;
247 /* filled by findrec */
248 int record;
249 int keyoffset, keylength;
250 int entryoffset, entrylength;
251};
252
253struct hfsplus_readdir_data {
254 struct list_head list;
255 struct file *file;
256 struct hfsplus_cat_key key;
257};
258
259#define hfs_btree_open hfsplus_btree_open
260#define hfs_btree_close hfsplus_btree_close
261#define hfs_btree_write hfsplus_btree_write
262#define hfs_bmap_alloc hfsplus_bmap_alloc
263#define hfs_bmap_free hfsplus_bmap_free
264#define hfs_bnode_read hfsplus_bnode_read
265#define hfs_bnode_read_u16 hfsplus_bnode_read_u16
266#define hfs_bnode_read_u8 hfsplus_bnode_read_u8
267#define hfs_bnode_read_key hfsplus_bnode_read_key
268#define hfs_bnode_write hfsplus_bnode_write
269#define hfs_bnode_write_u16 hfsplus_bnode_write_u16
270#define hfs_bnode_clear hfsplus_bnode_clear
271#define hfs_bnode_copy hfsplus_bnode_copy
272#define hfs_bnode_move hfsplus_bnode_move
273#define hfs_bnode_dump hfsplus_bnode_dump
274#define hfs_bnode_unlink hfsplus_bnode_unlink
275#define hfs_bnode_findhash hfsplus_bnode_findhash
276#define hfs_bnode_find hfsplus_bnode_find
277#define hfs_bnode_unhash hfsplus_bnode_unhash
278#define hfs_bnode_free hfsplus_bnode_free
279#define hfs_bnode_create hfsplus_bnode_create
280#define hfs_bnode_get hfsplus_bnode_get
281#define hfs_bnode_put hfsplus_bnode_put
282#define hfs_brec_lenoff hfsplus_brec_lenoff
283#define hfs_brec_keylen hfsplus_brec_keylen
284#define hfs_brec_insert hfsplus_brec_insert
285#define hfs_brec_remove hfsplus_brec_remove
286#define hfs_find_init hfsplus_find_init
287#define hfs_find_exit hfsplus_find_exit
288#define __hfs_brec_find __hplusfs_brec_find
289#define hfs_brec_find hfsplus_brec_find
290#define hfs_brec_read hfsplus_brec_read
291#define hfs_brec_goto hfsplus_brec_goto
292#define hfs_part_find hfsplus_part_find
293
294/*
295 * definitions for ext2 flag ioctls (linux really needs a generic
296 * interface for this).
297 */
298
299/* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support
300 * chattr/lsattr */
36695673
DH
301#define HFSPLUS_IOC_EXT2_GETFLAGS FS_IOC_GETFLAGS
302#define HFSPLUS_IOC_EXT2_SETFLAGS FS_IOC_SETFLAGS
1da177e4
LT
303
304
305/*
306 * Functions in any *.c used in other files
307 */
308
309/* bitmap.c */
310int hfsplus_block_allocate(struct super_block *, u32, u32, u32 *);
311int hfsplus_block_free(struct super_block *, u32, u32);
312
313/* btree.c */
314struct hfs_btree *hfs_btree_open(struct super_block *, u32);
315void hfs_btree_close(struct hfs_btree *);
316void hfs_btree_write(struct hfs_btree *);
317struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *);
318void hfs_bmap_free(struct hfs_bnode *);
319
320/* bnode.c */
321void hfs_bnode_read(struct hfs_bnode *, void *, int, int);
322u16 hfs_bnode_read_u16(struct hfs_bnode *, int);
323u8 hfs_bnode_read_u8(struct hfs_bnode *, int);
324void hfs_bnode_read_key(struct hfs_bnode *, void *, int);
325void hfs_bnode_write(struct hfs_bnode *, void *, int, int);
326void hfs_bnode_write_u16(struct hfs_bnode *, int, u16);
327void hfs_bnode_clear(struct hfs_bnode *, int, int);
328void hfs_bnode_copy(struct hfs_bnode *, int,
329 struct hfs_bnode *, int, int);
330void hfs_bnode_move(struct hfs_bnode *, int, int, int);
331void hfs_bnode_dump(struct hfs_bnode *);
332void hfs_bnode_unlink(struct hfs_bnode *);
333struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *, u32);
334struct hfs_bnode *hfs_bnode_find(struct hfs_btree *, u32);
335void hfs_bnode_unhash(struct hfs_bnode *);
336void hfs_bnode_free(struct hfs_bnode *);
337struct hfs_bnode *hfs_bnode_create(struct hfs_btree *, u32);
338void hfs_bnode_get(struct hfs_bnode *);
339void hfs_bnode_put(struct hfs_bnode *);
340
341/* brec.c */
342u16 hfs_brec_lenoff(struct hfs_bnode *, u16, u16 *);
343u16 hfs_brec_keylen(struct hfs_bnode *, u16);
344int hfs_brec_insert(struct hfs_find_data *, void *, int);
345int hfs_brec_remove(struct hfs_find_data *);
346
347/* bfind.c */
348int hfs_find_init(struct hfs_btree *, struct hfs_find_data *);
349void hfs_find_exit(struct hfs_find_data *);
350int __hfs_brec_find(struct hfs_bnode *, struct hfs_find_data *);
351int hfs_brec_find(struct hfs_find_data *);
352int hfs_brec_read(struct hfs_find_data *, void *, int);
353int hfs_brec_goto(struct hfs_find_data *, int);
354
355/* catalog.c */
2753cc28
AS
356int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *,
357 const hfsplus_btree_key *);
358int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *,
359 const hfsplus_btree_key *);
360void hfsplus_cat_build_key(struct super_block *sb,
361 hfsplus_btree_key *, u32, struct qstr *);
1da177e4
LT
362int hfsplus_find_cat(struct super_block *, u32, struct hfs_find_data *);
363int hfsplus_create_cat(u32, struct inode *, struct qstr *, struct inode *);
364int hfsplus_delete_cat(u32, struct inode *, struct qstr *);
365int hfsplus_rename_cat(u32, struct inode *, struct qstr *,
366 struct inode *, struct qstr *);
90e61690 367void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms);
1da177e4 368
4b0a8da7
AB
369/* dir.c */
370extern const struct inode_operations hfsplus_dir_inode_operations;
371extern const struct file_operations hfsplus_dir_operations;
372
1da177e4 373/* extents.c */
2179d372 374int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *);
1da177e4
LT
375void hfsplus_ext_write_extent(struct inode *);
376int hfsplus_get_block(struct inode *, sector_t, struct buffer_head *, int);
2753cc28
AS
377int hfsplus_free_fork(struct super_block *, u32,
378 struct hfsplus_fork_raw *, int);
1da177e4
LT
379int hfsplus_file_extend(struct inode *);
380void hfsplus_file_truncate(struct inode *);
381
382/* inode.c */
f5e54d6e
CH
383extern const struct address_space_operations hfsplus_aops;
384extern const struct address_space_operations hfsplus_btree_aops;
e16404ed 385extern const struct dentry_operations hfsplus_dentry_operations;
1da177e4
LT
386
387void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *);
388void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *);
389int hfsplus_cat_read_inode(struct inode *, struct hfs_find_data *);
390int hfsplus_cat_write_inode(struct inode *);
391struct inode *hfsplus_new_inode(struct super_block *, int);
392void hfsplus_delete_inode(struct inode *);
eb29d66d 393int hfsplus_file_fsync(struct file *file, int datasync);
1da177e4
LT
394
395/* ioctl.c */
7cc4bcc6 396long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
1da177e4
LT
397int hfsplus_setxattr(struct dentry *dentry, const char *name,
398 const void *value, size_t size, int flags);
399ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
400 void *value, size_t size);
401ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
402
403/* options.c */
717dd80e 404int hfsplus_parse_options(char *, struct hfsplus_sb_info *);
6f80dfe5 405int hfsplus_parse_options_remount(char *input, int *force);
717dd80e
RZ
406void hfsplus_fill_defaults(struct hfsplus_sb_info *);
407int hfsplus_show_options(struct seq_file *, struct vfsmount *);
1da177e4 408
63525391
DH
409/* super.c */
410struct inode *hfsplus_iget(struct super_block *, unsigned long);
b5fc510c 411int hfsplus_sync_fs(struct super_block *sb, int wait);
63525391 412
1da177e4
LT
413/* tables.c */
414extern u16 hfsplus_case_fold_table[];
415extern u16 hfsplus_decompose_table[];
416extern u16 hfsplus_compose_table[];
417
418/* unicode.c */
2753cc28
AS
419int hfsplus_strcasecmp(const struct hfsplus_unistr *,
420 const struct hfsplus_unistr *);
421int hfsplus_strcmp(const struct hfsplus_unistr *,
422 const struct hfsplus_unistr *);
423int hfsplus_uni2asc(struct super_block *,
424 const struct hfsplus_unistr *, char *, int *);
425int hfsplus_asc2uni(struct super_block *,
426 struct hfsplus_unistr *, const char *, int);
d45bce8f 427int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str);
2753cc28
AS
428int hfsplus_compare_dentry(struct dentry *dentry,
429 struct qstr *s1, struct qstr *s2);
1da177e4
LT
430
431/* wrapper.c */
432int hfsplus_read_wrapper(struct super_block *);
1da177e4 433int hfs_part_find(struct super_block *, sector_t *, sector_t *);
52399b17
CH
434int hfsplus_submit_bio(struct block_device *bdev, sector_t sector,
435 void *data, int rw);
1da177e4 436
1da177e4
LT
437/* time macros */
438#define __hfsp_mt2ut(t) (be32_to_cpu(t) - 2082844800U)
439#define __hfsp_ut2mt(t) (cpu_to_be32(t + 2082844800U))
440
441/* compatibility */
442#define hfsp_mt2ut(t) (struct timespec){ .tv_sec = __hfsp_mt2ut(t) }
443#define hfsp_ut2mt(t) __hfsp_ut2mt((t).tv_sec)
444#define hfsp_now2mt() __hfsp_ut2mt(get_seconds())
445
1da177e4 446#endif
This page took 0.67765 seconds and 5 git commands to generate.