Add a file system (linux2.6.10)

Source: Internet
Author: User
Tags symlink
Add a file system (linux2.6.10)-Linux general technology-Linux programming and kernel information. The following is a detailed description. Add a file system named myext3 that is exactly the same as ext3

I. Code copy

Cd/usr/src/linux-2.6.10/fs

Mkdir myext3

Cp-r ext3/. myext3 /.

Notes: For. H files, you can directly use the four header files ext3_fs.h, ext3_fs_ I .h, ext3_fs_sb.h, and ext3_jbd.h IN THE include/linux directory. If you need your own header file to add additional instructions and code, you can create it in the include/linux directory, for example, myext3_fs.h.

Ii. Modification of codes and related configuration files

1. Modify fs/myext3/super. c

A: Change. name = "ext3" in the definition of struct ext3_fs_type to. name = "myext3"
And replace the following:
Init_ext3_fs-> init_myext3_fs
Exit_ext3_fs-> exit_myext3_fs
Ext3_fs_type-> myext3_fs_type

B: In the init_inodecache function, replace "ext3_inode_cache" with "myext3_inode_cache ".
Because the kmem_cache_create function is uniquely allocated according to the string when creating the cache, you need to change it to avoid repeated points.
Configuration, which is in conflict with the ext3 file system.

2. Modify fs/myext3/xattr. c

In the init_ext3_xattr function, replace "ext3_xattr" with "myext3_xattr ". The reason is the same as 1. B.

3. Modify fs/Kconfig
Join
Config MYEXT3_FS
Tristate "My ext3 file system support"
Help
My own ext3 file system.

4. Modify fs/Makefile
Join
Obj-$ (CONFIG_MYEXT3_FS) + = myext3/# add by hrr for my own ext3

5. Modify fs/myext3/Makefile

The original Makefile is

#
# Makefile for the linux ext3-filesystem routines.
#

Obj-$ (CONFIG_EXT3_FS) + = ext3.o

Ext3-y: = balloc. o bitmap. o dir. o file. o fsync. o ialloc. o inode. o \
Ioctl. o namei. o super. o symlink. o hash. o resize. o

Ext3-$ (CONFIG_EXT3_FS_XATTR) + = xattr. o xattr_user.o xattr_trusted.o
Ext3-$ (CONFIG_EXT3_FS_POSIX_ACL) + = acl. o
Ext3-$ (CONFIG_EXT3_FS_SECURITY) + = xattr_security.o

Change

#
# Makefile for the linux ext3-filesystem routines.
#

Obj-$ (CONFIG_MYEXT3_FS) + = myext3.o

Myext3-y: = balloc. o bitmap. o dir. o file. o fsync. o ialloc. o inode. o \
Ioctl. o namei. o super. o symlink. o hash. o resize. o

Myext3-$ (CONFIG_EXT3_FS_XATTR) + = xattr. o xattr_user.o xattr_trusted.o
Myext3-$ (CONFIG_EXT3_FS_POSIX_ACL) + = acl. o
Myext3-$ (CONFIG_EXT3_FS_SECURITY) + = xattr_security.o

Change the corresponding ext3 to myext3.

3. Compile the connection to generate the Kernel File

1. make menuconfig

All other options are modified based on the default configuration. You only need to load myext3 as the kernel module, that is, select M.

Notes: Y (directly compiled into the kernel), N (not selected), and M (compiled into modules)

2. make clean

This step is not required

3. make

Make is equivalent to the union of make bzImage and make modules.

4. make modules_install

During this step, the information displayed on the console should include:
INSTALL fs/myext3/myext3.ko

In this case, you can run the ls/lib/modules/command to view the corresponding module.

Myext3.ko is in the/lib/modules/2.6.10-ac12/kernel/fs/myext3/directory.

5. make install

Notes1: You can also modify myext3 as needed, such as deleting unnecessary functions and adding new functions.

Notes2: all of the above commands run under the/usr/src/linux-2.6.10 directory

4. Add partitions and create mount points to use the myext3 file system.

1. Use fdisk to create partitions, such as/dev/sda6.

2. mkfs. ext3/dev/sda6

Format/dev/sda6 into an ext3 file system. Theoretically, myext3 and ext3 are exactly the same, except the name. In
Step 4: Use the myext3 file system format to mount the ext3 file system we just created.

3. modprobe myext3

Load the myext3 Module

4. mount-t myext3/dev/sda6/mnt/test

Mount/dev/sda6 to the/mnt/test directory. Please note that the parameter we use is-t myext3, that is, myext3
The file system format is used to mount the file system. It turns out that the new kernel has supported our new file system.
Myext3.

In this case, the linux default ext3 file system is used elsewhere in the system. Myext3 is used in the/mnt/test directory. In the future, we can modify myext3 as needed.

Notes: After modifying the myext3 module, run the following command to re-compile the module to test the new myext3 function.

Cd/usr/src/linux-2.6.10
Make modules
Lsmod // You Can See myext3 Module Used by 1
Umount/mnt/test/
Lsmod // now you can see myext3 Module Used by 0, so that you can delete myext3 Module
Rmmod myext3 // Delete the myext3 Module
Insmod fs/myext3/myext3.ko // load the new myext3 Module
Lsmod // you can see the myext3 Module.
Mount-t myext3/dev/sda6/mnt/test

Notes: to use commands and system calls related to extended attributes at the application layer, you must add the user_xattr option during mount,

That is, mount-t ext3audit-o user_xattr/dev/sda6/mnt/testaudit

Then you can go to the/mnt/test directory and test the modified myext3 file system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.