#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/major.h>
#include <linux/vfs.h>
#define ROMFS_MAGIC 0xEBAF3421
static struct kmem_cache *tbagfs_inode_cachep;
struct tbagfs_inode_info {
struct inode vfs_inode;
unsigned long i_metasize; /* size of non-data area */
unsigned long i_dataoffset; /* from the start of fs */
};
/*
* * fill in the superblock
* */
static int tbagfs_fill_super(struct super_block *sb, void *data, int silent)
{
return 0;
}
/*
* * get a superblock for mounting
* */
static int tbagfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name,
void *data, struct vfsmount *mnt)
{
int ret = -EINVAL;
if (ret == -EINVAL)
ret = get_sb_bdev(fs_type, flags, dev_name, data,
tbagfs_fill_super, mnt);
return ret;
}
static struct file_system_type tbagfs_fs_type = {
.owner = THIS_MODULE,
.name = "tbagfs",
.get_sb = tbagfs_get_sb,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};
static void tbagfs_i_init_once(void *_inode)
{
struct tbagfs_inode_info *inode = _inode;
inode_init_once(&inode->vfs_inode);
}
static int __init init_tbagfs_fs(void)
{
int ret = 0;
tbagfs_inode_cachep =
kmem_cache_create("tbagfs", sizeof(struct tbagfs_inode_info), 0,
SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
tbagfs_i_init_once);
if(!tbagfs_inode_cachep){
printk(KERN_ERR "TBAGFS error: Failed to initialise inode cache\n");
return -ENOMEM;
}
ret = register_filesystem(&tbagfs_fs_type);
if(ret){
printk(KERN_ERR "TBAGFS error: Failed to register filesystem\n");
goto error_register;
}
return 0;
error_register:
kmem_cache_destroy(tbagfs_inode_cachep);
return ret;
}
static void __exit exit_tbagfs_fs(void)
{
unregister_filesystem(&tbagfs_fs_type);
kmem_cache_destroy(tbagfs_inode_cachep);
}
module_init(init_tbagfs_fs)
module_exit(exit_tbagfs_fs)
MODULE_LICENSE("GPL");
|