[PATCH] VFS: Permit filesystem to perform statfs with a known root dentry
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / hfsplus / super.c
CommitLineData
1da177e4
LT
1/*
2 * linux/fs/hfsplus/super.c
3 *
4 * Copyright (C) 2001
5 * Brad Boyer (flar@allandria.com)
6 * (C) 2003 Ardis Technologies <roman@ardistech.com>
7 *
8 */
9
10#include <linux/config.h>
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/pagemap.h>
14#include <linux/fs.h>
15#include <linux/sched.h>
16#include <linux/slab.h>
1da177e4
LT
17#include <linux/vfs.h>
18#include <linux/nls.h>
19
20static struct inode *hfsplus_alloc_inode(struct super_block *sb);
21static void hfsplus_destroy_inode(struct inode *inode);
22
23#include "hfsplus_fs.h"
24
1da177e4
LT
25static void hfsplus_read_inode(struct inode *inode)
26{
27 struct hfs_find_data fd;
28 struct hfsplus_vh *vhdr;
29 int err;
30
1da177e4
LT
31 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
32 init_MUTEX(&HFSPLUS_I(inode).extents_lock);
33 HFSPLUS_I(inode).flags = 0;
34 HFSPLUS_I(inode).rsrc_inode = NULL;
94c1d318 35 atomic_set(&HFSPLUS_I(inode).opencnt, 0);
1da177e4
LT
36
37 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
38 read_inode:
39 hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
40 err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
41 if (!err)
42 err = hfsplus_cat_read_inode(inode, &fd);
43 hfs_find_exit(&fd);
44 if (err)
45 goto bad_inode;
46 return;
47 }
48 vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr;
49 switch(inode->i_ino) {
50 case HFSPLUS_ROOT_CNID:
51 goto read_inode;
52 case HFSPLUS_EXT_CNID:
53 hfsplus_inode_read_fork(inode, &vhdr->ext_file);
54 inode->i_mapping->a_ops = &hfsplus_btree_aops;
55 break;
56 case HFSPLUS_CAT_CNID:
57 hfsplus_inode_read_fork(inode, &vhdr->cat_file);
58 inode->i_mapping->a_ops = &hfsplus_btree_aops;
59 break;
60 case HFSPLUS_ALLOC_CNID:
61 hfsplus_inode_read_fork(inode, &vhdr->alloc_file);
62 inode->i_mapping->a_ops = &hfsplus_aops;
63 break;
64 case HFSPLUS_START_CNID:
65 hfsplus_inode_read_fork(inode, &vhdr->start_file);
66 break;
67 case HFSPLUS_ATTR_CNID:
68 hfsplus_inode_read_fork(inode, &vhdr->attr_file);
69 inode->i_mapping->a_ops = &hfsplus_btree_aops;
70 break;
71 default:
72 goto bad_inode;
73 }
74
75 return;
76
77 bad_inode:
78 make_bad_inode(inode);
79}
80
81static int hfsplus_write_inode(struct inode *inode, int unused)
82{
83 struct hfsplus_vh *vhdr;
84 int ret = 0;
85
86 dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
87 hfsplus_ext_write_extent(inode);
88 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
89 return hfsplus_cat_write_inode(inode);
90 }
91 vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr;
92 switch (inode->i_ino) {
93 case HFSPLUS_ROOT_CNID:
94 ret = hfsplus_cat_write_inode(inode);
95 break;
96 case HFSPLUS_EXT_CNID:
97 if (vhdr->ext_file.total_size != cpu_to_be64(inode->i_size)) {
98 HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
99 inode->i_sb->s_dirt = 1;
100 }
101 hfsplus_inode_write_fork(inode, &vhdr->ext_file);
102 hfs_btree_write(HFSPLUS_SB(inode->i_sb).ext_tree);
103 break;
104 case HFSPLUS_CAT_CNID:
105 if (vhdr->cat_file.total_size != cpu_to_be64(inode->i_size)) {
106 HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
107 inode->i_sb->s_dirt = 1;
108 }
109 hfsplus_inode_write_fork(inode, &vhdr->cat_file);
110 hfs_btree_write(HFSPLUS_SB(inode->i_sb).cat_tree);
111 break;
112 case HFSPLUS_ALLOC_CNID:
113 if (vhdr->alloc_file.total_size != cpu_to_be64(inode->i_size)) {
114 HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
115 inode->i_sb->s_dirt = 1;
116 }
117 hfsplus_inode_write_fork(inode, &vhdr->alloc_file);
118 break;
119 case HFSPLUS_START_CNID:
120 if (vhdr->start_file.total_size != cpu_to_be64(inode->i_size)) {
121 HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
122 inode->i_sb->s_dirt = 1;
123 }
124 hfsplus_inode_write_fork(inode, &vhdr->start_file);
125 break;
126 case HFSPLUS_ATTR_CNID:
127 if (vhdr->attr_file.total_size != cpu_to_be64(inode->i_size)) {
128 HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
129 inode->i_sb->s_dirt = 1;
130 }
131 hfsplus_inode_write_fork(inode, &vhdr->attr_file);
132 hfs_btree_write(HFSPLUS_SB(inode->i_sb).attr_tree);
133 break;
134 }
135 return ret;
136}
137
138static void hfsplus_clear_inode(struct inode *inode)
139{
140 dprint(DBG_INODE, "hfsplus_clear_inode: %lu\n", inode->i_ino);
1da177e4
LT
141 if (HFSPLUS_IS_RSRC(inode)) {
142 HFSPLUS_I(HFSPLUS_I(inode).rsrc_inode).rsrc_inode = NULL;
143 iput(HFSPLUS_I(inode).rsrc_inode);
144 }
1da177e4
LT
145}
146
147static void hfsplus_write_super(struct super_block *sb)
148{
149 struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
150
151 dprint(DBG_SUPER, "hfsplus_write_super\n");
152 sb->s_dirt = 0;
153 if (sb->s_flags & MS_RDONLY)
154 /* warn? */
155 return;
156
157 vhdr->free_blocks = cpu_to_be32(HFSPLUS_SB(sb).free_blocks);
158 vhdr->next_alloc = cpu_to_be32(HFSPLUS_SB(sb).next_alloc);
159 vhdr->next_cnid = cpu_to_be32(HFSPLUS_SB(sb).next_cnid);
160 vhdr->folder_count = cpu_to_be32(HFSPLUS_SB(sb).folder_count);
161 vhdr->file_count = cpu_to_be32(HFSPLUS_SB(sb).file_count);
162
163 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
164 if (HFSPLUS_SB(sb).flags & HFSPLUS_SB_WRITEBACKUP) {
165 if (HFSPLUS_SB(sb).sect_count) {
166 struct buffer_head *bh;
167 u32 block, offset;
168
169 block = HFSPLUS_SB(sb).blockoffset;
170 block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9);
171 offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1);
634725a9 172 printk(KERN_DEBUG "hfs: backup: %u,%u,%u,%u\n", HFSPLUS_SB(sb).blockoffset,
1da177e4
LT
173 HFSPLUS_SB(sb).sect_count, block, offset);
174 bh = sb_bread(sb, block);
175 if (bh) {
176 vhdr = (struct hfsplus_vh *)(bh->b_data + offset);
177 if (be16_to_cpu(vhdr->signature) == HFSPLUS_VOLHEAD_SIG) {
178 memcpy(vhdr, HFSPLUS_SB(sb).s_vhdr, sizeof(*vhdr));
179 mark_buffer_dirty(bh);
180 brelse(bh);
181 } else
634725a9 182 printk(KERN_WARNING "hfs: backup not found!\n");
1da177e4
LT
183 }
184 }
185 HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP;
186 }
187}
188
189static void hfsplus_put_super(struct super_block *sb)
190{
191 dprint(DBG_SUPER, "hfsplus_put_super\n");
945b0920
CL
192 if (!sb->s_fs_info)
193 return;
194 if (!(sb->s_flags & MS_RDONLY) && HFSPLUS_SB(sb).s_vhdr) {
1da177e4
LT
195 struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
196
197 vhdr->modify_date = hfsp_now2mt();
198 vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_UNMNT);
199 vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_INCNSTNT);
200 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
e39f07c8 201 sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh);
1da177e4
LT
202 }
203
204 hfs_btree_close(HFSPLUS_SB(sb).cat_tree);
205 hfs_btree_close(HFSPLUS_SB(sb).ext_tree);
206 iput(HFSPLUS_SB(sb).alloc_file);
207 iput(HFSPLUS_SB(sb).hidden_dir);
208 brelse(HFSPLUS_SB(sb).s_vhbh);
209 if (HFSPLUS_SB(sb).nls)
210 unload_nls(HFSPLUS_SB(sb).nls);
945b0920
CL
211 kfree(sb->s_fs_info);
212 sb->s_fs_info = NULL;
1da177e4
LT
213}
214
726c3342 215static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
1da177e4 216{
726c3342
DH
217 struct super_block *sb = dentry->d_sb;
218
1da177e4
LT
219 buf->f_type = HFSPLUS_SUPER_MAGIC;
220 buf->f_bsize = sb->s_blocksize;
221 buf->f_blocks = HFSPLUS_SB(sb).total_blocks << HFSPLUS_SB(sb).fs_shift;
222 buf->f_bfree = HFSPLUS_SB(sb).free_blocks << HFSPLUS_SB(sb).fs_shift;
223 buf->f_bavail = buf->f_bfree;
224 buf->f_files = 0xFFFFFFFF;
225 buf->f_ffree = 0xFFFFFFFF - HFSPLUS_SB(sb).next_cnid;
226 buf->f_namelen = HFSPLUS_MAX_STRLEN;
227
228 return 0;
229}
230
231static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
232{
233 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
234 return 0;
235 if (!(*flags & MS_RDONLY)) {
236 struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
b0b623c3
RZ
237 struct hfsplus_sb_info sbi;
238
239 memset(&sbi, 0, sizeof(struct hfsplus_sb_info));
240 sbi.nls = HFSPLUS_SB(sb).nls;
241 if (!hfsplus_parse_options(data, &sbi))
242 return -EINVAL;
1da177e4
LT
243
244 if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
634725a9 245 printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, "
1da177e4
LT
246 "running fsck.hfsplus is recommended. leaving read-only.\n");
247 sb->s_flags |= MS_RDONLY;
248 *flags |= MS_RDONLY;
b0b623c3
RZ
249 } else if (sbi.flags & HFSPLUS_SB_FORCE) {
250 /* nothing */
1da177e4 251 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
634725a9 252 printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n");
1da177e4
LT
253 sb->s_flags |= MS_RDONLY;
254 *flags |= MS_RDONLY;
b0b623c3 255 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
634725a9 256 printk(KERN_WARNING "hfs: filesystem is marked journaled, leaving read-only.\n");
b0b623c3
RZ
257 sb->s_flags |= MS_RDONLY;
258 *flags |= MS_RDONLY;
1da177e4
LT
259 }
260 }
261 return 0;
262}
263
264static struct super_operations hfsplus_sops = {
265 .alloc_inode = hfsplus_alloc_inode,
266 .destroy_inode = hfsplus_destroy_inode,
267 .read_inode = hfsplus_read_inode,
268 .write_inode = hfsplus_write_inode,
269 .clear_inode = hfsplus_clear_inode,
270 .put_super = hfsplus_put_super,
271 .write_super = hfsplus_write_super,
272 .statfs = hfsplus_statfs,
273 .remount_fs = hfsplus_remount,
717dd80e 274 .show_options = hfsplus_show_options,
1da177e4
LT
275};
276
277static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
278{
279 struct hfsplus_vh *vhdr;
280 struct hfsplus_sb_info *sbi;
281 hfsplus_cat_entry entry;
282 struct hfs_find_data fd;
283 struct inode *root;
284 struct qstr str;
285 struct nls_table *nls = NULL;
286 int err = -EINVAL;
287
288 sbi = kmalloc(sizeof(struct hfsplus_sb_info), GFP_KERNEL);
289 if (!sbi)
290 return -ENOMEM;
291
292 memset(sbi, 0, sizeof(HFSPLUS_SB(sb)));
293 sb->s_fs_info = sbi;
294 INIT_HLIST_HEAD(&sbi->rsrc_inodes);
717dd80e
RZ
295 hfsplus_fill_defaults(sbi);
296 if (!hfsplus_parse_options(data, sbi)) {
634725a9 297 printk(KERN_ERR "hfs: unable to parse mount options\n");
1da177e4
LT
298 err = -EINVAL;
299 goto cleanup;
300 }
301
302 /* temporarily use utf8 to correctly find the hidden dir below */
303 nls = sbi->nls;
304 sbi->nls = load_nls("utf8");
bd6a59b2 305 if (!sbi->nls) {
634725a9 306 printk(KERN_ERR "hfs: unable to load nls for utf8\n");
1da177e4
LT
307 err = -EINVAL;
308 goto cleanup;
309 }
310
311 /* Grab the volume header */
312 if (hfsplus_read_wrapper(sb)) {
313 if (!silent)
634725a9 314 printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n");
1da177e4
LT
315 err = -EINVAL;
316 goto cleanup;
317 }
318 vhdr = HFSPLUS_SB(sb).s_vhdr;
319
320 /* Copy parts of the volume header into the superblock */
2179d372
DE
321 sb->s_magic = HFSPLUS_VOLHEAD_SIG;
322 if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION ||
323 be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) {
634725a9 324 printk(KERN_ERR "hfs: wrong filesystem version\n");
1da177e4
LT
325 goto cleanup;
326 }
327 HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks);
328 HFSPLUS_SB(sb).free_blocks = be32_to_cpu(vhdr->free_blocks);
329 HFSPLUS_SB(sb).next_alloc = be32_to_cpu(vhdr->next_alloc);
330 HFSPLUS_SB(sb).next_cnid = be32_to_cpu(vhdr->next_cnid);
331 HFSPLUS_SB(sb).file_count = be32_to_cpu(vhdr->file_count);
332 HFSPLUS_SB(sb).folder_count = be32_to_cpu(vhdr->folder_count);
333 HFSPLUS_SB(sb).data_clump_blocks = be32_to_cpu(vhdr->data_clump_sz) >> HFSPLUS_SB(sb).alloc_blksz_shift;
334 if (!HFSPLUS_SB(sb).data_clump_blocks)
335 HFSPLUS_SB(sb).data_clump_blocks = 1;
336 HFSPLUS_SB(sb).rsrc_clump_blocks = be32_to_cpu(vhdr->rsrc_clump_sz) >> HFSPLUS_SB(sb).alloc_blksz_shift;
337 if (!HFSPLUS_SB(sb).rsrc_clump_blocks)
338 HFSPLUS_SB(sb).rsrc_clump_blocks = 1;
339
340 /* Set up operations so we can load metadata */
341 sb->s_op = &hfsplus_sops;
342 sb->s_maxbytes = MAX_LFS_FILESIZE;
343
344 if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
634725a9
RZ
345 printk(KERN_WARNING "hfs: Filesystem was not cleanly unmounted, "
346 "running fsck.hfsplus is recommended. mounting read-only.\n");
1da177e4 347 sb->s_flags |= MS_RDONLY;
b0b623c3
RZ
348 } else if (sbi->flags & HFSPLUS_SB_FORCE) {
349 /* nothing */
1da177e4 350 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
634725a9 351 printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
1da177e4 352 sb->s_flags |= MS_RDONLY;
b0b623c3 353 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
634725a9
RZ
354 printk(KERN_WARNING "hfs: write access to a jounaled filesystem is not supported, "
355 "use the force option at your own risk, mounting read-only.\n");
b0b623c3 356 sb->s_flags |= MS_RDONLY;
1da177e4 357 }
b0b623c3 358 sbi->flags &= ~HFSPLUS_SB_FORCE;
1da177e4
LT
359
360 /* Load metadata objects (B*Trees) */
361 HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
362 if (!HFSPLUS_SB(sb).ext_tree) {
634725a9 363 printk(KERN_ERR "hfs: failed to load extents file\n");
1da177e4
LT
364 goto cleanup;
365 }
366 HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
367 if (!HFSPLUS_SB(sb).cat_tree) {
634725a9 368 printk(KERN_ERR "hfs: failed to load catalog file\n");
1da177e4
LT
369 goto cleanup;
370 }
371
372 HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID);
373 if (!HFSPLUS_SB(sb).alloc_file) {
634725a9 374 printk(KERN_ERR "hfs: failed to load allocation file\n");
1da177e4
LT
375 goto cleanup;
376 }
377
378 /* Load the root directory */
379 root = iget(sb, HFSPLUS_ROOT_CNID);
380 sb->s_root = d_alloc_root(root);
381 if (!sb->s_root) {
634725a9 382 printk(KERN_ERR "hfs: failed to load root directory\n");
1da177e4
LT
383 iput(root);
384 goto cleanup;
385 }
386
387 str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
388 str.name = HFSP_HIDDENDIR_NAME;
389 hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
390 hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
391 if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
392 hfs_find_exit(&fd);
393 if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
394 goto cleanup;
395 HFSPLUS_SB(sb).hidden_dir = iget(sb, be32_to_cpu(entry.folder.id));
396 if (!HFSPLUS_SB(sb).hidden_dir)
397 goto cleanup;
398 } else
399 hfs_find_exit(&fd);
400
401 if (sb->s_flags & MS_RDONLY)
402 goto out;
403
404 /* H+LX == hfsplusutils, H+Lx == this driver, H+lx is unused
405 * all three are registered with Apple for our use
406 */
407 vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION);
408 vhdr->modify_date = hfsp_now2mt();
409 vhdr->write_count = cpu_to_be32(be32_to_cpu(vhdr->write_count) + 1);
410 vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
411 vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
412 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
e39f07c8 413 sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh);
1da177e4
LT
414
415 if (!HFSPLUS_SB(sb).hidden_dir) {
634725a9 416 printk(KERN_DEBUG "hfs: create hidden dir...\n");
1da177e4
LT
417 HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
418 hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode,
419 &str, HFSPLUS_SB(sb).hidden_dir);
420 mark_inode_dirty(HFSPLUS_SB(sb).hidden_dir);
421 }
422out:
423 unload_nls(sbi->nls);
424 sbi->nls = nls;
425 return 0;
426
427cleanup:
428 hfsplus_put_super(sb);
429 if (nls)
430 unload_nls(nls);
431 return err;
432}
433
434MODULE_AUTHOR("Brad Boyer");
435MODULE_DESCRIPTION("Extended Macintosh Filesystem");
436MODULE_LICENSE("GPL");
437
438static kmem_cache_t *hfsplus_inode_cachep;
439
440static struct inode *hfsplus_alloc_inode(struct super_block *sb)
441{
442 struct hfsplus_inode_info *i;
443
444 i = kmem_cache_alloc(hfsplus_inode_cachep, SLAB_KERNEL);
445 return i ? &i->vfs_inode : NULL;
446}
447
448static void hfsplus_destroy_inode(struct inode *inode)
449{
450 kmem_cache_free(hfsplus_inode_cachep, &HFSPLUS_I(inode));
451}
452
453#define HFSPLUS_INODE_SIZE sizeof(struct hfsplus_inode_info)
454
454e2398
DH
455static int hfsplus_get_sb(struct file_system_type *fs_type,
456 int flags, const char *dev_name, void *data,
457 struct vfsmount *mnt)
1da177e4 458{
454e2398
DH
459 return get_sb_bdev(fs_type, flags, dev_name, data, hfsplus_fill_super,
460 mnt);
1da177e4
LT
461}
462
463static struct file_system_type hfsplus_fs_type = {
464 .owner = THIS_MODULE,
465 .name = "hfsplus",
466 .get_sb = hfsplus_get_sb,
467 .kill_sb = kill_block_super,
468 .fs_flags = FS_REQUIRES_DEV,
469};
470
471static void hfsplus_init_once(void *p, kmem_cache_t *cachep, unsigned long flags)
472{
473 struct hfsplus_inode_info *i = p;
474
475 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR)
476 inode_init_once(&i->vfs_inode);
477}
478
479static int __init init_hfsplus_fs(void)
480{
481 int err;
482
483 hfsplus_inode_cachep = kmem_cache_create("hfsplus_icache",
484 HFSPLUS_INODE_SIZE, 0, SLAB_HWCACHE_ALIGN,
485 hfsplus_init_once, NULL);
486 if (!hfsplus_inode_cachep)
487 return -ENOMEM;
488 err = register_filesystem(&hfsplus_fs_type);
489 if (err)
490 kmem_cache_destroy(hfsplus_inode_cachep);
491 return err;
492}
493
494static void __exit exit_hfsplus_fs(void)
495{
496 unregister_filesystem(&hfsplus_fs_type);
497 if (kmem_cache_destroy(hfsplus_inode_cachep))
634725a9 498 printk(KERN_ERR "hfsplus_inode_cache: not all structures were freed\n");
1da177e4
LT
499}
500
501module_init(init_hfsplus_fs)
502module_exit(exit_hfsplus_fs)