vfs/fatfs: cleanup implementation

- remove redundant file system factory

- remove dead code block

  The code was guarded by preprocessor directives checking whether the
  contrib code define "_USE_MKFS" is 1. As "_USE_MKFS" is not set one
  for our port of FAT, the code was never executed and can be removed.

- remove uneffective config attributes

  Apparently, the former XML attributes to the plugin 'drive' and
  'codepage' had no effect. I tested them in a scenario with the VFS
  block server on a disk-image boot-module as back end. Regardless of
  the 'drive' value, the block session label was always "0". Regardless
  of the 'codepage' value, the FAT on the disk image succeeded to mount
  when not using '--codepage' for 'mkfs.fat' and failed to mount when
  using '--codepage' to specify a supported but foreign codepage for
  'mkfs.fat' (e.g. "720").

Ref #4220
This commit is contained in:
Martin Stein 2021-07-14 11:54:29 +02:00 committed by Christian Helmuth
parent 60c8369718
commit 2533d7b4b6
2 changed files with 6 additions and 76 deletions

View File

@ -3,40 +3,7 @@ This plugin provides resource-optimized FAT and exFAT support to the VFS library
Usage
~~~~~
The plugin takes two configuration options as XML attributes, 'codepage' and 'drive'.
A codepage number is required only for non-ASCII filename support. The 'drive' option
takes an integer value between 1 and 10 and is simply a symbolic identifier passed
thru the Block session request. In this manner multiple drives are supported.
Codepages
~~~~~~~~~
Support for non-ACII filenames is experimental and only one codepage
may be in use for any number of drives.
Supported codepages
--------------------------------
437 | U.S.
720 | Arabic
737 | Greek
771 | KBL
775 | Baltic
850 | Latin 1
852 | Latin 2
855 | Cyrillic
857 | Turkish
860 | Portuguese
861 | Icelandic
862 | Hebrew
863 | Canadian French
864 | Arabic
865 | Nordic
866 | Russian
869 | Greek 2
932 | Japanese (DBCS)
936 | Simplified Chinese (DBCS)
949 | Korean (DBCS)
950 | Traditional Chinese (DBCS)
The plugin takes no configuration options.
Caching
~~~~~~~~

View File

@ -312,38 +312,13 @@ class Fatfs::File_system : public Vfs::File_system
: _vfs_env(env)
{
{
static unsigned codepage = 0;
unsigned const cp = config.attribute_value<unsigned>(
"codepage", 0);
if (codepage != 0 && codepage != cp) {
Genode::error(
"cannot reinitialize codepage for FAT library, please "
"use additional VFS instances for additional codepages");
throw ~0;
}
if (f_setcp(cp) != FR_OK) {
Genode::error("invalid OEM code page '", cp, "'");
if (f_setcp(0) != FR_OK) {
Genode::error("failed to set codepage to 0");
throw FR_INVALID_PARAMETER;
}
codepage = cp;
}
auto const drive_num = config.attribute_value(
"drive", Genode::String<4>("0"));
#if _USE_MKFS == 1
if (config.attribute_value("format", false)) {
Genode::log("formatting drive ", drive_num, "...");
if (f_mkfs((const TCHAR*)drive_num.string(), 1, 0) != FR_OK) {
Genode::error("format of drive ", drive_num, " failed");
throw ~0;
}
}
#endif
/* mount the file system */
Genode::String<4> const drive_num { "0" };
switch (f_mount(&_fatfs, (const TCHAR*)drive_num.string(), 1)) {
case FR_OK: {
TCHAR label[24] = { '\0' };
@ -827,22 +802,10 @@ class Fatfs::File_system : public Vfs::File_system
struct Fatfs_factory : Vfs::File_system_factory
{
struct Inner : Vfs::File_system_factory
{
Inner(Genode::Env &env, Genode::Allocator &alloc) {
Fatfs::block_init(env, alloc); }
Vfs::File_system *create(Vfs::Env &env, Genode::Xml_node node) override
{
return new (env.alloc())
Fatfs::File_system(env, node);
}
};
Vfs::File_system *create(Vfs::Env &vfs_env, Genode::Xml_node node) override
{
static Inner factory(vfs_env.env(), vfs_env.alloc());
return factory.create(vfs_env, node);
Fatfs::block_init(vfs_env.env(), vfs_env.alloc());
return new (vfs_env.alloc()) Fatfs::File_system(vfs_env, node);
}
};