genode/repos/os/run/lx_fs_import.run
Norman Feske 2c8beb462f file-system session: root dir via session label
This patch changes the way of how the client-selected sub directory is
communicated to the server. The former opaque session argument is now
passed as last label element, which allows for the flexible tweaking
of this argument by init's session-routing and label-rewriting
mechansims. In particular, it alleviates the need for creating chroot
component instances.

This change requires the following four adaptations at the
configuration level:

- Each file-system session request must now carry a path starting
  with / as last session arguments. Hence, <vfs> <fs> nodes that
  feature a 'label' attributes must extend the attribute value
  with " -> /". For <fs> nodes with no label attribute, "/" is
  used as last label argument by default.

- For matching session-routing rules at init's configuration,
  the matching of full labels should be replaced by 'label_prefix'
  matches, excluding the last (path) argument.

- Wherever a label of a file-system session is rewritten by using
  init's 'label' attribute of a <parent> or <child> target node,
  the new attribute 'identity' should be used instead. This replaces
  the identity part of the label while preserving the client's
  directory argument.

- Analogously to the matching of session-routing rules, server-side
  policy-selection rules that formerly matched a concrete 'label'
  must be changed to match a 'label_prefix' instead.

As a good practice, 'label_prefix' values should end with " ->" if
possible, which clearly delimits the identity part of the label
used by the matching.

Issue #5445
2025-02-24 16:39:20 +01:00

115 lines
2.7 KiB
Plaintext

assert_spec linux
lappend depot_archives [depot_user]/src/[base_src]
lappend depot_archives [depot_user]/src/init
lappend depot_archives [depot_user]/src/vfs
lappend depot_archives [depot_user]/src/vfs_import
set build_components { }
if { [get_cmd_switch --autopilot] } {
lappend depot_archives [depot_user]/src/lx_fs
} else {
lappend build_components server/lx_fs
}
create_boot_directory
install_config {
<config>
<parent-provides>
<service name="ROM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<resource name="RAM" preserve="200M"/>
<resource name="CAP" preserve="1000"/>
<start name="timer" caps="100" ram="1M">
<provides> <service name="Timer"/> </provides>
</start>
<start name="import_lx_fs" caps="220" ram="8M" ld="no">
<binary name="lx_fs"/>
<provides>
<service name="File_system"/>
</provides>
<config>
<policy label_prefix="import_showcase ->" root="/" writeable="yes"/>
</config>
<route>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="import_showcase" caps="100" ram="4M">
<binary name="vfs"/>
<provides>
<service name="File_system"/>
</provides>
<config>
<vfs> <fs/>
<import overwrite="false">
<dir name="test-existing-file">
<inline name="a_file">Hello Friend!</inline>
</dir>
<dir name="test-file">
<inline name="foo">bar</inline>
</dir>
<dir name="test-existing-directory">
<inline name="foo">bar</inline>
</dir>
</import>
</vfs>
</config>
<route>
<service name="File_system"> <child name="import_lx_fs"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
</config>
}
import_from_depot $depot_archives
if { [llength $build_components] > 0 } {
build $build_components
}
build_boot_image [build_artifacts]
## Create files before genode is run
exec mkdir -p [run_dir]/genode/test-existing-file
exec echo "This file already exist." > [run_dir]/genode/test-existing-file/a_file
exec mkdir -p [run_dir]/genode/test-existing-directory
append qemu_args " -nographic "
run_genode_until "Warning: skipping copy of file /test-existing-file/a_file, OPEN_ERR_EXISTS" 20
set created_file { [run_dir]/genode/test-file/foo }
if { [file exists $created_file] == 1 } {
puts { "Imported file not found." }
exit 1
}
set created_file_in_dir { [run_dir]/genode/test-existing-directory/foo }
if { [file exists $created_file] == 1 } {
puts { "Imported file not found." }
exit 1
}