Allow defining ram_fs file content from config

This commit is contained in:
Norman Feske 2012-05-18 17:07:30 +02:00
parent 95766bd4a1
commit cdbd1630bb
2 changed files with 17 additions and 3 deletions

View File

@ -18,8 +18,9 @@ The following configuration illustates the way of how to express policy.
! </dir>
! <dir name="home">
! <dir name="user">
! <!-- just a place holder -->
! <rom name="timer" />
! <inline name=".vimrc">
! set hidden
! </inline>
! </dir>
! </dir>
! </content>
@ -33,7 +34,10 @@ The '<content>' sub node of the '<config>' node provides a way to pre-populate
the file system with directories and files. Note that '<dir>' nodes can be
arbitrarily nested. Files can be loaded from the ROM service. By adding the
optional 'at' attribute to a rom node, the file name can be defined
independently from the ROM module name.
independently from the ROM module name. In addition to creating files from
ROM modules, files can be created from data specified directly as part of the
configuration using '<inline>' nodes. The content of such nodes is used as
file content as is.
Session-specific access-control policy is expressed via one or more '<policy>'
nodes. At session-creation time, each policy node is matched against the label

View File

@ -598,6 +598,16 @@ static void preload_content(Genode::Allocator &alloc,
catch (Rm_session::Attach_failed) {
PWRN("Could not locally attach ROM file \"%s\"", (char *)name); }
}
/*
* Create file from inline data provided as content of the XML node
*/
if (sub_node.has_type("inline")) {
File *file = new (&alloc) File(alloc, name);
file->write(sub_node.content_addr(), sub_node.content_size(), 0);
dir.adopt_unsynchronized(file);
}
}
}