Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  linux/fs/sysv/inode.c
0004  *
0005  *  minix/inode.c
0006  *  Copyright (C) 1991, 1992  Linus Torvalds
0007  *
0008  *  xenix/inode.c
0009  *  Copyright (C) 1992  Doug Evans
0010  *
0011  *  coh/inode.c
0012  *  Copyright (C) 1993  Pascal Haible, Bruno Haible
0013  *
0014  *  sysv/inode.c
0015  *  Copyright (C) 1993  Paul B. Monday
0016  *
0017  *  sysv/inode.c
0018  *  Copyright (C) 1993  Bruno Haible
0019  *  Copyright (C) 1997, 1998  Krzysztof G. Baranowski
0020  *
0021  *  This file contains code for read/parsing the superblock.
0022  */
0023 
0024 #include <linux/module.h>
0025 #include <linux/init.h>
0026 #include <linux/slab.h>
0027 #include <linux/buffer_head.h>
0028 #include "sysv.h"
0029 
0030 /*
0031  * The following functions try to recognize specific filesystems.
0032  *
0033  * We recognize:
0034  * - Xenix FS by its magic number.
0035  * - SystemV FS by its magic number.
0036  * - Coherent FS by its funny fname/fpack field.
0037  * - SCO AFS by s_nfree == 0xffff
0038  * - V7 FS has no distinguishing features.
0039  *
0040  * We discriminate among SystemV4 and SystemV2 FS by the assumption that
0041  * the time stamp is not < 01-01-1980.
0042  */
0043 
0044 enum {
0045     JAN_1_1980 = (10*365 + 2) * 24 * 60 * 60
0046 };
0047 
0048 static void detected_xenix(struct sysv_sb_info *sbi, unsigned *max_links)
0049 {
0050     struct buffer_head *bh1 = sbi->s_bh1;
0051     struct buffer_head *bh2 = sbi->s_bh2;
0052     struct xenix_super_block * sbd1;
0053     struct xenix_super_block * sbd2;
0054 
0055     if (bh1 != bh2)
0056         sbd1 = sbd2 = (struct xenix_super_block *) bh1->b_data;
0057     else {
0058         /* block size = 512, so bh1 != bh2 */
0059         sbd1 = (struct xenix_super_block *) bh1->b_data;
0060         sbd2 = (struct xenix_super_block *) (bh2->b_data - 512);
0061     }
0062 
0063     *max_links = XENIX_LINK_MAX;
0064     sbi->s_fic_size = XENIX_NICINOD;
0065     sbi->s_flc_size = XENIX_NICFREE;
0066     sbi->s_sbd1 = (char *)sbd1;
0067     sbi->s_sbd2 = (char *)sbd2;
0068     sbi->s_sb_fic_count = &sbd1->s_ninode;
0069     sbi->s_sb_fic_inodes = &sbd1->s_inode[0];
0070     sbi->s_sb_total_free_inodes = &sbd2->s_tinode;
0071     sbi->s_bcache_count = &sbd1->s_nfree;
0072     sbi->s_bcache = &sbd1->s_free[0];
0073     sbi->s_free_blocks = &sbd2->s_tfree;
0074     sbi->s_sb_time = &sbd2->s_time;
0075     sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd1->s_isize);
0076     sbi->s_nzones = fs32_to_cpu(sbi, sbd1->s_fsize);
0077 }
0078 
0079 static void detected_sysv4(struct sysv_sb_info *sbi, unsigned *max_links)
0080 {
0081     struct sysv4_super_block * sbd;
0082     struct buffer_head *bh1 = sbi->s_bh1;
0083     struct buffer_head *bh2 = sbi->s_bh2;
0084 
0085     if (bh1 == bh2)
0086         sbd = (struct sysv4_super_block *) (bh1->b_data + BLOCK_SIZE/2);
0087     else
0088         sbd = (struct sysv4_super_block *) bh2->b_data;
0089 
0090     *max_links = SYSV_LINK_MAX;
0091     sbi->s_fic_size = SYSV_NICINOD;
0092     sbi->s_flc_size = SYSV_NICFREE;
0093     sbi->s_sbd1 = (char *)sbd;
0094     sbi->s_sbd2 = (char *)sbd;
0095     sbi->s_sb_fic_count = &sbd->s_ninode;
0096     sbi->s_sb_fic_inodes = &sbd->s_inode[0];
0097     sbi->s_sb_total_free_inodes = &sbd->s_tinode;
0098     sbi->s_bcache_count = &sbd->s_nfree;
0099     sbi->s_bcache = &sbd->s_free[0];
0100     sbi->s_free_blocks = &sbd->s_tfree;
0101     sbi->s_sb_time = &sbd->s_time;
0102     sbi->s_sb_state = &sbd->s_state;
0103     sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
0104     sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
0105 }
0106 
0107 static void detected_sysv2(struct sysv_sb_info *sbi, unsigned *max_links)
0108 {
0109     struct sysv2_super_block *sbd;
0110     struct buffer_head *bh1 = sbi->s_bh1;
0111     struct buffer_head *bh2 = sbi->s_bh2;
0112 
0113     if (bh1 == bh2)
0114         sbd = (struct sysv2_super_block *) (bh1->b_data + BLOCK_SIZE/2);
0115     else
0116         sbd = (struct sysv2_super_block *) bh2->b_data;
0117 
0118     *max_links = SYSV_LINK_MAX;
0119     sbi->s_fic_size = SYSV_NICINOD;
0120     sbi->s_flc_size = SYSV_NICFREE;
0121     sbi->s_sbd1 = (char *)sbd;
0122     sbi->s_sbd2 = (char *)sbd;
0123     sbi->s_sb_fic_count = &sbd->s_ninode;
0124     sbi->s_sb_fic_inodes = &sbd->s_inode[0];
0125     sbi->s_sb_total_free_inodes = &sbd->s_tinode;
0126     sbi->s_bcache_count = &sbd->s_nfree;
0127     sbi->s_bcache = &sbd->s_free[0];
0128     sbi->s_free_blocks = &sbd->s_tfree;
0129     sbi->s_sb_time = &sbd->s_time;
0130     sbi->s_sb_state = &sbd->s_state;
0131     sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
0132     sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
0133 }
0134 
0135 static void detected_coherent(struct sysv_sb_info *sbi, unsigned *max_links)
0136 {
0137     struct coh_super_block * sbd;
0138     struct buffer_head *bh1 = sbi->s_bh1;
0139 
0140     sbd = (struct coh_super_block *) bh1->b_data;
0141 
0142     *max_links = COH_LINK_MAX;
0143     sbi->s_fic_size = COH_NICINOD;
0144     sbi->s_flc_size = COH_NICFREE;
0145     sbi->s_sbd1 = (char *)sbd;
0146     sbi->s_sbd2 = (char *)sbd;
0147     sbi->s_sb_fic_count = &sbd->s_ninode;
0148     sbi->s_sb_fic_inodes = &sbd->s_inode[0];
0149     sbi->s_sb_total_free_inodes = &sbd->s_tinode;
0150     sbi->s_bcache_count = &sbd->s_nfree;
0151     sbi->s_bcache = &sbd->s_free[0];
0152     sbi->s_free_blocks = &sbd->s_tfree;
0153     sbi->s_sb_time = &sbd->s_time;
0154     sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
0155     sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
0156 }
0157 
0158 static void detected_v7(struct sysv_sb_info *sbi, unsigned *max_links)
0159 {
0160     struct buffer_head *bh2 = sbi->s_bh2;
0161     struct v7_super_block *sbd = (struct v7_super_block *)bh2->b_data;
0162 
0163     *max_links = V7_LINK_MAX;
0164     sbi->s_fic_size = V7_NICINOD;
0165     sbi->s_flc_size = V7_NICFREE;
0166     sbi->s_sbd1 = (char *)sbd;
0167     sbi->s_sbd2 = (char *)sbd;
0168     sbi->s_sb_fic_count = &sbd->s_ninode;
0169     sbi->s_sb_fic_inodes = &sbd->s_inode[0];
0170     sbi->s_sb_total_free_inodes = &sbd->s_tinode;
0171     sbi->s_bcache_count = &sbd->s_nfree;
0172     sbi->s_bcache = &sbd->s_free[0];
0173     sbi->s_free_blocks = &sbd->s_tfree;
0174     sbi->s_sb_time = &sbd->s_time;
0175     sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd->s_isize);
0176     sbi->s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
0177 }
0178 
0179 static int detect_xenix(struct sysv_sb_info *sbi, struct buffer_head *bh)
0180 {
0181     struct xenix_super_block *sbd = (struct xenix_super_block *)bh->b_data;
0182     if (*(__le32 *)&sbd->s_magic == cpu_to_le32(0x2b5544))
0183         sbi->s_bytesex = BYTESEX_LE;
0184     else if (*(__be32 *)&sbd->s_magic == cpu_to_be32(0x2b5544))
0185         sbi->s_bytesex = BYTESEX_BE;
0186     else
0187         return 0;
0188     switch (fs32_to_cpu(sbi, sbd->s_type)) {
0189     case 1:
0190         sbi->s_type = FSTYPE_XENIX;
0191         return 1;
0192     case 2:
0193         sbi->s_type = FSTYPE_XENIX;
0194         return 2;
0195     default:
0196         return 0;
0197     }
0198 }
0199 
0200 static int detect_sysv(struct sysv_sb_info *sbi, struct buffer_head *bh)
0201 {
0202     struct super_block *sb = sbi->s_sb;
0203     /* All relevant fields are at the same offsets in R2 and R4 */
0204     struct sysv4_super_block * sbd;
0205     u32 type;
0206 
0207     sbd = (struct sysv4_super_block *) (bh->b_data + BLOCK_SIZE/2);
0208     if (*(__le32 *)&sbd->s_magic == cpu_to_le32(0xfd187e20))
0209         sbi->s_bytesex = BYTESEX_LE;
0210     else if (*(__be32 *)&sbd->s_magic == cpu_to_be32(0xfd187e20))
0211         sbi->s_bytesex = BYTESEX_BE;
0212     else
0213         return 0;
0214 
0215     type = fs32_to_cpu(sbi, sbd->s_type);
0216  
0217     if (fs16_to_cpu(sbi, sbd->s_nfree) == 0xffff) {
0218         sbi->s_type = FSTYPE_AFS;
0219         sbi->s_forced_ro = 1;
0220         if (!sb_rdonly(sb)) {
0221             printk("SysV FS: SCO EAFS on %s detected, " 
0222                 "forcing read-only mode.\n", 
0223                 sb->s_id);
0224         }
0225         return type;
0226     }
0227  
0228     if (fs32_to_cpu(sbi, sbd->s_time) < JAN_1_1980) {
0229         /* this is likely to happen on SystemV2 FS */
0230         if (type > 3 || type < 1)
0231             return 0;
0232         sbi->s_type = FSTYPE_SYSV2;
0233         return type;
0234     }
0235     if ((type > 3 || type < 1) && (type > 0x30 || type < 0x10))
0236         return 0;
0237 
0238     /* On Interactive Unix (ISC) Version 4.0/3.x s_type field = 0x10,
0239        0x20 or 0x30 indicates that symbolic links and the 14-character
0240        filename limit is gone. Due to lack of information about this
0241            feature read-only mode seems to be a reasonable approach... -KGB */
0242 
0243     if (type >= 0x10) {
0244         printk("SysV FS: can't handle long file names on %s, "
0245                "forcing read-only mode.\n", sb->s_id);
0246         sbi->s_forced_ro = 1;
0247     }
0248 
0249     sbi->s_type = FSTYPE_SYSV4;
0250     return type >= 0x10 ? type >> 4 : type;
0251 }
0252 
0253 static int detect_coherent(struct sysv_sb_info *sbi, struct buffer_head *bh)
0254 {
0255     struct coh_super_block * sbd;
0256 
0257     sbd = (struct coh_super_block *) (bh->b_data + BLOCK_SIZE/2);
0258     if ((memcmp(sbd->s_fname,"noname",6) && memcmp(sbd->s_fname,"xxxxx ",6))
0259         || (memcmp(sbd->s_fpack,"nopack",6) && memcmp(sbd->s_fpack,"xxxxx\n",6)))
0260         return 0;
0261     sbi->s_bytesex = BYTESEX_PDP;
0262     sbi->s_type = FSTYPE_COH;
0263     return 1;
0264 }
0265 
0266 static int detect_sysv_odd(struct sysv_sb_info *sbi, struct buffer_head *bh)
0267 {
0268     int size = detect_sysv(sbi, bh);
0269 
0270     return size>2 ? 0 : size;
0271 }
0272 
0273 static struct {
0274     int block;
0275     int (*test)(struct sysv_sb_info *, struct buffer_head *);
0276 } flavours[] = {
0277     {1, detect_xenix},
0278     {0, detect_sysv},
0279     {0, detect_coherent},
0280     {9, detect_sysv_odd},
0281     {15,detect_sysv_odd},
0282     {18,detect_sysv},
0283 };
0284 
0285 static char *flavour_names[] = {
0286     [FSTYPE_XENIX]  = "Xenix",
0287     [FSTYPE_SYSV4]  = "SystemV",
0288     [FSTYPE_SYSV2]  = "SystemV Release 2",
0289     [FSTYPE_COH]    = "Coherent",
0290     [FSTYPE_V7] = "V7",
0291     [FSTYPE_AFS]    = "AFS",
0292 };
0293 
0294 static void (*flavour_setup[])(struct sysv_sb_info *, unsigned *) = {
0295     [FSTYPE_XENIX]  = detected_xenix,
0296     [FSTYPE_SYSV4]  = detected_sysv4,
0297     [FSTYPE_SYSV2]  = detected_sysv2,
0298     [FSTYPE_COH]    = detected_coherent,
0299     [FSTYPE_V7] = detected_v7,
0300     [FSTYPE_AFS]    = detected_sysv4,
0301 };
0302 
0303 static int complete_read_super(struct super_block *sb, int silent, int size)
0304 {
0305     struct sysv_sb_info *sbi = SYSV_SB(sb);
0306     struct inode *root_inode;
0307     char *found = flavour_names[sbi->s_type];
0308     u_char n_bits = size+8;
0309     int bsize = 1 << n_bits;
0310     int bsize_4 = bsize >> 2;
0311 
0312     sbi->s_firstinodezone = 2;
0313 
0314     flavour_setup[sbi->s_type](sbi, &sb->s_max_links);
0315     if (sbi->s_firstdatazone < sbi->s_firstinodezone)
0316         return 0;
0317 
0318     sbi->s_ndatazones = sbi->s_nzones - sbi->s_firstdatazone;
0319     sbi->s_inodes_per_block = bsize >> 6;
0320     sbi->s_inodes_per_block_1 = (bsize >> 6)-1;
0321     sbi->s_inodes_per_block_bits = n_bits-6;
0322     sbi->s_ind_per_block = bsize_4;
0323     sbi->s_ind_per_block_2 = bsize_4*bsize_4;
0324     sbi->s_toobig_block = 10 + bsize_4 * (1 + bsize_4 * (1 + bsize_4));
0325     sbi->s_ind_per_block_bits = n_bits-2;
0326 
0327     sbi->s_ninodes = (sbi->s_firstdatazone - sbi->s_firstinodezone)
0328         << sbi->s_inodes_per_block_bits;
0329 
0330     if (!silent)
0331         printk("VFS: Found a %s FS (block size = %ld) on device %s\n",
0332                found, sb->s_blocksize, sb->s_id);
0333 
0334     sb->s_magic = SYSV_MAGIC_BASE + sbi->s_type;
0335     /* set up enough so that it can read an inode */
0336     sb->s_op = &sysv_sops;
0337     if (sbi->s_forced_ro)
0338         sb->s_flags |= SB_RDONLY;
0339     root_inode = sysv_iget(sb, SYSV_ROOT_INO);
0340     if (IS_ERR(root_inode)) {
0341         printk("SysV FS: get root inode failed\n");
0342         return 0;
0343     }
0344     sb->s_root = d_make_root(root_inode);
0345     if (!sb->s_root) {
0346         printk("SysV FS: get root dentry failed\n");
0347         return 0;
0348     }
0349     return 1;
0350 }
0351 
0352 static int sysv_fill_super(struct super_block *sb, void *data, int silent)
0353 {
0354     struct buffer_head *bh1, *bh = NULL;
0355     struct sysv_sb_info *sbi;
0356     unsigned long blocknr;
0357     int size = 0, i;
0358     
0359     BUILD_BUG_ON(1024 != sizeof (struct xenix_super_block));
0360     BUILD_BUG_ON(512 != sizeof (struct sysv4_super_block));
0361     BUILD_BUG_ON(512 != sizeof (struct sysv2_super_block));
0362     BUILD_BUG_ON(500 != sizeof (struct coh_super_block));
0363     BUILD_BUG_ON(64 != sizeof (struct sysv_inode));
0364 
0365     sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
0366     if (!sbi)
0367         return -ENOMEM;
0368 
0369     sbi->s_sb = sb;
0370     sbi->s_block_base = 0;
0371     mutex_init(&sbi->s_lock);
0372     sb->s_fs_info = sbi;
0373     sb->s_time_min = 0;
0374     sb->s_time_max = U32_MAX;
0375     sb_set_blocksize(sb, BLOCK_SIZE);
0376 
0377     for (i = 0; i < ARRAY_SIZE(flavours) && !size; i++) {
0378         brelse(bh);
0379         bh = sb_bread(sb, flavours[i].block);
0380         if (!bh)
0381             continue;
0382         size = flavours[i].test(SYSV_SB(sb), bh);
0383     }
0384 
0385     if (!size)
0386         goto Eunknown;
0387 
0388     switch (size) {
0389         case 1:
0390             blocknr = bh->b_blocknr << 1;
0391             brelse(bh);
0392             sb_set_blocksize(sb, 512);
0393             bh1 = sb_bread(sb, blocknr);
0394             bh = sb_bread(sb, blocknr + 1);
0395             break;
0396         case 2:
0397             bh1 = bh;
0398             break;
0399         case 3:
0400             blocknr = bh->b_blocknr >> 1;
0401             brelse(bh);
0402             sb_set_blocksize(sb, 2048);
0403             bh1 = bh = sb_bread(sb, blocknr);
0404             break;
0405         default:
0406             goto Ebadsize;
0407     }
0408 
0409     if (bh && bh1) {
0410         sbi->s_bh1 = bh1;
0411         sbi->s_bh2 = bh;
0412         if (complete_read_super(sb, silent, size))
0413             return 0;
0414     }
0415 
0416     brelse(bh1);
0417     brelse(bh);
0418     sb_set_blocksize(sb, BLOCK_SIZE);
0419     printk("oldfs: cannot read superblock\n");
0420 failed:
0421     kfree(sbi);
0422     return -EINVAL;
0423 
0424 Eunknown:
0425     brelse(bh);
0426     if (!silent)
0427         printk("VFS: unable to find oldfs superblock on device %s\n",
0428             sb->s_id);
0429     goto failed;
0430 Ebadsize:
0431     brelse(bh);
0432     if (!silent)
0433         printk("VFS: oldfs: unsupported block size (%dKb)\n",
0434             1<<(size-2));
0435     goto failed;
0436 }
0437 
0438 static int v7_sanity_check(struct super_block *sb, struct buffer_head *bh)
0439 {
0440     struct v7_super_block *v7sb;
0441     struct sysv_inode *v7i;
0442     struct buffer_head *bh2;
0443     struct sysv_sb_info *sbi;
0444 
0445     sbi = sb->s_fs_info;
0446 
0447     /* plausibility check on superblock */
0448     v7sb = (struct v7_super_block *) bh->b_data;
0449     if (fs16_to_cpu(sbi, v7sb->s_nfree) > V7_NICFREE ||
0450         fs16_to_cpu(sbi, v7sb->s_ninode) > V7_NICINOD ||
0451         fs32_to_cpu(sbi, v7sb->s_fsize) > V7_MAXSIZE)
0452         return 0;
0453 
0454     /* plausibility check on root inode: it is a directory,
0455        with a nonzero size that is a multiple of 16 */
0456     bh2 = sb_bread(sb, 2);
0457     if (bh2 == NULL)
0458         return 0;
0459 
0460     v7i = (struct sysv_inode *)(bh2->b_data + 64);
0461     if ((fs16_to_cpu(sbi, v7i->i_mode) & ~0777) != S_IFDIR ||
0462         (fs32_to_cpu(sbi, v7i->i_size) == 0) ||
0463         (fs32_to_cpu(sbi, v7i->i_size) & 017) ||
0464         (fs32_to_cpu(sbi, v7i->i_size) > V7_NFILES *
0465          sizeof(struct sysv_dir_entry))) {
0466         brelse(bh2);
0467         return 0;
0468     }
0469 
0470     brelse(bh2);
0471     return 1;
0472 }
0473 
0474 static int v7_fill_super(struct super_block *sb, void *data, int silent)
0475 {
0476     struct sysv_sb_info *sbi;
0477     struct buffer_head *bh;
0478 
0479     BUILD_BUG_ON(sizeof(struct v7_super_block) != 440);
0480     BUILD_BUG_ON(sizeof(struct sysv_inode) != 64);
0481 
0482     sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
0483     if (!sbi)
0484         return -ENOMEM;
0485 
0486     sbi->s_sb = sb;
0487     sbi->s_block_base = 0;
0488     sbi->s_type = FSTYPE_V7;
0489     mutex_init(&sbi->s_lock);
0490     sb->s_fs_info = sbi;
0491     sb->s_time_min = 0;
0492     sb->s_time_max = U32_MAX;
0493     
0494     sb_set_blocksize(sb, 512);
0495 
0496     if ((bh = sb_bread(sb, 1)) == NULL) {
0497         if (!silent)
0498             printk("VFS: unable to read V7 FS superblock on "
0499                    "device %s.\n", sb->s_id);
0500         goto failed;
0501     }
0502 
0503     /* Try PDP-11 UNIX */
0504     sbi->s_bytesex = BYTESEX_PDP;
0505     if (v7_sanity_check(sb, bh))
0506         goto detected;
0507 
0508     /* Try PC/IX, v7/x86 */
0509     sbi->s_bytesex = BYTESEX_LE;
0510     if (v7_sanity_check(sb, bh))
0511         goto detected;
0512 
0513     goto failed;
0514 
0515 detected:
0516     sbi->s_bh1 = bh;
0517     sbi->s_bh2 = bh;
0518     if (complete_read_super(sb, silent, 1))
0519         return 0;
0520 
0521 failed:
0522     printk(KERN_ERR "VFS: could not find a valid V7 on %s.\n",
0523         sb->s_id);
0524     brelse(bh);
0525     kfree(sbi);
0526     return -EINVAL;
0527 }
0528 
0529 /* Every kernel module contains stuff like this. */
0530 
0531 static struct dentry *sysv_mount(struct file_system_type *fs_type,
0532     int flags, const char *dev_name, void *data)
0533 {
0534     return mount_bdev(fs_type, flags, dev_name, data, sysv_fill_super);
0535 }
0536 
0537 static struct dentry *v7_mount(struct file_system_type *fs_type,
0538     int flags, const char *dev_name, void *data)
0539 {
0540     return mount_bdev(fs_type, flags, dev_name, data, v7_fill_super);
0541 }
0542 
0543 static struct file_system_type sysv_fs_type = {
0544     .owner      = THIS_MODULE,
0545     .name       = "sysv",
0546     .mount      = sysv_mount,
0547     .kill_sb    = kill_block_super,
0548     .fs_flags   = FS_REQUIRES_DEV,
0549 };
0550 MODULE_ALIAS_FS("sysv");
0551 
0552 static struct file_system_type v7_fs_type = {
0553     .owner      = THIS_MODULE,
0554     .name       = "v7",
0555     .mount      = v7_mount,
0556     .kill_sb    = kill_block_super,
0557     .fs_flags   = FS_REQUIRES_DEV,
0558 };
0559 MODULE_ALIAS_FS("v7");
0560 MODULE_ALIAS("v7");
0561 
0562 static int __init init_sysv_fs(void)
0563 {
0564     int error;
0565 
0566     error = sysv_init_icache();
0567     if (error)
0568         goto out;
0569     error = register_filesystem(&sysv_fs_type);
0570     if (error)
0571         goto destroy_icache;
0572     error = register_filesystem(&v7_fs_type);
0573     if (error)
0574         goto unregister;
0575     return 0;
0576 
0577 unregister:
0578     unregister_filesystem(&sysv_fs_type);
0579 destroy_icache:
0580     sysv_destroy_icache();
0581 out:
0582     return error;
0583 }
0584 
0585 static void __exit exit_sysv_fs(void)
0586 {
0587     unregister_filesystem(&sysv_fs_type);
0588     unregister_filesystem(&v7_fs_type);
0589     sysv_destroy_icache();
0590 }
0591 
0592 module_init(init_sysv_fs)
0593 module_exit(exit_sysv_fs)
0594 MODULE_LICENSE("GPL");