aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-12-07 14:08:51 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-12-07 14:08:51 -0500
commit24b584240a0006ea7436cd35f5e8983eb76f1e6f (patch)
tree8b14be4ebcc93301bc63b061ecf89a16f114a31c /fs
parentc09eef305dd43846360944ad072f051f964fa383 (diff)
ext4: Use ext4 file system driver for ext2/ext3 file system mounts
Add a new config option, CONFIG_EXT4_USE_FOR_EXT23 which if enabled, will cause ext4 to be used for either ext2 or ext3 file system mounts when ext2 or ext3 is not enabled in the configuration. This allows minimalist kernel fanatics to drop to file system drivers from their compiled kernel with out losing functionality. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/Kconfig10
-rw-r--r--fs/ext4/super.c58
2 files changed, 68 insertions, 0 deletions
diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig
index 9f2d45d75b1a..a6b4e93833d6 100644
--- a/fs/ext4/Kconfig
+++ b/fs/ext4/Kconfig
@@ -26,6 +26,16 @@ config EXT4_FS
26 26
27 If unsure, say N. 27 If unsure, say N.
28 28
29config EXT4_USE_FOR_EXT23
30 bool "Use ext4 for ext2/ext3 file systems"
31 depends on !EXT3_FS || !EXT2_FS
32 default y
33 help
34 Allow the ext4 file system driver code to be used for ext2 or
35 ext3 file system mounts. This allows users to reduce their
36 compiled kernel size by using one file system driver for
37 ext2, ext3, and ext4 file systems.
38
29config EXT4_FS_XATTR 39config EXT4_FS_XATTR
30 bool "Ext4 extended attributes" 40 bool "Ext4 extended attributes"
31 depends on EXT4_FS 41 depends on EXT4_FS
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 5a2db612950b..30476daf966e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3960,6 +3960,58 @@ static int ext4_get_sb(struct file_system_type *fs_type, int flags,
3960 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); 3960 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
3961} 3961}
3962 3962
3963#if !defined(CONTIG_EXT2_FS) && defined(CONFIG_EXT4_USE_FOR_EXT23)
3964static struct file_system_type ext2_fs_type = {
3965 .owner = THIS_MODULE,
3966 .name = "ext2",
3967 .get_sb = ext4_get_sb,
3968 .kill_sb = kill_block_super,
3969 .fs_flags = FS_REQUIRES_DEV,
3970};
3971
3972static inline void register_as_ext2(void)
3973{
3974 int err = register_filesystem(&ext2_fs_type);
3975 if (err)
3976 printk(KERN_WARNING
3977 "EXT4-fs: Unable to register as ext2 (%d)\n", err);
3978}
3979
3980static inline void unregister_as_ext2(void)
3981{
3982 unregister_filesystem(&ext2_fs_type);
3983}
3984#else
3985static inline void register_as_ext2(void) { }
3986static inline void unregister_as_ext2(void) { }
3987#endif
3988
3989#if !defined(CONTIG_EXT3_FS) && defined(CONFIG_EXT4_USE_FOR_EXT23)
3990static struct file_system_type ext3_fs_type = {
3991 .owner = THIS_MODULE,
3992 .name = "ext3",
3993 .get_sb = ext4_get_sb,
3994 .kill_sb = kill_block_super,
3995 .fs_flags = FS_REQUIRES_DEV,
3996};
3997
3998static inline void register_as_ext3(void)
3999{
4000 int err = register_filesystem(&ext3_fs_type);
4001 if (err)
4002 printk(KERN_WARNING
4003 "EXT4-fs: Unable to register as ext3 (%d)\n", err);
4004}
4005
4006static inline void unregister_as_ext3(void)
4007{
4008 unregister_filesystem(&ext3_fs_type);
4009}
4010#else
4011static inline void register_as_ext3(void) { }
4012static inline void unregister_as_ext3(void) { }
4013#endif
4014
3963static struct file_system_type ext4_fs_type = { 4015static struct file_system_type ext4_fs_type = {
3964 .owner = THIS_MODULE, 4016 .owner = THIS_MODULE,
3965 .name = "ext4", 4017 .name = "ext4",
@@ -3989,11 +4041,15 @@ static int __init init_ext4_fs(void)
3989 err = init_inodecache(); 4041 err = init_inodecache();
3990 if (err) 4042 if (err)
3991 goto out1; 4043 goto out1;
4044 register_as_ext2();
4045 register_as_ext3();
3992 err = register_filesystem(&ext4_fs_type); 4046 err = register_filesystem(&ext4_fs_type);
3993 if (err) 4047 if (err)
3994 goto out; 4048 goto out;
3995 return 0; 4049 return 0;
3996out: 4050out:
4051 unregister_as_ext2();
4052 unregister_as_ext3();
3997 destroy_inodecache(); 4053 destroy_inodecache();
3998out1: 4054out1:
3999 exit_ext4_xattr(); 4055 exit_ext4_xattr();
@@ -4009,6 +4065,8 @@ out4:
4009 4065
4010static void __exit exit_ext4_fs(void) 4066static void __exit exit_ext4_fs(void)
4011{ 4067{
4068 unregister_as_ext2();
4069 unregister_as_ext3();
4012 unregister_filesystem(&ext4_fs_type); 4070 unregister_filesystem(&ext4_fs_type);
4013 destroy_inodecache(); 4071 destroy_inodecache();
4014 exit_ext4_xattr(); 4072 exit_ext4_xattr();