Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ntfs3: serve as alias for the legacy ntfs driver

Johan Hovold reported that removing the legacy ntfs driver broke boot
for him since his fstab uses the legacy ntfs driver to access firmware
from the original Windows partition.

Use ntfs3 as an alias for legacy ntfs if CONFIG_NTFS_FS is selected.
This is similar to how ext3 is treated.

Link: https://lore.kernel.org/r/Zf2zPf5TO5oYt3I3@hovoldconsulting.com
Link: https://lore.kernel.org/r/20240325-hinkriegen-zuziehen-d7e2c490427a@brauner
Fixes: 7ffa8f3d3023 ("fs: Remove NTFS classic")
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+40
+9
fs/ntfs3/Kconfig
··· 46 46 NOTE: this is linux only feature. Windows will ignore these ACLs. 47 47 48 48 If you don't know what Access Control Lists are, say N. 49 + 50 + config NTFS_FS 51 + tristate "NTFS file system support" 52 + select NTFS3_FS 53 + select BUFFER_HEAD 54 + select NLS 55 + help 56 + This config option is here only for backward compatibility. NTFS 57 + filesystem is now handled by the NTFS3 driver.
+31
fs/ntfs3/super.c
··· 1798 1798 .kill_sb = ntfs3_kill_sb, 1799 1799 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, 1800 1800 }; 1801 + 1802 + #if IS_ENABLED(CONFIG_NTFS_FS) 1803 + static struct file_system_type ntfs_legacy_fs_type = { 1804 + .owner = THIS_MODULE, 1805 + .name = "ntfs", 1806 + .init_fs_context = ntfs_init_fs_context, 1807 + .parameters = ntfs_fs_parameters, 1808 + .kill_sb = ntfs3_kill_sb, 1809 + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, 1810 + }; 1811 + MODULE_ALIAS_FS("ntfs"); 1812 + 1813 + static inline void register_as_ntfs_legacy(void) 1814 + { 1815 + int err = register_filesystem(&ntfs_legacy_fs_type); 1816 + if (err) 1817 + pr_warn("ntfs3: Failed to register legacy ntfs filesystem driver: %d\n", err); 1818 + } 1819 + 1820 + static inline void unregister_as_ntfs_legacy(void) 1821 + { 1822 + unregister_filesystem(&ntfs_legacy_fs_type); 1823 + } 1824 + #else 1825 + static inline void register_as_ntfs_legacy(void) {} 1826 + static inline void unregister_as_ntfs_legacy(void) {} 1827 + #endif 1828 + 1829 + 1801 1830 // clang-format on 1802 1831 1803 1832 static int __init init_ntfs_fs(void) ··· 1861 1832 goto out1; 1862 1833 } 1863 1834 1835 + register_as_ntfs_legacy(); 1864 1836 err = register_filesystem(&ntfs_fs_type); 1865 1837 if (err) 1866 1838 goto out; ··· 1879 1849 rcu_barrier(); 1880 1850 kmem_cache_destroy(ntfs_inode_cachep); 1881 1851 unregister_filesystem(&ntfs_fs_type); 1852 + unregister_as_ntfs_legacy(); 1882 1853 ntfs3_exit_bitmap(); 1883 1854 1884 1855 #ifdef CONFIG_PROC_FS