super.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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/module.h>
  10. #include <linux/init.h>
  11. #include <linux/pagemap.h>
  12. #include <linux/blkdev.h>
  13. #include <linux/fs.h>
  14. #include <linux/slab.h>
  15. #include <linux/vfs.h>
  16. #include <linux/nls.h>
  17. static struct inode *hfsplus_alloc_inode(struct super_block *sb);
  18. static void hfsplus_destroy_inode(struct inode *inode);
  19. #include "hfsplus_fs.h"
  20. static int hfsplus_system_read_inode(struct inode *inode)
  21. {
  22. struct hfsplus_vh *vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
  23. switch (inode->i_ino) {
  24. case HFSPLUS_EXT_CNID:
  25. hfsplus_inode_read_fork(inode, &vhdr->ext_file);
  26. inode->i_mapping->a_ops = &hfsplus_btree_aops;
  27. break;
  28. case HFSPLUS_CAT_CNID:
  29. hfsplus_inode_read_fork(inode, &vhdr->cat_file);
  30. inode->i_mapping->a_ops = &hfsplus_btree_aops;
  31. break;
  32. case HFSPLUS_ALLOC_CNID:
  33. hfsplus_inode_read_fork(inode, &vhdr->alloc_file);
  34. inode->i_mapping->a_ops = &hfsplus_aops;
  35. break;
  36. case HFSPLUS_START_CNID:
  37. hfsplus_inode_read_fork(inode, &vhdr->start_file);
  38. break;
  39. case HFSPLUS_ATTR_CNID:
  40. hfsplus_inode_read_fork(inode, &vhdr->attr_file);
  41. inode->i_mapping->a_ops = &hfsplus_btree_aops;
  42. break;
  43. default:
  44. return -EIO;
  45. }
  46. return 0;
  47. }
  48. struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
  49. {
  50. struct hfs_find_data fd;
  51. struct inode *inode;
  52. int err;
  53. inode = iget_locked(sb, ino);
  54. if (!inode)
  55. return ERR_PTR(-ENOMEM);
  56. if (!(inode->i_state & I_NEW))
  57. return inode;
  58. INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list);
  59. mutex_init(&HFSPLUS_I(inode)->extents_lock);
  60. HFSPLUS_I(inode)->flags = 0;
  61. HFSPLUS_I(inode)->extent_state = 0;
  62. HFSPLUS_I(inode)->rsrc_inode = NULL;
  63. atomic_set(&HFSPLUS_I(inode)->opencnt, 0);
  64. if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
  65. inode->i_ino == HFSPLUS_ROOT_CNID) {
  66. hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
  67. err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
  68. if (!err)
  69. err = hfsplus_cat_read_inode(inode, &fd);
  70. hfs_find_exit(&fd);
  71. } else {
  72. err = hfsplus_system_read_inode(inode);
  73. }
  74. if (err) {
  75. iget_failed(inode);
  76. return ERR_PTR(err);
  77. }
  78. unlock_new_inode(inode);
  79. return inode;
  80. }
  81. static int hfsplus_system_write_inode(struct inode *inode)
  82. {
  83. struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
  84. struct hfsplus_vh *vhdr = sbi->s_vhdr;
  85. struct hfsplus_fork_raw *fork;
  86. struct hfs_btree *tree = NULL;
  87. switch (inode->i_ino) {
  88. case HFSPLUS_EXT_CNID:
  89. fork = &vhdr->ext_file;
  90. tree = sbi->ext_tree;
  91. break;
  92. case HFSPLUS_CAT_CNID:
  93. fork = &vhdr->cat_file;
  94. tree = sbi->cat_tree;
  95. break;
  96. case HFSPLUS_ALLOC_CNID:
  97. fork = &vhdr->alloc_file;
  98. break;
  99. case HFSPLUS_START_CNID:
  100. fork = &vhdr->start_file;
  101. break;
  102. case HFSPLUS_ATTR_CNID:
  103. fork = &vhdr->attr_file;
  104. tree = sbi->attr_tree;
  105. default:
  106. return -EIO;
  107. }
  108. if (fork->total_size != cpu_to_be64(inode->i_size)) {
  109. set_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags);
  110. inode->i_sb->s_dirt = 1;
  111. }
  112. hfsplus_inode_write_fork(inode, fork);
  113. if (tree)
  114. hfs_btree_write(tree);
  115. return 0;
  116. }
  117. static int hfsplus_write_inode(struct inode *inode,
  118. struct writeback_control *wbc)
  119. {
  120. dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
  121. hfsplus_ext_write_extent(inode);
  122. if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
  123. inode->i_ino == HFSPLUS_ROOT_CNID)
  124. return hfsplus_cat_write_inode(inode);
  125. else
  126. return hfsplus_system_write_inode(inode);
  127. }
  128. static void hfsplus_evict_inode(struct inode *inode)
  129. {
  130. dprint(DBG_INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
  131. truncate_inode_pages(&inode->i_data, 0);
  132. end_writeback(inode);
  133. if (HFSPLUS_IS_RSRC(inode)) {
  134. HFSPLUS_I(HFSPLUS_I(inode)->rsrc_inode)->rsrc_inode = NULL;
  135. iput(HFSPLUS_I(inode)->rsrc_inode);
  136. }
  137. }
  138. int hfsplus_sync_fs(struct super_block *sb, int wait)
  139. {
  140. struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
  141. struct hfsplus_vh *vhdr = sbi->s_vhdr;
  142. int write_backup = 0;
  143. int error, error2;
  144. if (!wait)
  145. return 0;
  146. dprint(DBG_SUPER, "hfsplus_write_super\n");
  147. sb->s_dirt = 0;
  148. /*
  149. * Explicitly write out the special metadata inodes.
  150. *
  151. * While these special inodes are marked as hashed and written
  152. * out peridocically by the flusher threads we redirty them
  153. * during writeout of normal inodes, and thus the life lock
  154. * prevents us from getting the latest state to disk.
  155. */
  156. error = filemap_write_and_wait(sbi->cat_tree->inode->i_mapping);
  157. error2 = filemap_write_and_wait(sbi->ext_tree->inode->i_mapping);
  158. if (!error)
  159. error = error2;
  160. error2 = filemap_write_and_wait(sbi->alloc_file->i_mapping);
  161. if (!error)
  162. error = error2;
  163. mutex_lock(&sbi->vh_mutex);
  164. mutex_lock(&sbi->alloc_mutex);
  165. vhdr->free_blocks = cpu_to_be32(sbi->free_blocks);
  166. vhdr->next_cnid = cpu_to_be32(sbi->next_cnid);
  167. vhdr->folder_count = cpu_to_be32(sbi->folder_count);
  168. vhdr->file_count = cpu_to_be32(sbi->file_count);
  169. if (test_and_clear_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags)) {
  170. memcpy(sbi->s_backup_vhdr, sbi->s_vhdr, sizeof(*sbi->s_vhdr));
  171. write_backup = 1;
  172. }
  173. error2 = hfsplus_submit_bio(sb->s_bdev,
  174. sbi->part_start + HFSPLUS_VOLHEAD_SECTOR,
  175. sbi->s_vhdr, WRITE_SYNC);
  176. if (!error)
  177. error = error2;
  178. if (!write_backup)
  179. goto out;
  180. error2 = hfsplus_submit_bio(sb->s_bdev,
  181. sbi->part_start + sbi->sect_count - 2,
  182. sbi->s_backup_vhdr, WRITE_SYNC);
  183. if (!error)
  184. error2 = error;
  185. out:
  186. mutex_unlock(&sbi->alloc_mutex);
  187. mutex_unlock(&sbi->vh_mutex);
  188. if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags))
  189. blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);
  190. return error;
  191. }
  192. static void hfsplus_write_super(struct super_block *sb)
  193. {
  194. if (!(sb->s_flags & MS_RDONLY))
  195. hfsplus_sync_fs(sb, 1);
  196. else
  197. sb->s_dirt = 0;
  198. }
  199. static void hfsplus_put_super(struct super_block *sb)
  200. {
  201. struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
  202. dprint(DBG_SUPER, "hfsplus_put_super\n");
  203. if (!sb->s_fs_info)
  204. return;
  205. if (!(sb->s_flags & MS_RDONLY) && sbi->s_vhdr) {
  206. struct hfsplus_vh *vhdr = sbi->s_vhdr;
  207. vhdr->modify_date = hfsp_now2mt();
  208. vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_UNMNT);
  209. vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_INCNSTNT);
  210. hfsplus_sync_fs(sb, 1);
  211. }
  212. hfs_btree_close(sbi->cat_tree);
  213. hfs_btree_close(sbi->ext_tree);
  214. iput(sbi->alloc_file);
  215. iput(sbi->hidden_dir);
  216. kfree(sbi->s_vhdr);
  217. kfree(sbi->s_backup_vhdr);
  218. unload_nls(sbi->nls);
  219. kfree(sb->s_fs_info);
  220. sb->s_fs_info = NULL;
  221. }
  222. static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
  223. {
  224. struct super_block *sb = dentry->d_sb;
  225. struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
  226. u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
  227. buf->f_type = HFSPLUS_SUPER_MAGIC;
  228. buf->f_bsize = sb->s_blocksize;
  229. buf->f_blocks = sbi->total_blocks << sbi->fs_shift;
  230. buf->f_bfree = sbi->free_blocks << sbi->fs_shift;
  231. buf->f_bavail = buf->f_bfree;
  232. buf->f_files = 0xFFFFFFFF;
  233. buf->f_ffree = 0xFFFFFFFF - sbi->next_cnid;
  234. buf->f_fsid.val[0] = (u32)id;
  235. buf->f_fsid.val[1] = (u32)(id >> 32);
  236. buf->f_namelen = HFSPLUS_MAX_STRLEN;
  237. return 0;
  238. }
  239. static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
  240. {
  241. if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
  242. return 0;
  243. if (!(*flags & MS_RDONLY)) {
  244. struct hfsplus_vh *vhdr = HFSPLUS_SB(sb)->s_vhdr;
  245. int force = 0;
  246. if (!hfsplus_parse_options_remount(data, &force))
  247. return -EINVAL;
  248. if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
  249. printk(KERN_WARNING "hfs: filesystem was "
  250. "not cleanly unmounted, "
  251. "running fsck.hfsplus is recommended. "
  252. "leaving read-only.\n");
  253. sb->s_flags |= MS_RDONLY;
  254. *flags |= MS_RDONLY;
  255. } else if (force) {
  256. /* nothing */
  257. } else if (vhdr->attributes &
  258. cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
  259. printk(KERN_WARNING "hfs: filesystem is marked locked, "
  260. "leaving read-only.\n");
  261. sb->s_flags |= MS_RDONLY;
  262. *flags |= MS_RDONLY;
  263. } else if (vhdr->attributes &
  264. cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
  265. printk(KERN_WARNING "hfs: filesystem is "
  266. "marked journaled, "
  267. "leaving read-only.\n");
  268. sb->s_flags |= MS_RDONLY;
  269. *flags |= MS_RDONLY;
  270. }
  271. }
  272. return 0;
  273. }
  274. static const struct super_operations hfsplus_sops = {
  275. .alloc_inode = hfsplus_alloc_inode,
  276. .destroy_inode = hfsplus_destroy_inode,
  277. .write_inode = hfsplus_write_inode,
  278. .evict_inode = hfsplus_evict_inode,
  279. .put_super = hfsplus_put_super,
  280. .write_super = hfsplus_write_super,
  281. .sync_fs = hfsplus_sync_fs,
  282. .statfs = hfsplus_statfs,
  283. .remount_fs = hfsplus_remount,
  284. .show_options = hfsplus_show_options,
  285. };
  286. static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
  287. {
  288. struct hfsplus_vh *vhdr;
  289. struct hfsplus_sb_info *sbi;
  290. hfsplus_cat_entry entry;
  291. struct hfs_find_data fd;
  292. struct inode *root, *inode;
  293. struct qstr str;
  294. struct nls_table *nls = NULL;
  295. int err = -EINVAL;
  296. sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
  297. if (!sbi)
  298. return -ENOMEM;
  299. sb->s_fs_info = sbi;
  300. mutex_init(&sbi->alloc_mutex);
  301. mutex_init(&sbi->vh_mutex);
  302. hfsplus_fill_defaults(sbi);
  303. if (!hfsplus_parse_options(data, sbi)) {
  304. printk(KERN_ERR "hfs: unable to parse mount options\n");
  305. err = -EINVAL;
  306. goto cleanup;
  307. }
  308. /* temporarily use utf8 to correctly find the hidden dir below */
  309. nls = sbi->nls;
  310. sbi->nls = load_nls("utf8");
  311. if (!sbi->nls) {
  312. printk(KERN_ERR "hfs: unable to load nls for utf8\n");
  313. err = -EINVAL;
  314. goto cleanup;
  315. }
  316. /* Grab the volume header */
  317. if (hfsplus_read_wrapper(sb)) {
  318. if (!silent)
  319. printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n");
  320. err = -EINVAL;
  321. goto cleanup;
  322. }
  323. vhdr = sbi->s_vhdr;
  324. /* Copy parts of the volume header into the superblock */
  325. sb->s_magic = HFSPLUS_VOLHEAD_SIG;
  326. if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION ||
  327. be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) {
  328. printk(KERN_ERR "hfs: wrong filesystem version\n");
  329. goto cleanup;
  330. }
  331. sbi->total_blocks = be32_to_cpu(vhdr->total_blocks);
  332. sbi->free_blocks = be32_to_cpu(vhdr->free_blocks);
  333. sbi->next_cnid = be32_to_cpu(vhdr->next_cnid);
  334. sbi->file_count = be32_to_cpu(vhdr->file_count);
  335. sbi->folder_count = be32_to_cpu(vhdr->folder_count);
  336. sbi->data_clump_blocks =
  337. be32_to_cpu(vhdr->data_clump_sz) >> sbi->alloc_blksz_shift;
  338. if (!sbi->data_clump_blocks)
  339. sbi->data_clump_blocks = 1;
  340. sbi->rsrc_clump_blocks =
  341. be32_to_cpu(vhdr->rsrc_clump_sz) >> sbi->alloc_blksz_shift;
  342. if (!sbi->rsrc_clump_blocks)
  343. sbi->rsrc_clump_blocks = 1;
  344. /* Set up operations so we can load metadata */
  345. sb->s_op = &hfsplus_sops;
  346. sb->s_maxbytes = MAX_LFS_FILESIZE;
  347. if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
  348. printk(KERN_WARNING "hfs: Filesystem was "
  349. "not cleanly unmounted, "
  350. "running fsck.hfsplus is recommended. "
  351. "mounting read-only.\n");
  352. sb->s_flags |= MS_RDONLY;
  353. } else if (test_and_clear_bit(HFSPLUS_SB_FORCE, &sbi->flags)) {
  354. /* nothing */
  355. } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
  356. printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
  357. sb->s_flags |= MS_RDONLY;
  358. } else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) &&
  359. !(sb->s_flags & MS_RDONLY)) {
  360. printk(KERN_WARNING "hfs: write access to "
  361. "a journaled filesystem is not supported, "
  362. "use the force option at your own risk, "
  363. "mounting read-only.\n");
  364. sb->s_flags |= MS_RDONLY;
  365. }
  366. /* Load metadata objects (B*Trees) */
  367. sbi->ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
  368. if (!sbi->ext_tree) {
  369. printk(KERN_ERR "hfs: failed to load extents file\n");
  370. goto cleanup;
  371. }
  372. sbi->cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
  373. if (!sbi->cat_tree) {
  374. printk(KERN_ERR "hfs: failed to load catalog file\n");
  375. goto cleanup;
  376. }
  377. inode = hfsplus_iget(sb, HFSPLUS_ALLOC_CNID);
  378. if (IS_ERR(inode)) {
  379. printk(KERN_ERR "hfs: failed to load allocation file\n");
  380. err = PTR_ERR(inode);
  381. goto cleanup;
  382. }
  383. sbi->alloc_file = inode;
  384. /* Load the root directory */
  385. root = hfsplus_iget(sb, HFSPLUS_ROOT_CNID);
  386. if (IS_ERR(root)) {
  387. printk(KERN_ERR "hfs: failed to load root directory\n");
  388. err = PTR_ERR(root);
  389. goto cleanup;
  390. }
  391. sb->s_root = d_alloc_root(root);
  392. if (!sb->s_root) {
  393. iput(root);
  394. err = -ENOMEM;
  395. goto cleanup;
  396. }
  397. d_set_d_op(sb->s_root, &hfsplus_dentry_operations);
  398. str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
  399. str.name = HFSP_HIDDENDIR_NAME;
  400. hfs_find_init(sbi->cat_tree, &fd);
  401. hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
  402. if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
  403. hfs_find_exit(&fd);
  404. if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
  405. goto cleanup;
  406. inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id));
  407. if (IS_ERR(inode)) {
  408. err = PTR_ERR(inode);
  409. goto cleanup;
  410. }
  411. sbi->hidden_dir = inode;
  412. } else
  413. hfs_find_exit(&fd);
  414. if (sb->s_flags & MS_RDONLY)
  415. goto out;
  416. /* H+LX == hfsplusutils, H+Lx == this driver, H+lx is unused
  417. * all three are registered with Apple for our use
  418. */
  419. vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION);
  420. vhdr->modify_date = hfsp_now2mt();
  421. be32_add_cpu(&vhdr->write_count, 1);
  422. vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
  423. vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
  424. hfsplus_sync_fs(sb, 1);
  425. if (!sbi->hidden_dir) {
  426. mutex_lock(&sbi->vh_mutex);
  427. sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
  428. hfsplus_create_cat(sbi->hidden_dir->i_ino, sb->s_root->d_inode,
  429. &str, sbi->hidden_dir);
  430. mutex_unlock(&sbi->vh_mutex);
  431. hfsplus_mark_inode_dirty(sbi->hidden_dir, HFSPLUS_I_CAT_DIRTY);
  432. }
  433. out:
  434. unload_nls(sbi->nls);
  435. sbi->nls = nls;
  436. return 0;
  437. cleanup:
  438. hfsplus_put_super(sb);
  439. unload_nls(nls);
  440. return err;
  441. }
  442. MODULE_AUTHOR("Brad Boyer");
  443. MODULE_DESCRIPTION("Extended Macintosh Filesystem");
  444. MODULE_LICENSE("GPL");
  445. static struct kmem_cache *hfsplus_inode_cachep;
  446. static struct inode *hfsplus_alloc_inode(struct super_block *sb)
  447. {
  448. struct hfsplus_inode_info *i;
  449. i = kmem_cache_alloc(hfsplus_inode_cachep, GFP_KERNEL);
  450. return i ? &i->vfs_inode : NULL;
  451. }
  452. static void hfsplus_i_callback(struct rcu_head *head)
  453. {
  454. struct inode *inode = container_of(head, struct inode, i_rcu);
  455. INIT_LIST_HEAD(&inode->i_dentry);
  456. kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode));
  457. }
  458. static void hfsplus_destroy_inode(struct inode *inode)
  459. {
  460. call_rcu(&inode->i_rcu, hfsplus_i_callback);
  461. }
  462. #define HFSPLUS_INODE_SIZE sizeof(struct hfsplus_inode_info)
  463. static struct dentry *hfsplus_mount(struct file_system_type *fs_type,
  464. int flags, const char *dev_name, void *data)
  465. {
  466. return mount_bdev(fs_type, flags, dev_name, data, hfsplus_fill_super);
  467. }
  468. static struct file_system_type hfsplus_fs_type = {
  469. .owner = THIS_MODULE,
  470. .name = "hfsplus",
  471. .mount = hfsplus_mount,
  472. .kill_sb = kill_block_super,
  473. .fs_flags = FS_REQUIRES_DEV,
  474. };
  475. static void hfsplus_init_once(void *p)
  476. {
  477. struct hfsplus_inode_info *i = p;
  478. inode_init_once(&i->vfs_inode);
  479. }
  480. static int __init init_hfsplus_fs(void)
  481. {
  482. int err;
  483. hfsplus_inode_cachep = kmem_cache_create("hfsplus_icache",
  484. HFSPLUS_INODE_SIZE, 0, SLAB_HWCACHE_ALIGN,
  485. hfsplus_init_once);
  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. static void __exit exit_hfsplus_fs(void)
  494. {
  495. unregister_filesystem(&hfsplus_fs_type);
  496. kmem_cache_destroy(hfsplus_inode_cachep);
  497. }
  498. module_init(init_hfsplus_fs)
  499. module_exit(exit_hfsplus_fs)