inode.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Optimized MPEG FS - inode and super operations.
  4. * Copyright (C) 2006 Bob Copeland <me@bobcopeland.com>
  5. */
  6. #include <linux/module.h>
  7. #include <linux/sched.h>
  8. #include <linux/slab.h>
  9. #include <linux/fs.h>
  10. #include <linux/vfs.h>
  11. #include <linux/cred.h>
  12. #include <linux/buffer_head.h>
  13. #include <linux/vmalloc.h>
  14. #include <linux/writeback.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/crc-itu-t.h>
  17. #include <linux/fs_struct.h>
  18. #include <linux/fs_context.h>
  19. #include <linux/fs_parser.h>
  20. #include "omfs.h"
  21. MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>");
  22. MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux");
  23. MODULE_LICENSE("GPL");
  24. struct buffer_head *omfs_bread(struct super_block *sb, sector_t block)
  25. {
  26. struct omfs_sb_info *sbi = OMFS_SB(sb);
  27. if (block >= sbi->s_num_blocks)
  28. return NULL;
  29. return sb_bread(sb, clus_to_blk(sbi, block));
  30. }
  31. struct inode *omfs_new_inode(struct inode *dir, umode_t mode)
  32. {
  33. struct inode *inode;
  34. u64 new_block;
  35. int err;
  36. int len;
  37. struct omfs_sb_info *sbi = OMFS_SB(dir->i_sb);
  38. inode = new_inode(dir->i_sb);
  39. if (!inode)
  40. return ERR_PTR(-ENOMEM);
  41. err = omfs_allocate_range(dir->i_sb, sbi->s_mirrors, sbi->s_mirrors,
  42. &new_block, &len);
  43. if (err)
  44. goto fail;
  45. inode->i_ino = new_block;
  46. inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
  47. inode->i_mapping->a_ops = &omfs_aops;
  48. simple_inode_init_ts(inode);
  49. switch (mode & S_IFMT) {
  50. case S_IFDIR:
  51. inode->i_op = &omfs_dir_inops;
  52. inode->i_fop = &omfs_dir_operations;
  53. inode->i_size = sbi->s_sys_blocksize;
  54. inc_nlink(inode);
  55. break;
  56. case S_IFREG:
  57. inode->i_op = &omfs_file_inops;
  58. inode->i_fop = &omfs_file_operations;
  59. inode->i_size = 0;
  60. break;
  61. }
  62. insert_inode_hash(inode);
  63. mark_inode_dirty(inode);
  64. return inode;
  65. fail:
  66. make_bad_inode(inode);
  67. iput(inode);
  68. return ERR_PTR(err);
  69. }
  70. /*
  71. * Update the header checksums for a dirty inode based on its contents.
  72. * Caller is expected to hold the buffer head underlying oi and mark it
  73. * dirty.
  74. */
  75. static void omfs_update_checksums(struct omfs_inode *oi)
  76. {
  77. int xor, i, ofs = 0, count;
  78. u16 crc = 0;
  79. unsigned char *ptr = (unsigned char *) oi;
  80. count = be32_to_cpu(oi->i_head.h_body_size);
  81. ofs = sizeof(struct omfs_header);
  82. crc = crc_itu_t(crc, ptr + ofs, count);
  83. oi->i_head.h_crc = cpu_to_be16(crc);
  84. xor = ptr[0];
  85. for (i = 1; i < OMFS_XOR_COUNT; i++)
  86. xor ^= ptr[i];
  87. oi->i_head.h_check_xor = xor;
  88. }
  89. static int __omfs_write_inode(struct inode *inode, int wait)
  90. {
  91. struct omfs_inode *oi;
  92. struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
  93. struct buffer_head *bh, *bh2;
  94. u64 ctime;
  95. int i;
  96. int ret = -EIO;
  97. int sync_failed = 0;
  98. /* get current inode since we may have written sibling ptrs etc. */
  99. bh = omfs_bread(inode->i_sb, inode->i_ino);
  100. if (!bh)
  101. goto out;
  102. oi = (struct omfs_inode *) bh->b_data;
  103. oi->i_head.h_self = cpu_to_be64(inode->i_ino);
  104. if (S_ISDIR(inode->i_mode))
  105. oi->i_type = OMFS_DIR;
  106. else if (S_ISREG(inode->i_mode))
  107. oi->i_type = OMFS_FILE;
  108. else {
  109. printk(KERN_WARNING "omfs: unknown file type: %d\n",
  110. inode->i_mode);
  111. goto out_brelse;
  112. }
  113. oi->i_head.h_body_size = cpu_to_be32(sbi->s_sys_blocksize -
  114. sizeof(struct omfs_header));
  115. oi->i_head.h_version = 1;
  116. oi->i_head.h_type = OMFS_INODE_NORMAL;
  117. oi->i_head.h_magic = OMFS_IMAGIC;
  118. oi->i_size = cpu_to_be64(inode->i_size);
  119. ctime = inode_get_ctime_sec(inode) * 1000LL +
  120. ((inode_get_ctime_nsec(inode) + 999)/1000);
  121. oi->i_ctime = cpu_to_be64(ctime);
  122. omfs_update_checksums(oi);
  123. mark_buffer_dirty(bh);
  124. if (wait) {
  125. sync_dirty_buffer(bh);
  126. if (buffer_req(bh) && !buffer_uptodate(bh))
  127. sync_failed = 1;
  128. }
  129. /* if mirroring writes, copy to next fsblock */
  130. for (i = 1; i < sbi->s_mirrors; i++) {
  131. bh2 = omfs_bread(inode->i_sb, inode->i_ino + i);
  132. if (!bh2)
  133. goto out_brelse;
  134. memcpy(bh2->b_data, bh->b_data, bh->b_size);
  135. mark_buffer_dirty(bh2);
  136. if (wait) {
  137. sync_dirty_buffer(bh2);
  138. if (buffer_req(bh2) && !buffer_uptodate(bh2))
  139. sync_failed = 1;
  140. }
  141. brelse(bh2);
  142. }
  143. ret = (sync_failed) ? -EIO : 0;
  144. out_brelse:
  145. brelse(bh);
  146. out:
  147. return ret;
  148. }
  149. static int omfs_write_inode(struct inode *inode, struct writeback_control *wbc)
  150. {
  151. return __omfs_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
  152. }
  153. int omfs_sync_inode(struct inode *inode)
  154. {
  155. return __omfs_write_inode(inode, 1);
  156. }
  157. /*
  158. * called when an entry is deleted, need to clear the bits in the
  159. * bitmaps.
  160. */
  161. static void omfs_evict_inode(struct inode *inode)
  162. {
  163. truncate_inode_pages_final(&inode->i_data);
  164. clear_inode(inode);
  165. if (inode->i_nlink)
  166. return;
  167. if (S_ISREG(inode->i_mode)) {
  168. inode->i_size = 0;
  169. omfs_shrink_inode(inode);
  170. }
  171. omfs_clear_range(inode->i_sb, inode->i_ino, 2);
  172. }
  173. struct inode *omfs_iget(struct super_block *sb, ino_t ino)
  174. {
  175. struct omfs_sb_info *sbi = OMFS_SB(sb);
  176. struct omfs_inode *oi;
  177. struct buffer_head *bh;
  178. u64 ctime;
  179. unsigned long nsecs;
  180. struct inode *inode;
  181. inode = iget_locked(sb, ino);
  182. if (!inode)
  183. return ERR_PTR(-ENOMEM);
  184. if (!(inode_state_read_once(inode) & I_NEW))
  185. return inode;
  186. bh = omfs_bread(inode->i_sb, ino);
  187. if (!bh)
  188. goto iget_failed;
  189. oi = (struct omfs_inode *)bh->b_data;
  190. /* check self */
  191. if (ino != be64_to_cpu(oi->i_head.h_self))
  192. goto fail_bh;
  193. inode->i_uid = sbi->s_uid;
  194. inode->i_gid = sbi->s_gid;
  195. ctime = be64_to_cpu(oi->i_ctime);
  196. nsecs = do_div(ctime, 1000) * 1000L;
  197. inode_set_atime(inode, ctime, nsecs);
  198. inode_set_mtime(inode, ctime, nsecs);
  199. inode_set_ctime(inode, ctime, nsecs);
  200. inode->i_mapping->a_ops = &omfs_aops;
  201. switch (oi->i_type) {
  202. case OMFS_DIR:
  203. inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask);
  204. inode->i_op = &omfs_dir_inops;
  205. inode->i_fop = &omfs_dir_operations;
  206. inode->i_size = sbi->s_sys_blocksize;
  207. inc_nlink(inode);
  208. break;
  209. case OMFS_FILE:
  210. inode->i_mode = S_IFREG | (S_IRWXUGO & ~sbi->s_fmask);
  211. inode->i_fop = &omfs_file_operations;
  212. inode->i_size = be64_to_cpu(oi->i_size);
  213. break;
  214. }
  215. brelse(bh);
  216. unlock_new_inode(inode);
  217. return inode;
  218. fail_bh:
  219. brelse(bh);
  220. iget_failed:
  221. iget_failed(inode);
  222. return ERR_PTR(-EIO);
  223. }
  224. static void omfs_put_super(struct super_block *sb)
  225. {
  226. struct omfs_sb_info *sbi = OMFS_SB(sb);
  227. kfree(sbi->s_imap);
  228. kfree(sbi);
  229. sb->s_fs_info = NULL;
  230. }
  231. static int omfs_statfs(struct dentry *dentry, struct kstatfs *buf)
  232. {
  233. struct super_block *s = dentry->d_sb;
  234. struct omfs_sb_info *sbi = OMFS_SB(s);
  235. u64 id = huge_encode_dev(s->s_bdev->bd_dev);
  236. buf->f_type = OMFS_MAGIC;
  237. buf->f_bsize = sbi->s_blocksize;
  238. buf->f_blocks = sbi->s_num_blocks;
  239. buf->f_files = sbi->s_num_blocks;
  240. buf->f_namelen = OMFS_NAMELEN;
  241. buf->f_fsid = u64_to_fsid(id);
  242. buf->f_bfree = buf->f_bavail = buf->f_ffree =
  243. omfs_count_free(s);
  244. return 0;
  245. }
  246. /*
  247. * Display the mount options in /proc/mounts.
  248. */
  249. static int omfs_show_options(struct seq_file *m, struct dentry *root)
  250. {
  251. struct omfs_sb_info *sbi = OMFS_SB(root->d_sb);
  252. umode_t cur_umask = current_umask();
  253. if (!uid_eq(sbi->s_uid, current_uid()))
  254. seq_printf(m, ",uid=%u",
  255. from_kuid_munged(&init_user_ns, sbi->s_uid));
  256. if (!gid_eq(sbi->s_gid, current_gid()))
  257. seq_printf(m, ",gid=%u",
  258. from_kgid_munged(&init_user_ns, sbi->s_gid));
  259. if (sbi->s_dmask == sbi->s_fmask) {
  260. if (sbi->s_fmask != cur_umask)
  261. seq_printf(m, ",umask=%o", sbi->s_fmask);
  262. } else {
  263. if (sbi->s_dmask != cur_umask)
  264. seq_printf(m, ",dmask=%o", sbi->s_dmask);
  265. if (sbi->s_fmask != cur_umask)
  266. seq_printf(m, ",fmask=%o", sbi->s_fmask);
  267. }
  268. return 0;
  269. }
  270. static const struct super_operations omfs_sops = {
  271. .write_inode = omfs_write_inode,
  272. .evict_inode = omfs_evict_inode,
  273. .put_super = omfs_put_super,
  274. .statfs = omfs_statfs,
  275. .show_options = omfs_show_options,
  276. };
  277. /*
  278. * For Rio Karma, there is an on-disk free bitmap whose location is
  279. * stored in the root block. For ReplayTV, there is no such free bitmap
  280. * so we have to walk the tree. Both inodes and file data are allocated
  281. * from the same map. This array can be big (300k) so we allocate
  282. * in units of the blocksize.
  283. */
  284. static int omfs_get_imap(struct super_block *sb)
  285. {
  286. unsigned int bitmap_size, array_size;
  287. int count;
  288. struct omfs_sb_info *sbi = OMFS_SB(sb);
  289. struct buffer_head *bh;
  290. unsigned long **ptr;
  291. sector_t block;
  292. bitmap_size = DIV_ROUND_UP(sbi->s_num_blocks, 8);
  293. array_size = DIV_ROUND_UP(bitmap_size, sb->s_blocksize);
  294. if (sbi->s_bitmap_ino == ~0ULL)
  295. goto out;
  296. sbi->s_imap_size = array_size;
  297. sbi->s_imap = kcalloc(array_size, sizeof(unsigned long *), GFP_KERNEL);
  298. if (!sbi->s_imap)
  299. goto nomem;
  300. block = clus_to_blk(sbi, sbi->s_bitmap_ino);
  301. if (block >= sbi->s_num_blocks)
  302. goto nomem;
  303. ptr = sbi->s_imap;
  304. for (count = bitmap_size; count > 0; count -= sb->s_blocksize) {
  305. bh = sb_bread(sb, block++);
  306. if (!bh)
  307. goto nomem_free;
  308. *ptr = kmemdup(bh->b_data, sb->s_blocksize, GFP_KERNEL);
  309. if (!*ptr) {
  310. brelse(bh);
  311. goto nomem_free;
  312. }
  313. if (count < sb->s_blocksize)
  314. memset((void *)*ptr + count, 0xff,
  315. sb->s_blocksize - count);
  316. brelse(bh);
  317. ptr++;
  318. }
  319. out:
  320. return 0;
  321. nomem_free:
  322. for (count = 0; count < array_size; count++)
  323. kfree(sbi->s_imap[count]);
  324. kfree(sbi->s_imap);
  325. nomem:
  326. sbi->s_imap = NULL;
  327. sbi->s_imap_size = 0;
  328. return -ENOMEM;
  329. }
  330. struct omfs_mount_options {
  331. kuid_t s_uid;
  332. kgid_t s_gid;
  333. int s_dmask;
  334. int s_fmask;
  335. };
  336. enum {
  337. Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask,
  338. };
  339. static const struct fs_parameter_spec omfs_param_spec[] = {
  340. fsparam_uid ("uid", Opt_uid),
  341. fsparam_gid ("gid", Opt_gid),
  342. fsparam_u32oct ("umask", Opt_umask),
  343. fsparam_u32oct ("dmask", Opt_dmask),
  344. fsparam_u32oct ("fmask", Opt_fmask),
  345. {}
  346. };
  347. static int
  348. omfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
  349. {
  350. struct omfs_mount_options *opts = fc->fs_private;
  351. int token;
  352. struct fs_parse_result result;
  353. /* All options are ignored on remount */
  354. if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
  355. return 0;
  356. token = fs_parse(fc, omfs_param_spec, param, &result);
  357. if (token < 0)
  358. return token;
  359. switch (token) {
  360. case Opt_uid:
  361. opts->s_uid = result.uid;
  362. break;
  363. case Opt_gid:
  364. opts->s_gid = result.gid;
  365. break;
  366. case Opt_umask:
  367. opts->s_fmask = opts->s_dmask = result.uint_32;
  368. break;
  369. case Opt_dmask:
  370. opts->s_dmask = result.uint_32;
  371. break;
  372. case Opt_fmask:
  373. opts->s_fmask = result.uint_32;
  374. break;
  375. default:
  376. return -EINVAL;
  377. }
  378. return 0;
  379. }
  380. static void
  381. omfs_set_options(struct omfs_sb_info *sbi, struct omfs_mount_options *opts)
  382. {
  383. sbi->s_uid = opts->s_uid;
  384. sbi->s_gid = opts->s_gid;
  385. sbi->s_dmask = opts->s_dmask;
  386. sbi->s_fmask = opts->s_fmask;
  387. }
  388. static int omfs_fill_super(struct super_block *sb, struct fs_context *fc)
  389. {
  390. struct buffer_head *bh, *bh2;
  391. struct omfs_super_block *omfs_sb;
  392. struct omfs_root_block *omfs_rb;
  393. struct omfs_sb_info *sbi;
  394. struct inode *root;
  395. struct omfs_mount_options *parsed_opts = fc->fs_private;
  396. int ret = -EINVAL;
  397. int silent = fc->sb_flags & SB_SILENT;
  398. sbi = kzalloc_obj(struct omfs_sb_info);
  399. if (!sbi)
  400. return -ENOMEM;
  401. sb->s_fs_info = sbi;
  402. omfs_set_options(sbi, parsed_opts);
  403. sb->s_maxbytes = 0xffffffff;
  404. sb->s_time_gran = NSEC_PER_MSEC;
  405. sb->s_time_min = 0;
  406. sb->s_time_max = U64_MAX / MSEC_PER_SEC;
  407. sb_set_blocksize(sb, 0x200);
  408. bh = sb_bread(sb, 0);
  409. if (!bh)
  410. goto end;
  411. omfs_sb = (struct omfs_super_block *)bh->b_data;
  412. if (omfs_sb->s_magic != cpu_to_be32(OMFS_MAGIC)) {
  413. if (!silent)
  414. printk(KERN_ERR "omfs: Invalid superblock (%x)\n",
  415. omfs_sb->s_magic);
  416. goto out_brelse_bh;
  417. }
  418. sb->s_magic = OMFS_MAGIC;
  419. sbi->s_num_blocks = be64_to_cpu(omfs_sb->s_num_blocks);
  420. sbi->s_blocksize = be32_to_cpu(omfs_sb->s_blocksize);
  421. sbi->s_mirrors = be32_to_cpu(omfs_sb->s_mirrors);
  422. sbi->s_root_ino = be64_to_cpu(omfs_sb->s_root_block);
  423. sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
  424. mutex_init(&sbi->s_bitmap_lock);
  425. if (sbi->s_num_blocks > OMFS_MAX_BLOCKS) {
  426. printk(KERN_ERR "omfs: sysblock number (%llx) is out of range\n",
  427. (unsigned long long)sbi->s_num_blocks);
  428. goto out_brelse_bh;
  429. }
  430. if (sbi->s_sys_blocksize > PAGE_SIZE) {
  431. printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
  432. sbi->s_sys_blocksize);
  433. goto out_brelse_bh;
  434. }
  435. if (sbi->s_blocksize < sbi->s_sys_blocksize ||
  436. sbi->s_blocksize > OMFS_MAX_BLOCK_SIZE) {
  437. printk(KERN_ERR "omfs: block size (%d) is out of range\n",
  438. sbi->s_blocksize);
  439. goto out_brelse_bh;
  440. }
  441. /*
  442. * Use sys_blocksize as the fs block since it is smaller than a
  443. * page while the fs blocksize can be larger.
  444. */
  445. sb_set_blocksize(sb, sbi->s_sys_blocksize);
  446. /*
  447. * ...and the difference goes into a shift. sys_blocksize is always
  448. * a power of two factor of blocksize.
  449. */
  450. sbi->s_block_shift = get_bitmask_order(sbi->s_blocksize) -
  451. get_bitmask_order(sbi->s_sys_blocksize);
  452. bh2 = omfs_bread(sb, be64_to_cpu(omfs_sb->s_root_block));
  453. if (!bh2)
  454. goto out_brelse_bh;
  455. omfs_rb = (struct omfs_root_block *)bh2->b_data;
  456. sbi->s_bitmap_ino = be64_to_cpu(omfs_rb->r_bitmap);
  457. sbi->s_clustersize = be32_to_cpu(omfs_rb->r_clustersize);
  458. if (sbi->s_num_blocks != be64_to_cpu(omfs_rb->r_num_blocks)) {
  459. printk(KERN_ERR "omfs: block count discrepancy between "
  460. "super and root blocks (%llx, %llx)\n",
  461. (unsigned long long)sbi->s_num_blocks,
  462. (unsigned long long)be64_to_cpu(omfs_rb->r_num_blocks));
  463. goto out_brelse_bh2;
  464. }
  465. if (sbi->s_bitmap_ino != ~0ULL &&
  466. sbi->s_bitmap_ino > sbi->s_num_blocks) {
  467. printk(KERN_ERR "omfs: free space bitmap location is corrupt "
  468. "(%llx, total blocks %llx)\n",
  469. (unsigned long long) sbi->s_bitmap_ino,
  470. (unsigned long long) sbi->s_num_blocks);
  471. goto out_brelse_bh2;
  472. }
  473. if (sbi->s_clustersize < 1 ||
  474. sbi->s_clustersize > OMFS_MAX_CLUSTER_SIZE) {
  475. printk(KERN_ERR "omfs: cluster size out of range (%d)",
  476. sbi->s_clustersize);
  477. goto out_brelse_bh2;
  478. }
  479. ret = omfs_get_imap(sb);
  480. if (ret)
  481. goto out_brelse_bh2;
  482. sb->s_op = &omfs_sops;
  483. root = omfs_iget(sb, be64_to_cpu(omfs_rb->r_root_dir));
  484. if (IS_ERR(root)) {
  485. ret = PTR_ERR(root);
  486. goto out_brelse_bh2;
  487. }
  488. sb->s_root = d_make_root(root);
  489. if (!sb->s_root) {
  490. ret = -ENOMEM;
  491. goto out_brelse_bh2;
  492. }
  493. printk(KERN_DEBUG "omfs: Mounted volume %s\n", omfs_rb->r_name);
  494. ret = 0;
  495. out_brelse_bh2:
  496. brelse(bh2);
  497. out_brelse_bh:
  498. brelse(bh);
  499. end:
  500. if (ret)
  501. kfree(sbi);
  502. return ret;
  503. }
  504. static int omfs_get_tree(struct fs_context *fc)
  505. {
  506. return get_tree_bdev(fc, omfs_fill_super);
  507. }
  508. static void omfs_free_fc(struct fs_context *fc);
  509. static const struct fs_context_operations omfs_context_ops = {
  510. .parse_param = omfs_parse_param,
  511. .get_tree = omfs_get_tree,
  512. .free = omfs_free_fc,
  513. };
  514. static int omfs_init_fs_context(struct fs_context *fc)
  515. {
  516. struct omfs_mount_options *opts;
  517. opts = kzalloc_obj(*opts);
  518. if (!opts)
  519. return -ENOMEM;
  520. /* Set mount options defaults */
  521. opts->s_uid = current_uid();
  522. opts->s_gid = current_gid();
  523. opts->s_dmask = opts->s_fmask = current_umask();
  524. fc->fs_private = opts;
  525. fc->ops = &omfs_context_ops;
  526. return 0;
  527. }
  528. static void omfs_free_fc(struct fs_context *fc)
  529. {
  530. kfree(fc->fs_private);
  531. }
  532. static struct file_system_type omfs_fs_type = {
  533. .owner = THIS_MODULE,
  534. .name = "omfs",
  535. .kill_sb = kill_block_super,
  536. .fs_flags = FS_REQUIRES_DEV,
  537. .init_fs_context = omfs_init_fs_context,
  538. .parameters = omfs_param_spec,
  539. };
  540. MODULE_ALIAS_FS("omfs");
  541. static int __init init_omfs_fs(void)
  542. {
  543. return register_filesystem(&omfs_fs_type);
  544. }
  545. static void __exit exit_omfs_fs(void)
  546. {
  547. unregister_filesystem(&omfs_fs_type);
  548. }
  549. module_init(init_omfs_fs);
  550. module_exit(exit_omfs_fs);