前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >文件系统学习-1

文件系统学习-1

作者头像
用户3765803
发布2019-03-05 10:07:51
6220
发布2019-03-05 10:07:51
举报
文章被收录于专栏:悟空被FFmpeg玩悟空被FFmpeg玩

#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");

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2010-01-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
文件存储
文件存储(Cloud File Storage,CFS)为您提供安全可靠、可扩展的共享文件存储服务。文件存储可与腾讯云服务器、容器服务、批量计算等服务搭配使用,为多个计算节点提供容量和性能可弹性扩展的高性能共享存储。腾讯云文件存储的管理界面简单、易使用,可实现对现有应用的无缝集成;按实际用量付费,为您节约成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档