super.c 15 KB

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