From 549f77eafe1d2e5592e655c8247de7afc07984b3 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 23 Nov 2015 13:39:29 +0100 Subject: [PATCH] Catch exceptions when creating VFS Catch exceptions at File_system_factory::create. Print error message in Dir_file_system. Fixes #1786 --- repos/os/include/vfs/dir_file_system.h | 15 ++++++++++++--- repos/os/src/lib/vfs/file_system_factory.cc | 21 +++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h index 7dc0194b72..c9a427c6d3 100644 --- a/repos/os/include/vfs/dir_file_system.h +++ b/repos/os/include/vfs/dir_file_system.h @@ -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) { } } } diff --git a/repos/os/src/lib/vfs/file_system_factory.cc b/repos/os/src/lib/vfs/file_system_factory.cc index 746c065c8a..b07e5ec0c2 100644 --- a/repos/os/src/lib/vfs/file_system_factory.cc +++ b/repos/os/src/lib/vfs/file_system_factory.cc @@ -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; }