fs: sdfat: Add config option to register sdFAT for exFAT
authorPaul Keith <javelinanddart@gmail.com>
Fri, 2 Mar 2018 03:51:53 +0000 (04:51 +0100)
committerBruno Martins <bgcngm@gmail.com>
Sat, 22 May 2021 19:18:47 +0000 (21:18 +0200)
Change-Id: Id57abf0a4bd0b433fecc622eecb383cd4ea29d17
Signed-off-by: Paul Keith <javelinanddart@gmail.com>
fs/sdfat/Kconfig
fs/sdfat/sdfat.c

index e849b25af3474ca176261afb99df84be8d0a8944..62eb87bab6f6e5d3cf03b027b33c99faadf61402 100644 (file)
@@ -15,6 +15,13 @@ config SDFAT_FS
          To compile this as a module, choose M here: the module will be called
          sdfat_core and sdfat_fs.
 
+config SDFAT_USE_FOR_EXFAT
+       bool "Register sdFAT as exFAT"
+       default y
+       depends on SDFAT_FS && !EXFAT_FS
+       help
+         If you want to register sdFAT as available for exFAT, say Y.
+
 config SDFAT_DELAYED_META_DIRTY
        bool "Enable delayed metadata dirty"
        default y
index 516e15129cf5b5702d5235e36dfe9ce08a02bf98..3907d6604f623a335bf87f815b6d636d6b8f37fc 100644 (file)
@@ -5177,6 +5177,20 @@ static struct file_system_type sdfat_fs_type = {
        .fs_flags    = FS_REQUIRES_DEV,
 };
 
+#ifdef CONFIG_SDFAT_USE_FOR_EXFAT
+static struct file_system_type exfat_fs_type = {
+       .owner       = THIS_MODULE,
+       .name        = "exfat",
+       .mount       = sdfat_fs_mount,
+#ifdef CONFIG_SDFAT_DBG_IOCTL
+       .kill_sb    = sdfat_debug_kill_sb,
+#else
+       .kill_sb    = kill_block_super,
+#endif /* CONFIG_SDFAT_DBG_IOCTL */
+       .fs_flags    = FS_REQUIRES_DEV,
+};
+#endif /* CONFIG_SDFAT_USE_FOR_EXFAT */
+
 static int __init init_sdfat_fs(void)
 {
        int err;
@@ -5219,6 +5233,14 @@ static int __init init_sdfat_fs(void)
                goto error;
        }
 
+#ifdef CONFIG_SDFAT_USE_FOR_EXFAT
+       err = register_filesystem(&exfat_fs_type);
+       if (err) {
+               pr_err("[SDFAT] failed to register for exfat filesystem\n");
+               goto error;
+       }
+#endif /* CONFIG_SDFAT_USE_FOR_EXFAT */
+
        return 0;
 error:
        sdfat_uevent_uninit();
@@ -5258,6 +5280,10 @@ static void __exit exit_sdfat_fs(void)
        sdfat_destroy_inodecache();
        unregister_filesystem(&sdfat_fs_type);
 
+#ifdef CONFIG_SDFAT_USE_FOR_EXFAT
+       unregister_filesystem(&exfat_fs_type);
+#endif /* CONFIG_SDFAT_USE_FOR_EXFAT */
+
        fsapi_shutdown();
 }