fs: sdfat: Add config option to register sdFAT for VFAT
authorPaul Keith <javelinanddart@gmail.com>
Fri, 2 Mar 2018 04:10:27 +0000 (05:10 +0100)
committerMichael Benedict <michaelbt@live.com>
Sun, 25 Aug 2019 14:16:47 +0000 (00:16 +1000)
Change-Id: I72ba7a14b56175535884390e8601960b5d8ed1cf
Signed-off-by: Paul Keith <javelinanddart@gmail.com>
fs/sdfat/Kconfig
fs/sdfat/sdfat.c

index 3fe86e72c40b3cddb6866843a5f68a3ccbc4fbdd..1b67632c7d39e584b6cd03b5121fba426893678e 100644 (file)
@@ -22,6 +22,13 @@ config SDFAT_USE_FOR_EXFAT
        help
          If you want to register sdFAT as available for exFAT, say Y.
 
+config SDFAT_USE_FOR_VFAT
+       bool "Register sdFAT as VFAT"
+       default y
+       depends on SDFAT_FS && !VFAT_FS
+       help
+         If you want to register sdFAT as available for VFAT, say Y.
+
 config SDFAT_DELAYED_META_DIRTY
        bool "Enable delayed metadata dirty"
        default y
index 9d50d0ce72de4e69c1c9f8d728c8c1b87ab4b555..c1a2c2ec1b67ff3d8780226ba7dd87c340aad3cb 100644 (file)
@@ -4532,6 +4532,12 @@ enum {
        Opt_discard,
        Opt_fs,
        Opt_adj_req,
+#ifdef CONFIG_SDFAT_USE_FOR_VFAT
+       Opt_shortname_lower,
+       Opt_shortname_win95,
+       Opt_shortname_winnt,
+       Opt_shortname_mixed,
+#endif /* CONFIG_SDFAT_USE_FOR_VFAT */
 };
 
 static const match_table_t sdfat_tokens = {
@@ -4560,6 +4566,12 @@ static const match_table_t sdfat_tokens = {
        {Opt_discard, "discard"},
        {Opt_fs, "fs=%s"},
        {Opt_adj_req, "adj_req"},
+#ifdef CONFIG_SDFAT_USE_FOR_VFAT
+       {Opt_shortname_lower, "shortname=lower"},
+       {Opt_shortname_win95, "shortname=win95"},
+       {Opt_shortname_winnt, "shortname=winnt"},
+       {Opt_shortname_mixed, "shortname=mixed"},
+#endif /* CONFIG_SDFAT_USE_FOR_VFAT */
        {Opt_err, NULL}
 };
 
@@ -4726,6 +4738,14 @@ static int parse_options(struct super_block *sb, char *options, int silent,
                        IMSG("adjust request config is not enabled. ignore\n");
 #endif
                        break;
+#ifdef CONFIG_SDFAT_USE_FOR_VFAT
+               case Opt_shortname_lower:
+               case Opt_shortname_win95:
+               case Opt_shortname_mixed:
+                       pr_warn("[SDFAT] DRAGONS AHEAD! sdFAT only understands \"shortname=winnt\"!\n");
+               case Opt_shortname_winnt:
+                       break;
+#endif /* CONFIG_SDFAT_USE_FOR_VFAT */
                default:
                        if (!silent) {
                                sdfat_msg(sb, KERN_ERR,
@@ -5065,6 +5085,20 @@ static struct file_system_type exfat_fs_type = {
 };
 #endif /* CONFIG_SDFAT_USE_FOR_EXFAT */
 
+#ifdef CONFIG_SDFAT_USE_FOR_VFAT
+static struct file_system_type vfat_fs_type = {
+       .owner       = THIS_MODULE,
+       .name        = "vfat",
+       .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_VFAT */
+
 static int __init init_sdfat_fs(void)
 {
        int err;
@@ -5111,6 +5145,14 @@ static int __init init_sdfat_fs(void)
        }
 #endif /* CONFIG_SDFAT_USE_FOR_EXFAT */
 
+#ifdef CONFIG_SDFAT_USE_FOR_VFAT
+       err = register_filesystem(&vfat_fs_type);
+       if (err) {
+               pr_err("[SDFAT] failed to register for vfat filesystem\n");
+               goto error;
+       }
+#endif /* CONFIG_SDFAT_USE_FOR_VFAT */
+
        return 0;
 error:
        sdfat_statistics_uninit();
@@ -5143,6 +5185,9 @@ static void __exit exit_sdfat_fs(void)
 #ifdef CONFIG_SDFAT_USE_FOR_EXFAT
        unregister_filesystem(&exfat_fs_type);
 #endif /* CONFIG_SDFAT_USE_FOR_EXFAT */
+#ifdef CONFIG_SDFAT_USE_FOR_VFAT
+       unregister_filesystem(&vfat_fs_type);
+#endif /* CONFIG_SDFAT_USE_FOR_VFAT */
        fsapi_shutdown();
 }