Catch exceptions when creating VFS

Catch exceptions at File_system_factory::create.
Print error message in Dir_file_system.

Fixes #1786
This commit is contained in:
Emery Hemingway 2015-11-23 13:39:29 +01:00 committed by Christian Helmuth
parent 4aafa882d8
commit 549f77eafe
2 changed files with 25 additions and 11 deletions

View File

@ -210,6 +210,8 @@ class Vfs::Dir_file_system : public File_system
:
_first_file_system(0)
{
using namespace Genode;
/* remember directory name */
if (node.has_type("fstab") || node.has_type("vfs"))
_name[0] = 0;
@ -233,9 +235,16 @@ class Vfs::Dir_file_system : public File_system
continue;
}
char type_name[64];
sub_node.type_name(type_name, sizeof(type_name));
PWRN("unknown fstab node type <%s>", type_name);
PERR("failed to create <%s> VFS node", sub_node.type().string());
try {
String<64> value;
for (unsigned i = 0; i < 16; ++i) {
Xml_attribute attr = sub_node.attribute(i);
attr.value(&value);
PERR("\t%s=\"%s\"", attr.name().string(), value.string());
}
} catch (Xml_node::Nonexistent_attribute) { }
}
}

View File

@ -169,16 +169,21 @@ class Default_file_system_factory : public Vfs::Global_file_system_factory
Vfs::File_system *create(Genode::Xml_node node) override
{
/* try if type is handled by the currently registered fs types */
if (Vfs::File_system *fs = _try_create(node))
return fs;
/* probe for file system implementation available as shared lib */
if (_probe_external_factory(node)) {
/* try again with the new file system type loaded */
try {
/* try if type is handled by the currently registered fs types */
if (Vfs::File_system *fs = _try_create(node))
return fs;
}
/* if the builtin fails, do not try loading an external */
} catch (...) { return 0; }
try {
/* probe for file system implementation available as shared lib */
if (_probe_external_factory(node)) {
/* try again with the new file system type loaded */
if (Vfs::File_system *fs = _try_create(node))
return fs;
}
} catch (...) { }
return 0;
}