diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index a1f4b5373f..939c4cddbc 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -234,12 +234,18 @@ void Libc::Vfs_plugin::_with_info(File_descriptor &fd, FN const &fn) path.append_element("info"); try { - File_content const content(_alloc, *_root_dir, path.string(), - File_content::Limit{4096U}); - - content.xml([&] (Xml_node node) { - fn(node); }); - + /* + * Opening the info file repeatedly could be too expensive if + * file system servers are part of the VFS, because the directory + * status of the path would be checked at each VFS plugin every + * time. So, we open the file only once. + */ + static Readonly_file file { *_root_dir, path.string() }; + static char buffer[4096]; + Byte_range_ptr range(buffer, + min((size_t)(_root_dir->file_size(path.string())), + sizeof(buffer))); + with_xml_file_content(file, range, [&] (Xml_node node) { fn(node); }); } catch (...) { } }