Blame view

fs/hfs/hfs_fs.h 8.9 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
  /*
   *  linux/fs/hfs/hfs_fs.h
   *
   * Copyright (C) 1995-1997  Paul H. Hargrove
   * (C) 2003 Ardis Technologies <roman@ardistech.com>
   * This file may be distributed under the terms of the GNU General Public License.
   */
  
  #ifndef _LINUX_HFS_FS_H
  #define _LINUX_HFS_FS_H
d61426732   Joe Perches   hfs/hfsplus: conv...
11
12
13
14
15
  #ifdef pr_fmt
  #undef pr_fmt
  #endif
  
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
  #include <linux/slab.h>
  #include <linux/types.h>
3084b72de   Matthias Kaehlcke   hfs: convert bitm...
18
  #include <linux/mutex.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
  #include <linux/buffer_head.h>
  #include <linux/fs.h>
5687b5780   Artem Bityutskiy   hfs: get rid of h...
21
  #include <linux/workqueue.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  
  #include <asm/byteorder.h>
  #include <asm/uaccess.h>
  
  #include "hfs.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
  
  //#define DBG_MASK	(DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD|DBG_CAT_MOD|DBG_BITMAP)
  //#define DBG_MASK	(DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE)
  //#define DBG_MASK	(DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
  #define DBG_MASK	(0)
d61426732   Joe Perches   hfs/hfsplus: conv...
40
41
42
43
  #define hfs_dbg(flg, fmt, ...)					\
  do {								\
  	if (DBG_##flg & DBG_MASK)				\
  		printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);	\
c2b3e1f76   Joe Perches   hfs/hfsplus: conv...
44
  } while (0)
