linux2.6内核中如何添加新的文件系统

《边干边学 - linux内核指导》中教授了如何在2.4内核中添加myext2文件系统的方法。2.6内核中文件组织稍有变化,通过试验,方法如下:

1. 将fs/ext2拷贝一份为fs/myext2

2. cd fs/myext2

3. sed -i "s/ext2/myext2/g" * //将fs/myext2目录下出现的所有ext2替换为myext2

4. sed -i "s/EXT2/MYEXT2/g" * //将fs/myext2目录下出现的所有EXT2替换为MYEXT2

5. 复制include/linux/ext2_fs.h 和 include/linux/ext2_fs_sb.h 为myext2_fs.h 和 myext2_fs_sb.h,并类似于3、4替换所有ext2为myext2 (大写和小写)

6. cp include/asm-generic/bitops/ext2-non-atomic.h asm-generic/bitops/myext2-non-atomic.h,然后替换所有ext2为myext2(大写和小写)

7.在 include/asm/bitops.h中添加如下内容:

#include <asm-generic/bitops/ext2-non-atomic.h> #define ext2_set_bit_atomic(lock,nr,addr) / test_and_set_bit((nr),(unsigned long*)addr) #define ext2_clear_bit_atomic(lock,nr,addr) / test_and_clear_bit((nr),(unsigned long*)addr) #include <asm-generic/bitops/myext2-non-atomic.h> #define myext2_set_bit_atomic(lock,nr,addr) / test_and_set_bit((nr),(unsigned long*)addr) #define myext2_clear_bit_atomic(lock,nr,addr) / test_and_clear_bit((nr),(unsigned long*)addr)

8. 修改make menuconfig中的编译选项:

vi fs/Kconfig

config FS_XIP # execute in place bool depends on EXT2_FS_XIP default y config MYEXT2_FS tristate "My Second extended fs support" help Myext2 is a experimental filesystem To compile this file system support as a module, choose M here: the module will be called myext2. Be aware however that the file system of your root partition (the one containing the directory /) cannot be compiled as a module, and so this could be dangerous. If unsure, say Y. config MYEXT2_FS_XATTR bool "Ext2 extended attributes" depends on MYEXT2_FS help Extended attributes are name:value pairs associated with inodes by the kernel or by users (see the attr(5) manual page, or visit <http://acl.bestbits.at/> for details).

照着EXT2的写就行了。

make menuconfig看一下,是不是发现多了几个编译选项?

9. make menuconfig

10. make -j4

11. make modules

12. make modules_install

13. make install

查看一下grub的配置(vi /etc/grub.conf)

重启即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值