1
2
3
4
5
6
7
8
9#ifndef _LINUX_HFS_FS_H
10#define _LINUX_HFS_FS_H
11
12#include <linux/slab.h>
13#include <linux/types.h>
14#include <linux/mutex.h>
15#include <linux/buffer_head.h>
16#include <linux/fs.h>
17
18#include <asm/byteorder.h>
19#include <asm/uaccess.h>
20
21#include "hfs.h"
22
23#define DBG_BNODE_REFS 0x00000001
24#define DBG_BNODE_MOD 0x00000002
25#define DBG_CAT_MOD 0x00000004
26#define DBG_INODE 0x00000008
27#define DBG_SUPER 0x00000010
28#define DBG_EXTENT 0x00000020
29#define DBG_BITMAP 0x00000040
30
31
32
33
34#define DBG_MASK (0)
35
36#define dprint(flg, fmt, args...) \
37 if (flg & DBG_MASK) printk(fmt , ## args)
38
39
40
41
42
43
44struct hfs_inode_info {
45 atomic_t opencnt;
46
47 unsigned int flags;
48
49
50 int tz_secondswest;
51
52 struct hfs_cat_key cat_key;
53
54 struct list_head open_dir_list;
55 struct inode *rsrc_inode;
56
57 struct mutex extents_lock;
58
59 u16 alloc_blocks, clump_blocks;
60 sector_t fs_blocks;
61
62 hfs_extent_rec first_extents;
63 u16 first_blocks;
64 hfs_extent_rec cached_extents;
65 u16 cached_start, cached_blocks;
66
67 loff_t phys_size;
68 struct inode vfs_inode;
69};
70
71#define HFS_FLG_RSRC 0x0001
72#define HFS_FLG_EXT_DIRTY 0x0002
73#define HFS_FLG_EXT_NEW 0x0004
74
75#define HFS_IS_RSRC(inode) (HFS_I(inode)->flags & HFS_FLG_RSRC)
76
77
78
79
80
81
82struct hfs_sb_info {
83 struct buffer_head *mdb_bh;
84
85
86
87 struct hfs_mdb *mdb;
88 struct buffer_head *alt_mdb_bh;
89
90 struct hfs_mdb *alt_mdb;
91 __be32 *bitmap;
92
93 struct hfs_btree *ext_tree;
94
95 struct hfs_btree *cat_tree;
96
97 u32 file_count;
98
99
100 u32 folder_count;
101
102
103 u32 next_id;
104
105 u32 clumpablks;
106
107
108 u32 fs_start;
109
110
111 u32 part_start;
112 u16 root_files;
113
114
115
116
117 u16 root_dirs;
118
119
120 u16 fs_ablocks;
121
122
123 u16 free_ablocks;
124
125
126 u32 alloc_blksz;
127
128 int s_quiet;
129
130 __be32 s_type;
131 __be32 s_creator;
132 umode_t s_file_umask;
133
134 umode_t s_dir_umask;
135
136 uid_t s_uid;
137 gid_t s_gid;
138
139 int session, part;
140
141 struct nls_table *nls_io, *nls_disk;
142
143 struct mutex bitmap_lock;
144
145 unsigned long flags;
146
147 u16 blockoffset;
148
149 int fs_div;
150};
151
152#define HFS_FLG_BITMAP_DIRTY 0
153#define HFS_FLG_MDB_DIRTY 1
154#define HFS_FLG_ALT_MDB_DIRTY 2
155
156
157extern u32 hfs_vbm_search_free(struct super_block *, u32, u32 *);
158extern int hfs_clear_vbm_bits(struct super_block *, u16, u16);
159
160
161extern int hfs_cat_keycmp(const btree_key *, const btree_key *);
162struct hfs_find_data;
163extern int hfs_cat_find_brec(struct super_block *, u32, struct hfs_find_data *);
164extern int hfs_cat_create(u32, struct inode *, struct qstr *, struct inode *);
165extern int hfs_cat_delete(u32, struct inode *, struct qstr *);
166extern int hfs_cat_move(u32, struct inode *, struct qstr *,
167 struct inode *, struct qstr *);
168extern void hfs_cat_build_key(struct super_block *, btree_key *, u32, struct qstr *);
169
170
171extern const struct file_operations hfs_dir_operations;
172extern const struct inode_operations hfs_dir_inode_operations;
173
174
175extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
176extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
177extern void hfs_ext_write_extent(struct inode *);
178extern int hfs_extend_file(struct inode *);
179extern void hfs_file_truncate(struct inode *);
180
181extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
182
183
184extern const struct address_space_operations hfs_aops;
185extern const struct address_space_operations hfs_btree_aops;
186
187extern struct inode *hfs_new_inode(struct inode *, struct qstr *, umode_t);
188extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
189extern int hfs_write_inode(struct inode *, struct writeback_control *);
190extern int hfs_inode_setattr(struct dentry *, struct iattr *);
191extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
192 __be32 log_size, __be32 phys_size, u32 clump_size);
193extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *);
194extern void hfs_evict_inode(struct inode *);
195extern void hfs_delete_inode(struct inode *);
196
197
198extern int hfs_setxattr(struct dentry *dentry, const char *name,
199 const void *value, size_t size, int flags);
200extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
201 void *value, size_t size);
202extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
203
204
205extern int hfs_mdb_get(struct super_block *);
206extern void hfs_mdb_commit(struct super_block *);
207extern void hfs_mdb_close(struct super_block *);
208extern void hfs_mdb_put(struct super_block *);
209
210
211extern int hfs_part_find(struct super_block *, sector_t *, sector_t *);
212
213
214extern const struct dentry_operations hfs_dentry_operations;
215
216extern int hfs_hash_dentry(const struct dentry *, const struct inode *,
217 struct qstr *);
218extern int hfs_strcmp(const unsigned char *, unsigned int,
219 const unsigned char *, unsigned int);
220extern int hfs_compare_dentry(const struct dentry *parent,
221 const struct inode *pinode,
222 const struct dentry *dentry, const struct inode *inode,
223 unsigned int len, const char *str, const struct qstr *name);
224
225
226extern void hfs_asc2mac(struct super_block *, struct hfs_name *, struct qstr *);
227extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *);
228
229extern struct timezone sys_tz;
230
231
232
233
234
235
236
237
238#define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60)
239#define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60)
240
241#define HFS_I(inode) (list_entry(inode, struct hfs_inode_info, vfs_inode))
242#define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info)
243
244#define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
245#define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec)
246#define hfs_mtime() __hfs_u_to_mtime(get_seconds())
247
248static inline const char *hfs_mdb_name(struct super_block *sb)
249{
250 return sb->s_id;
251}
252
253static inline void hfs_bitmap_dirty(struct super_block *sb)
254{
255 set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags);
256 sb->s_dirt = 1;
257}
258
259#define sb_bread512(sb, sec, data) ({ \
260 struct buffer_head *__bh; \
261 sector_t __block; \
262 loff_t __start; \
263 int __offset; \
264 \
265 __start = (loff_t)(sec) << HFS_SECTOR_SIZE_BITS;\
266 __block = __start >> (sb)->s_blocksize_bits; \
267 __offset = __start & ((sb)->s_blocksize - 1); \
268 __bh = sb_bread((sb), __block); \
269 if (likely(__bh != NULL)) \
270 data = (void *)(__bh->b_data + __offset);\
271 else \
272 data = NULL; \
273 __bh; \
274})
275
276#endif
277