d61426732   Joe Perches   hfs/hfsplus: conv...
45
46
47
48
  #define hfs_dbg_cont(flg, fmt, ...)				\
  do {								\
  	if (DBG_##flg & DBG_MASK)				\
  		pr_cont(fmt, ##__VA_ARGS__);			\
c2b3e1f76   Joe Perches   hfs/hfsplus: conv...
49
  } while (0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  /*
   * struct hfs_inode_info
   *
   * The HFS-specific part of a Linux (struct inode)
   */
  struct hfs_inode_info {
  	atomic_t opencnt;
  
  	unsigned int flags;
  
  	/* to deal with localtime ugliness */
  	int tz_secondswest;
  
  	struct hfs_cat_key cat_key;
  
  	struct list_head open_dir_list;
  	struct inode *rsrc_inode;
39f8d472f   Matthias Kaehlcke   hfs: convert exte...
68
  	struct mutex extents_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  
  	u16 alloc_blocks, clump_blocks;
  	sector_t fs_blocks;
  	/* Allocation extents from catlog record or volume header */
  	hfs_extent_rec first_extents;
  	u16 first_blocks;
  	hfs_extent_rec cached_extents;
  	u16 cached_start, cached_blocks;
  
  	loff_t phys_size;
  	struct inode vfs_inode;
  };
  
  #define HFS_FLG_RSRC		0x0001
  #define HFS_FLG_EXT_DIRTY	0x0002
  #define HFS_FLG_EXT_NEW		0x0004
  
  #define HFS_IS_RSRC(inode)	(HFS_I(inode)->flags & HFS_FLG_RSRC)
  
  /*
   * struct hfs_sb_info
   *
   * The HFS-specific part of a Linux (struct super_block)
   */
  struct hfs_sb_info {
  	struct buffer_head *mdb_bh;		/* The hfs_buffer
  						   holding the real
  						   superblock (aka VIB
  						   or MDB) */
  	struct hfs_mdb *mdb;
  	struct buffer_head *alt_mdb_bh;		/* The hfs_buffer holding
  						   the alternate superblock */
  	struct hfs_mdb *alt_mdb;
  	__be32 *bitmap;				/* The page holding the
  						   allocation bitmap */
  	struct hfs_btree *ext_tree;			/* Information about
  						   the extents b-tree */
  	struct hfs_btree *cat_tree;			/* Information about
  						   the catalog b-tree */
  	u32 file_count;				/* The number of
  						   regular files in
  						   the filesystem */
  	u32 folder_count;			/* The number of
  						   directories in the
  						   filesystem */
  	u32 next_id;				/* The next available
  						   file id number */
  	u32 clumpablks;				/* The number of allocation
  						   blocks to try to add when
  						   extending a file */
  	u32 fs_start;				/* The first 512-byte
  						   block represented
  						   in the bitmap */
  	u32 part_start;
  	u16 root_files;				/* The number of
  						   regular
  						   (non-directory)
  						   files in the root
  						   directory */
  	u16 root_dirs;				/* The number of
  						   directories in the
  						   root directory */
  	u16 fs_ablocks;				/* The number of
  						   allocation blocks
  						   in the filesystem */
  	u16 free_ablocks;			/* the number of unused
  						   allocation blocks
  						   in the filesystem */
  	u32 alloc_blksz;			/* The size of an
  						   "allocation block" */
  	int s_quiet;				/* Silent failure when
  						   changing owner or mode? */
  	__be32 s_type;				/* Type for new files */
  	__be32 s_creator;			/* Creator for new files */
  	umode_t s_file_umask;			/* The umask applied to the
  						   permissions on all files */
  	umode_t s_dir_umask;			/* The umask applied to the
  						   permissions on all dirs */
43b5e4ccd   Eric W. Biederman   userns: Convert h...
147
148
  	kuid_t s_uid;				/* The uid of all files */
  	kgid_t s_gid;				/* The gid of all files */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
150
  
  	int session, part;
328b92278   Roman Zippel   [PATCH] hfs: NLS ...
151
  	struct nls_table *nls_io, *nls_disk;
3084b72de   Matthias Kaehlcke   hfs: convert bitm...
152
  	struct mutex bitmap_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
153
  	unsigned long flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
  	u16 blockoffset;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
  	int fs_div;
b16ca6263   Artem Bityutskiy   hfs: introduce VF...
156
  	struct super_block *sb;
5687b5780   Artem Bityutskiy   hfs: get rid of h...
157
158
159
  	int work_queued;		/* non-zero delayed work is queued */
  	struct delayed_work mdb_work;	/* MDB flush delayed work */
  	spinlock_t work_lock;		/* protects mdb_work and work_queued */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
  };
  
  #define HFS_FLG_BITMAP_DIRTY	0
  #define HFS_FLG_MDB_DIRTY	1
  #define HFS_FLG_ALT_MDB_DIRTY	2
  
  /* bitmap.c */
  extern u32 hfs_vbm_search_free(struct super_block *, u32, u32 *);
  extern int hfs_clear_vbm_bits(struct super_block *, u16, u16);
  
  /* catalog.c */
  extern int hfs_cat_keycmp(const btree_key *, const btree_key *);
  struct hfs_find_data;
  extern int hfs_cat_find_brec(struct super_block *, u32, struct hfs_find_data *);
  extern int hfs_cat_create(u32, struct inode *, struct qstr *, struct inode *);
  extern int hfs_cat_delete(u32, struct inode *, struct qstr *);
  extern int hfs_cat_move(u32, struct inode *, struct qstr *,
  			struct inode *, struct qstr *);
328b92278   Roman Zippel   [PATCH] hfs: NLS ...
178
  extern void hfs_cat_build_key(struct super_block *, btree_key *, u32, struct qstr *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179
180
  
  /* dir.c */
4b6f5d20b   Arjan van de Ven   [PATCH] Make most...
181
  extern const struct file_operations hfs_dir_operations;
92e1d5be9   Arjan van de Ven   [PATCH] mark stru...
182
  extern const struct inode_operations hfs_dir_inode_operations;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
183
184
185
186
  
  /* extent.c */
  extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
  extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
9509f1785   Alexey Khoroshilov   hfs: add error ch...
187
  extern int hfs_ext_write_extent(struct inode *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
188
189
190
191
192
193
  extern int hfs_extend_file(struct inode *);
  extern void hfs_file_truncate(struct inode *);
  
  extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
  
  /* inode.c */
f5e54d6e5   Christoph Hellwig   [PATCH] mark addr...
194
195
  extern const struct address_space_operations hfs_aops;
  extern const struct address_space_operations hfs_btree_aops;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
196

e021d7b7f   Al Viro   hfs: propagate um...
197
  extern struct inode *hfs_new_inode(struct inode *, struct qstr *, umode_t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
198
  extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
a9185b41a   Christoph Hellwig   pass writeback_co...
199
  extern int hfs_write_inode(struct inode *, struct writeback_control *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
200
201
202
203
  extern int hfs_inode_setattr(struct dentry *, struct iattr *);
  extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
  			__be32 log_size, __be32 phys_size, u32 clump_size);
  extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *);
b57922d97   Al Viro   convert remaining...
204
  extern void hfs_evict_inode(struct inode *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
  extern void hfs_delete_inode(struct inode *);
  
  /* attr.c */
  extern int hfs_setxattr(struct dentry *dentry, const char *name,
  			const void *value, size_t size, int flags);
  extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
  			    void *value, size_t size);
  extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
  
  /* mdb.c */
  extern int hfs_mdb_get(struct super_block *);
  extern void hfs_mdb_commit(struct super_block *);
  extern void hfs_mdb_close(struct super_block *);
  extern void hfs_mdb_put(struct super_block *);
  
  /* part_tbl.c */
  extern int hfs_part_find(struct super_block *, sector_t *, sector_t *);
  
  /* string.c */
e16404ed0   Al Viro   constify dentry_o...
224
  extern const struct dentry_operations hfs_dentry_operations;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
225

da53be12b   Linus Torvalds   Don't pass inode ...
226
  extern int hfs_hash_dentry(const struct dentry *, struct qstr *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
227
228
  extern int hfs_strcmp(const unsigned char *, unsigned int,
  		      const unsigned char *, unsigned int);
da53be12b   Linus Torvalds   Don't pass inode ...
229
  extern int hfs_compare_dentry(const struct dentry *parent, const struct dentry *dentry,
621e155a3   Nick Piggin   fs: change d_comp...
230
  		unsigned int len, const char *str, const struct qstr *name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
231
232
  
  /* trans.c */
328b92278   Roman Zippel   [PATCH] hfs: NLS ...
233
234
  extern void hfs_asc2mac(struct super_block *, struct hfs_name *, struct qstr *);
  extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
235

5687b5780   Artem Bityutskiy   hfs: get rid of h...
236
237
  /* super.c */
  extern void hfs_mark_mdb_dirty(struct super_block *sb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
238
239
240
241
242
243
244
245
246
  /*
   * There are two time systems.  Both are based on seconds since
   * a particular time/date.
   *	Unix:	unsigned lil-endian since 00:00 GMT, Jan. 1, 1970
   *	mac:	unsigned big-endian since 00:00 GMT, Jan. 1, 1904
   *
   */
  #define __hfs_u_to_mtime(sec)	cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60)
  #define __hfs_m_to_utime(sec)	(be32_to_cpu(sec) - 2082844800U  + sys_tz.tz_minuteswest * 60)
db6172c41   Rasmus Villemoes   fs: cleanup sligh...
247
  #define HFS_I(inode)	(container_of(inode, struct hfs_inode_info, vfs_inode))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248
249
250
251
252
253
254
255
256
257
258
259
260
261
  #define HFS_SB(sb)	((struct hfs_sb_info *)(sb)->s_fs_info)
  
  #define hfs_m_to_utime(time)	(struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
  #define hfs_u_to_mtime(time)	__hfs_u_to_mtime((time).tv_sec)
  #define hfs_mtime()		__hfs_u_to_mtime(get_seconds())
  
  static inline const char *hfs_mdb_name(struct super_block *sb)
  {
  	return sb->s_id;
  }
  
  static inline void hfs_bitmap_dirty(struct super_block *sb)
  {
  	set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags);
5687b5780   Artem Bityutskiy   hfs: get rid of h...
262
  	hfs_mark_mdb_dirty(sb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
263
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
  #define sb_bread512(sb, sec, data) ({			\
  	struct buffer_head *__bh;			\
  	sector_t __block;				\
  	loff_t __start;					\
  	int __offset;					\
  							\
  	__start = (loff_t)(sec) << HFS_SECTOR_SIZE_BITS;\
  	__block = __start >> (sb)->s_blocksize_bits;	\
  	__offset = __start & ((sb)->s_blocksize - 1);	\
  	__bh = sb_bread((sb), __block);			\
  	if (likely(__bh != NULL))			\
  		data = (void *)(__bh->b_data + __offset);\
  	else						\
  		data = NULL;				\
  	__bh;						\
  })
  
  #endif