super.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/fs/sysv/inode.c
  4. *
  5. * minix/inode.c
  6. * Copyright (C) 1991, 1992 Linus Torvalds
  7. *
  8. * xenix/inode.c
  9. * Copyright (C) 1992 Doug Evans
  10. *
  11. * coh/inode.c
  12. * Copyright (C) 1993 Pascal Haible, Bruno Haible
  13. *
  14. * sysv/inode.c
  15. * Copyright (C) 1993 Paul B. Monday
  16. *
  17. * sysv/inode.c
  18. * Copyright (C) 1993 Bruno Haible
  19. * Copyright (C) 1997, 1998 Krzysztof G. Baranowski
  20. *
  21. * This file contains code for read/parsing the superblock.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/init.h>
  25. #include <linux/slab.h>
  26. #include <linux/buffer_head.h>
  27. #include "sysv.h"
  28. /*
  29. * The following functions try to recognize specific filesystems.
  30. *
  31. * We recognize:
  32. * - Xenix FS by its magic number.
  33. * - SystemV FS by its magic number.
  34. * - Coherent FS by its funny fname/fpack field.
  35. * - SCO AFS by s_nfree == 0xffff
  36. * - V7 FS has no distinguishing features.
  37. *
  38. * We discriminate among SystemV4 and SystemV2 FS by the assumption that
  39. * the time stamp is not < 01-01-1980.
  40. */
  41. enum {
  42. JAN_1_1980 = (10*365 + 2) * 24 * 60 * 60
  43. };
  44. static void detected_xenix(struct sysv_sb_info *sbi, unsigned *max_links)
  45. {
  46. struct buffer_head *bh1 = sbi->s_bh1;
  47. struct buffer_head *bh2 = sbi->s_bh2;
  48. struct xenix_super_block * sbd1;
  49. struct xenix_super_block * sbd2;
  50. if (bh1 != bh2)
  51. sbd1 = sbd2 = (struct xenix_super_block *) bh1->b_data;
  52. else {
  53. /* block size = 512, so bh1 != bh2 */
  54. sbd1 = (struct xenix_super_block *) bh1->b_data;
  55. sbd2 = (struct xenix_super_block *) (bh2->b_data - 512);
  56. }
  57. *max_links = XENIX_LINK_MAX;
  58. sbi->s_fic_size = XENIX_NICINOD;
  59. sbi->s_flc_size = XENIX_NICFREE;
  60. sbi->s_sbd1 = (char *)sbd1;
  61. sbi->s_sbd2 = (char *)sbd2;
  62. sbi->s_sb_fic_count = &sbd1->s_ninode;
  63. sbi->s_sb_fic_inodes = &sbd1->s_inode[0];
  64. sbi->s_sb_total_free_inodes = &sbd2->s_tinode;
  65. sbi->s_bcache_count = &sbd1->s_nfree;
  66. sbi->s_bcache = &sbd1->s_free[0];
  67. sbi->s_free_blocks = &sbd2->s_tfree;
  68. sbi->s_sb_time = &sbd2->s_time;
  69. sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd1->s_isize);
  70. sbi->s_nzones = fs32_to_cpu(sbi, sbd1->s_fsize);
  71. }
  72. static void detected_sysv4(struct sysv_sb_info *sbi, unsigned *max_links)
  73. {
  74. struct sysv4_super_block * sbd;
  75. struct buffer_head *bh1 = sbi->s_bh1;
  76. struct buffer_head *bh2 = sbi->s_bh2;
  77. if (bh1 == bh2)
  78. sbd = (struct sysv4_super_block *) (bh1->b_data + BLOCK_SIZE/2);
  79. else
  80. sbd = (struct sysv4_super_block *) bh2->b_data;
  81. *max_links = SYSV_LINK_MAX;
  82. sbi->s_fic_size = SYSV_NICINOD;
  83. sbi->s_flc_size = SYSV_NICFREE;
  84. sbi->s_sbd1 = (char *)sbd;
  85. sbi->s_sbd2 = (char *)sbd;
  86. sbi->s_sb_fic_count = &sbd->s_ninode;
  87. sbi->s_sb_fic_inodes = &sbd->s_inode[0];
  88. sbi->s_sb_total_free_inodes = &sbd->s_tinode;
  89. sbi->s_bcache_count = &sbd->s_nfree;
  90. sbi->s_bcache = &sbd->s_free[0];
  91. sbi->s_free_blocks = &sbd->s_tfree;
  92. sbi->s_sb_time = &sbd->s_time;
  93. sbi->s_sb_state = &sbd->s_state;
  94. sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
  95. sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
  96. }
  97. static void detected_sysv2(struct sysv_sb_info *sbi, unsigned *max_links)
  98. {
  99. struct sysv2_super_block *sbd;
  100. struct buffer_head *bh1 = sbi->s_bh1;
  101. struct buffer_head *bh2 = sbi->s_bh2;
  102. if (bh1 == bh2)
  103. sbd = (struct sysv2_super_block *) (bh1->b_data + BLOCK_SIZE/2);
  104. else
  105. sbd = (struct sysv2_super_block *) bh2->b_data;
  106. *max_links = SYSV_LINK_MAX;
  107. sbi->s_fic_size = SYSV_NICINOD;
  108. sbi->s_flc_size = SYSV_NICFREE;
  109. sbi->s_sbd1 = (char *)sbd;
  110. sbi->s_sbd2 = (char *)sbd;
  111. sbi->s_sb_fic_count = &sbd->s_ninode;
  112. sbi->s_sb_fic_inodes = &sbd->s_inode[0];
  113. sbi->s_sb_total_free_inodes = &sbd->s_tinode;
  114. sbi->s_bcache_count = &sbd->s_nfree;
  115. sbi->s_bcache = &sbd->s_free[0];
  116. sbi->s_free_blocks = &sbd->s_tfree;
  117. sbi->s_sb_time = &sbd->s_time;
  118. sbi->s_sb_state = &sbd->s_state;
  119. sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
  120. sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
  121. }
  122. static void detected_coherent(struct sysv_sb_info *sbi, unsigned *max_links)
  123. {
  124. struct coh_super_block * sbd;
  125. struct buffer_head *bh1 = sbi->s_bh1;
  126. sbd = (struct coh_super_block *) bh1->b_data;
  127. *max_links = COH_LINK_MAX;
  128. sbi->s_fic_size = COH_NICINOD;
  129. sbi->s_flc_size = COH_NICFREE;
  130. sbi->s_sbd1 = (char *)sbd;
  131. sbi->s_sbd2 = (char *)sbd;
  132. sbi->s_sb_fic_count = &sbd->s_ninode;
  133. sbi->s_sb_fic_inodes = &sbd->s_inode[0];
  134. sbi->s_sb_total_free_inodes = &sbd->s_tinode;
  135. sbi->s_bcache_count = &sbd->s_nfree;
  136. sbi->s_bcache = &sbd->s_free[0];
  137. sbi->s_free_blocks = &sbd->s_tfree;
  138. sbi->s_sb_time = &sbd->s_time;
  139. sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
  140. sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
  141. }
  142. static void detected_v7(struct sysv_sb_info *sbi, unsigned *max_links)
  143. {
  144. struct buffer_head *bh2 = sbi->s_bh2;
  145. struct v7_super_block *sbd = (struct v7_super_block *)bh2->b_data;
  146. *max_links = V7_LINK_MAX;
  147. sbi->s_fic_size = V7_NICINOD;
  148. sbi->s_flc_size = V7_NICFREE;
  149. sbi->s_sbd1 = (char *)sbd;
  150. sbi->s_sbd2 = (char *)sbd;
  151. sbi->s_sb_fic_count = &sbd->s_ninode;
  152. sbi->s_sb_fic_inodes = &sbd->s_inode[0];
  153. sbi->s_sb_total_free_inodes = &sbd->s_tinode;
  154. sbi->s_bcache_count = &sbd->s_nfree;
  155. sbi->s_bcache = &sbd->s_free[0];
  156. sbi->s_free_blocks = &sbd->s_tfree;
  157. sbi->s_sb_time = &sbd->s_time;
  158. sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
  159. sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
  160. }
  161. static int detect_xenix(struct sysv_sb_info *sbi, struct buffer_head *bh)
  162. {
  163. struct xenix_super_block *sbd = (struct xenix_super_block *)bh->b_data;
  164. if (*(__le32 *)&sbd->s_magic == cpu_to_le32(0x2b5544))
  165. sbi->s_bytesex = BYTESEX_LE;
  166. else if (*(__be32 *)&sbd->s_magic == cpu_to_be32(0x2b5544))
  167. sbi->s_bytesex = BYTESEX_BE;
  168. else
  169. return 0;
  170. switch (fs32_to_cpu(sbi, sbd->s_type)) {
  171. case 1:
  172. sbi->s_type = FSTYPE_XENIX;
  173. return 1;
  174. case 2:
  175. sbi->s_type = FSTYPE_XENIX;
  176. return 2;
  177. default:
  178. return 0;
  179. }
  180. }
  181. static int detect_sysv(struct sysv_sb_info *sbi, struct buffer_head *bh)
  182. {
  183. struct super_block *sb = sbi->s_sb;
  184. /* All relevant fields are at the same offsets in R2 and R4 */
  185. struct sysv4_super_block * sbd;
  186. u32 type;
  187. sbd = (struct sysv4_super_block *) (bh->b_data + BLOCK_SIZE/2);
  188. if (*(__le32 *)&sbd->s_magic == cpu_to_le32(0xfd187e20))
  189. sbi->s_bytesex = BYTESEX_LE;
  190. else if (*(__be32 *)&sbd->s_magic == cpu_to_be32(0xfd187e20))
  191. sbi->s_bytesex = BYTESEX_BE;
  192. else
  193. return 0;
  194. type = fs32_to_cpu(sbi, sbd->s_type);
  195. if (fs16_to_cpu(sbi, sbd->s_nfree) == 0xffff) {
  196. sbi->s_type = FSTYPE_AFS;
  197. sbi->s_forced_ro = 1;
  198. if (!sb_rdonly(sb)) {
  199. printk("SysV FS: SCO EAFS on %s detected, "
  200. "forcing read-only mode.\n",
  201. sb->s_id);
  202. }
  203. return type;
  204. }
  205. if (fs32_to_cpu(sbi, sbd->s_time) < JAN_1_1980) {
  206. /* this is likely to happen on SystemV2 FS */
  207. if (type > 3 || type < 1)
  208. return 0;
  209. sbi->s_type = FSTYPE_SYSV2;
  210. return type;
  211. }
  212. if ((type > 3 || type < 1) && (type > 0x30 || type < 0x10))
  213. return 0;
  214. /* On Interactive Unix (ISC) Version 4.0/3.x s_type field = 0x10,
  215. 0x20 or 0x30 indicates that symbolic links and the 14-character
  216. filename limit is gone. Due to lack of information about this
  217. feature read-only mode seems to be a reasonable approach... -KGB */
  218. if (type >= 0x10) {
  219. printk("SysV FS: can't handle long file names on %s, "
  220. "forcing read-only mode.\n", sb->s_id);
  221. sbi->s_forced_ro = 1;
  222. }
  223. sbi->s_type = FSTYPE_SYSV4;
  224. return type >= 0x10 ? type >> 4 : type;
  225. }
  226. static int detect_coherent(struct sysv_sb_info *sbi, struct buffer_head *bh)
  227. {
  228. struct coh_super_block * sbd;
  229. sbd = (struct coh_super_block *) (bh->b_data + BLOCK_SIZE/2);
  230. if ((memcmp(sbd->s_fname,"noname",6) && memcmp(sbd->s_fname,"xxxxx ",6))
  231. || (memcmp(sbd->s_fpack,"nopack",6) && memcmp(sbd->s_fpack,"xxxxx\n",6)))
  232. return 0;
  233. sbi->s_bytesex = BYTESEX_PDP;
  234. sbi->s_type = FSTYPE_COH;
  235. return 1;
  236. }
  237. static int detect_sysv_odd(struct sysv_sb_info *sbi, struct buffer_head *bh)
  238. {
  239. int size = detect_sysv(sbi, bh);
  240. return size>2 ? 0 : size;
  241. }
  242. static struct {
  243. int block;
  244. int (*test)(struct sysv_sb_info *, struct buffer_head *);
  245. } flavours[] = {
  246. {1, detect_xenix},
  247. {0, detect_sysv},
  248. {0, detect_coherent},
  249. {9, detect_sysv_odd},
  250. {15,detect_sysv_odd},
  251. {18,detect_sysv},
  252. };
  253. static char *flavour_names[] = {
  254. [FSTYPE_XENIX] = "Xenix",
  255. [FSTYPE_SYSV4] = "SystemV",
  256. [FSTYPE_SYSV2] = "SystemV Release 2",
  257. [FSTYPE_COH] = "Coherent",
  258. [FSTYPE_V7] = "V7",
  259. [FSTYPE_AFS] = "AFS",
  260. };
  261. static void (*flavour_setup[])(struct sysv_sb_info *, unsigned *) = {
  262. [FSTYPE_XENIX] = detected_xenix,
  263. [FSTYPE_SYSV4] = detected_sysv4,
  264. [FSTYPE_SYSV2] = detected_sysv2,
  265. [FSTYPE_COH] = detected_coherent,
  266. [FSTYPE_V7] = detected_v7,
  267. [FSTYPE_AFS] = detected_sysv4,
  268. };
  269. static int complete_read_super(struct super_block *sb, int silent, int size)
  270. {
  271. struct sysv_sb_info *sbi = SYSV_SB(sb);
  272. struct inode *root_inode;
  273. char *found = flavour_names[sbi->s_type];
  274. u_char n_bits = size+8;
  275. int bsize = 1 << n_bits;
  276. int bsize_4 = bsize >> 2;
  277. sbi->s_firstinodezone = 2;
  278. flavour_setup[sbi->s_type](sbi, &sb->s_max_links);
  279. if (sbi->s_firstdatazone < sbi->s_firstinodezone)
  280. return 0;
  281. sbi->s_ndatazones = sbi->s_nzones - sbi->s_firstdatazone;
  282. sbi->s_inodes_per_block = bsize >> 6;
  283. sbi->s_inodes_per_block_1 = (bsize >> 6)-1;
  284. sbi->s_inodes_per_block_bits = n_bits-6;
  285. sbi->s_ind_per_block = bsize_4;
  286. sbi->s_ind_per_block_2 = bsize_4*bsize_4;
  287. sbi->s_toobig_block = 10 + bsize_4 * (1 + bsize_4 * (1 + bsize_4));
  288. sbi->s_ind_per_block_bits = n_bits-2;
  289. sbi->s_ninodes = (sbi->s_firstdatazone - sbi->s_firstinodezone)
  290. << sbi->s_inodes_per_block_bits;
  291. if (!silent)
  292. printk("VFS: Found a %s FS (block size = %ld) on device %s\n",
  293. found, sb->s_blocksize, sb->s_id);
  294. sb->s_magic = SYSV_MAGIC_BASE + sbi->s_type;
  295. /* set up enough so that it can read an inode */
  296. sb->s_op = &sysv_sops;
  297. if (sbi->s_forced_ro)
  298. sb->s_flags |= SB_RDONLY;
  299. root_inode = sysv_iget(sb, SYSV_ROOT_INO);
  300. if (IS_ERR(root_inode)) {
  301. printk("SysV FS: get root inode failed\n");
  302. return 0;
  303. }
  304. sb->s_root = d_make_root(root_inode);
  305. if (!sb->s_root) {
  306. printk("SysV FS: get root dentry failed\n");
  307. return 0;
  308. }
  309. return 1;
  310. }
  311. static int sysv_fill_super(struct super_block *sb, void *data, int silent)
  312. {
  313. struct buffer_head *bh1, *bh = NULL;
  314. struct sysv_sb_info *sbi;
  315. unsigned long blocknr;
  316. int size = 0, i;
  317. BUILD_BUG_ON(1024 != sizeof (struct xenix_super_block));
  318. BUILD_BUG_ON(512 != sizeof (struct sysv4_super_block));
  319. BUILD_BUG_ON(512 != sizeof (struct sysv2_super_block));
  320. BUILD_BUG_ON(500 != sizeof (struct coh_super_block));
  321. BUILD_BUG_ON(64 != sizeof (struct sysv_inode));
  322. sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
  323. if (!sbi)
  324. return -ENOMEM;
  325. sbi->s_sb = sb;
  326. sbi->s_block_base = 0;
  327. mutex_init(&sbi->s_lock);
  328. sb->s_fs_info = sbi;
  329. sb->s_time_min = 0;
  330. sb->s_time_max = U32_MAX;
  331. sb_set_blocksize(sb, BLOCK_SIZE);
  332. for (i = 0; i < ARRAY_SIZE(flavours) && !size; i++) {
  333. brelse(bh);
  334. bh = sb_bread(sb, flavours[i].block);
  335. if (!bh)
  336. continue;
  337. size = flavours[i].test(SYSV_SB(sb), bh);
  338. }
  339. if (!size)
  340. goto Eunknown;
  341. switch (size) {
  342. case 1:
  343. blocknr = bh->b_blocknr << 1;
  344. brelse(bh);
  345. sb_set_blocksize(sb, 512);
  346. bh1 = sb_bread(sb, blocknr);
  347. bh = sb_bread(sb, blocknr + 1);
  348. break;
  349. case 2:
  350. bh1 = bh;
  351. break;
  352. case 3:
  353. blocknr = bh->b_blocknr >> 1;
  354. brelse(bh);
  355. sb_set_blocksize(sb, 2048);
  356. bh1 = bh = sb_bread(sb, blocknr);
  357. break;
  358. default:
  359. goto Ebadsize;
  360. }
  361. if (bh && bh1) {
  362. sbi->s_bh1 = bh1;
  363. sbi->s_bh2 = bh;
  364. if (complete_read_super(sb, silent, size))
  365. return 0;
  366. }
  367. brelse(bh1);
  368. brelse(bh);
  369. sb_set_blocksize(sb, BLOCK_SIZE);
  370. printk("oldfs: cannot read superblock\n");
  371. failed:
  372. kfree(sbi);
  373. return -EINVAL;
  374. Eunknown:
  375. brelse(bh);
  376. if (!silent)
  377. printk("VFS: unable to find oldfs superblock on device %s\n",
  378. sb->s_id);
  379. goto failed;
  380. Ebadsize:
  381. brelse(bh);
  382. if (!silent)
  383. printk("VFS: oldfs: unsupported block size (%dKb)\n",
  384. 1<<(size-2));
  385. goto failed;
  386. }
  387. static int v7_sanity_check(struct super_block *sb, struct buffer_head *bh)
  388. {
  389. struct v7_super_block *v7sb;
  390. struct sysv_inode *v7i;
  391. struct buffer_head *bh2;
  392. struct sysv_sb_info *sbi;
  393. sbi = sb->s_fs_info;
  394. /* plausibility check on superblock */
  395. v7sb = (struct v7_super_block *) bh->b_data;
  396. if (fs16_to_cpu(sbi, v7sb->s_nfree) > V7_NICFREE ||
  397. fs16_to_cpu(sbi, v7sb->s_ninode) > V7_NICINOD ||
  398. fs32_to_cpu(sbi, v7sb->s_fsize) > V7_MAXSIZE)
  399. return 0;
  400. /* plausibility check on root inode: it is a directory,
  401. with a nonzero size that is a multiple of 16 */
  402. bh2 = sb_bread(sb, 2);
  403. if (bh2 == NULL)
  404. return 0;
  405. v7i = (struct sysv_inode *)(bh2->b_data + 64);
  406. if ((fs16_to_cpu(sbi, v7i->i_mode) & ~0777) != S_IFDIR ||
  407. (fs32_to_cpu(sbi, v7i->i_size) == 0) ||
  408. (fs32_to_cpu(sbi, v7i->i_size) & 017) ||
  409. (fs32_to_cpu(sbi, v7i->i_size) > V7_NFILES *
  410. sizeof(struct sysv_dir_entry))) {
  411. brelse(bh2);
  412. return 0;
  413. }
  414. brelse(bh2);
  415. return 1;
  416. }
  417. static int v7_fill_super(struct super_block *sb, void *data, int silent)
  418. {
  419. struct sysv_sb_info *sbi;
  420. struct buffer_head *bh;
  421. BUILD_BUG_ON(sizeof(struct v7_super_block) != 440);
  422. BUILD_BUG_ON(sizeof(struct sysv_inode) != 64);
  423. sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
  424. if (!sbi)
  425. return -ENOMEM;
  426. sbi->s_sb = sb;
  427. sbi->s_block_base = 0;
  428. sbi->s_type = FSTYPE_V7;
  429. mutex_init(&sbi->s_lock);
  430. sb->s_fs_info = sbi;
  431. sb->s_time_min = 0;
  432. sb->s_time_max = U32_MAX;
  433. sb_set_blocksize(sb, 512);
  434. if ((bh = sb_bread(sb, 1)) == NULL) {
  435. if (!silent)
  436. printk("VFS: unable to read V7 FS superblock on "
  437. "device %s.\n", sb->s_id);
  438. goto failed;
  439. }
  440. /* Try PDP-11 UNIX */
  441. sbi->s_bytesex = BYTESEX_PDP;
  442. if (v7_sanity_check(sb, bh))
  443. goto detected;
  444. /* Try PC/IX, v7/x86 */
  445. sbi->s_bytesex = BYTESEX_LE;
  446. if (v7_sanity_check(sb, bh))
  447. goto detected;
  448. goto failed;
  449. detected:
  450. sbi->s_bh1 = bh;
  451. sbi->s_bh2 = bh;
  452. if (complete_read_super(sb, silent, 1))
  453. return 0;
  454. failed:
  455. printk(KERN_ERR "VFS: could not find a valid V7 on %s.\n",
  456. sb->s_id);
  457. brelse(bh);
  458. kfree(sbi);
  459. return -EINVAL;
  460. }
  461. /* Every kernel module contains stuff like this. */
  462. static struct dentry *sysv_mount(struct file_system_type *fs_type,
  463. int flags, const char *dev_name, void *data)
  464. {
  465. return mount_bdev(fs_type, flags, dev_name, data, sysv_fill_super);
  466. }
  467. static struct dentry *v7_mount(struct file_system_type *fs_type,
  468. int flags, const char *dev_name, void *data)
  469. {
  470. return mount_bdev(fs_type, flags, dev_name, data, v7_fill_super);
  471. }
  472. static struct file_system_type sysv_fs_type = {
  473. .owner = THIS_MODULE,
  474. .name = "sysv",
  475. .mount = sysv_mount,
  476. .kill_sb = kill_block_super,
  477. .fs_flags = FS_REQUIRES_DEV,
  478. };
  479. MODULE_ALIAS_FS("sysv");
  480. static struct file_system_type v7_fs_type = {
  481. .owner = THIS_MODULE,
  482. .name = "v7",
  483. .mount = v7_mount,
  484. .kill_sb = kill_block_super,
  485. .fs_flags = FS_REQUIRES_DEV,
  486. };
  487. MODULE_ALIAS_FS("v7");
  488. MODULE_ALIAS("v7");
  489. static int __init init_sysv_fs(void)
  490. {
  491. int error;
  492. error = sysv_init_icache();
  493. if (error)
  494. goto out;
  495. error = register_filesystem(&sysv_fs_type);
  496. if (error)
  497. goto destroy_icache;
  498. error = register_filesystem(&v7_fs_type);
  499. if (error)
  500. goto unregister;
  501. return 0;
  502. unregister:
  503. unregister_filesystem(&sysv_fs_type);
  504. destroy_icache:
  505. sysv_destroy_icache();
  506. out:
  507. return error;
  508. }
  509. static void __exit exit_sysv_fs(void)
  510. {
  511. unregister_filesystem(&sysv_fs_type);
  512. unregister_filesystem(&v7_fs_type);
  513. sysv_destroy_icache();
  514. }
  515. module_init(init_sysv_fs)
  516. module_exit(exit_sysv_fs)
  517. MODULE_LICENSE("GPL");