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

重启即可。

你可能感兴趣的:(linux2.6内核中如何添加新的文件系统)