1 From 24b584240a0006ea7436cd35f5e8983eb76f1e6f Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Mon, 7 Dec 2009 14:08:51 -0500
4 Subject: [PATCH] ext4: Use ext4 file system driver for ext2/ext3 file system mounts
6 Add a new config option, CONFIG_EXT4_USE_FOR_EXT23 which if enabled,
7 will cause ext4 to be used for either ext2 or ext3 file system mounts
8 when ext2 or ext3 is not enabled in the configuration.
10 This allows minimalist kernel fanatics to drop to file system drivers
11 from their compiled kernel with out losing functionality.
13 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 fs/ext4/Kconfig | 10 +++++++++
16 fs/ext4/super.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 2 files changed, 68 insertions(+), 0 deletions(-)
21 @@ -26,6 +26,16 @@ config EXT4_FS
25 +config EXT4_USE_FOR_EXT23
26 + bool "Use ext4 for ext2/ext3 file systems"
27 + depends on !EXT3_FS || !EXT2_FS
30 + Allow the ext4 file system driver code to be used for ext2 or
31 + ext3 file system mounts. This allows users to reduce their
32 + compiled kernel size by using one file system driver for
33 + ext2, ext3, and ext4 file systems.
36 bool "Ext4 extended attributes"
40 @@ -3994,6 +3994,58 @@ static int ext4_get_sb(struct file_syste
41 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
44 +#if !defined(CONTIG_EXT2_FS) && defined(CONFIG_EXT4_USE_FOR_EXT23)
45 +static struct file_system_type ext2_fs_type = {
46 + .owner = THIS_MODULE,
48 + .get_sb = ext4_get_sb,
49 + .kill_sb = kill_block_super,
50 + .fs_flags = FS_REQUIRES_DEV,
53 +static inline void register_as_ext2(void)
55 + int err = register_filesystem(&ext2_fs_type);
58 + "EXT4-fs: Unable to register as ext2 (%d)\n", err);
61 +static inline void unregister_as_ext2(void)
63 + unregister_filesystem(&ext2_fs_type);
66 +static inline void register_as_ext2(void) { }
67 +static inline void unregister_as_ext2(void) { }
70 +#if !defined(CONTIG_EXT3_FS) && defined(CONFIG_EXT4_USE_FOR_EXT23)
71 +static struct file_system_type ext3_fs_type = {
72 + .owner = THIS_MODULE,
74 + .get_sb = ext4_get_sb,
75 + .kill_sb = kill_block_super,
76 + .fs_flags = FS_REQUIRES_DEV,
79 +static inline void register_as_ext3(void)
81 + int err = register_filesystem(&ext3_fs_type);
84 + "EXT4-fs: Unable to register as ext3 (%d)\n", err);
87 +static inline void unregister_as_ext3(void)
89 + unregister_filesystem(&ext3_fs_type);
92 +static inline void register_as_ext3(void) { }
93 +static inline void unregister_as_ext3(void) { }
96 static struct file_system_type ext4_fs_type = {
99 @@ -4024,11 +4076,15 @@ static int __init init_ext4_fs(void)
100 err = init_inodecache();
103 + register_as_ext2();
104 + register_as_ext3();
105 err = register_filesystem(&ext4_fs_type);
110 + unregister_as_ext2();
111 + unregister_as_ext3();
112 destroy_inodecache();
115 @@ -4044,6 +4100,8 @@ out4:
117 static void __exit exit_ext4_fs(void)
119 + unregister_as_ext2();
120 + unregister_as_ext3();
121 unregister_filesystem(&ext4_fs_type);
122 destroy_inodecache();