genode/repos/os/src/server/part_blk
Emery Hemingway 1fce8d0d74 default ahci_drv and part_blk Block sessions to read-only
Add a "writeable" policy option to the ahci_drv and part_blk Block
servers and default from writeable to ready-only. Should a policy
permit write acesss the session request argument "writeable" may still
downgrade a session to ready-only.

Fix #2469
2017-08-28 16:49:51 +02:00
..
component.h default ahci_drv and part_blk Block sessions to read-only 2017-08-28 16:49:51 +02:00
driver.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
gpt.h part_blk: added optional partitions report 2017-05-31 13:16:16 +02:00
main.cc part_blk: prevent deprecated warning 2017-05-31 13:16:18 +02:00
mbr.h part_blk: added optional partitions report 2017-05-31 13:16:16 +02:00
partition_table.h part_blk: added optional partitions report 2017-05-31 13:16:16 +02:00
README default ahci_drv and part_blk Block sessions to read-only 2017-08-28 16:49:51 +02:00
target.mk os: removal of deprecated os/config.h (fix #2431) 2017-05-31 13:16:22 +02:00

This directory contains an implementation of a block-device-partition server.

Behavior
--------

The server uses Genode's block-session interfaces as both front and back end,
leading to the most common use case where this server will reside "between" a
block-driver server and a higher level component like a file-system server.

At startup, the partition server will try to parse the master boot record (MBR)
of its back-end block session. If no partition table is found, the whole block
device is exported as partition '0'. In the other case, the MBR and possible
extended boot records (EBRs) are parsed and offered as separate block sessions
to the front-end clients. The four primary partitions will receive partition
numbers '1' to '4' whereas the first logical partition will be assigned to '5'.

The partition server also understands the GUID partition table (GPT). If the
config attribute 'use_gpt' is set to 'yes' it will first try to parse any
existing GPT. In case there is no GPT it will fall back to parsing the MBR.

In order to route a client to the right partition, the server parses its
configuration section looking for 'policy' tags.

XML Syntax:
! <policy label="<program name>" partition="<partition number>"  writeable="<boolean>"/>

part_blk supports partition reporting, which can be enabled via the
<report> configuration node. See below for an example. The report
looks like follows (for MBR resp. GPT).

! <partitions type="mbr">
!   <partition number="1" type="12" start="2048" length="2048"/>
!   <partition number="2" type="15" start="4096" length="16384"/>
!   <partition number="5" type="12" start="6144" length="4096"/>
!   <partition number="6" type="12" start="12288" length="8192"/>
! </partitions>
! <partitions type="gpt">
!   <partition number="1" name="one" type="ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
!     guid="5f4061cc-8d4a-4e6f-ad15-10b881b79aee" start="2048" length="2048"/>
!   <partition number="2" name="two" type="ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
!     guid="87199a83-d0f4-4a01-b9e3-6516a8579d61" start="4096" length="16351"/>
! </partitions>

Clients have read-only access to partitions unless overriden by a 'writeable'
policy attribute.

Usage
-----

Configuration snippet with two clients and an (hypothetical) IDE driver:
!<start name="ata_driver">
!  <resource name="RAM" quantum="1M" />
!  <provides><service name="Block"/></provides>
!  <config ata="yes" />
!</start>
!
!<start name="part_blk">
!  <resource name="RAM" quantum="10M" />
!  <provides><service name="Block" /></provides>
!
!  <!-- route part_blk to the ata_driver -->
!  <route>
!    <any-service><child name="ata_driver"/> <parent/><any-child/></any-service>
!  </route>
!
!  <!-- allow program 'test-part1' to access logical partition '6', while program
!      'test-part2' receives access to primary partition 1 -->
!  <config>
!    <report partitions="yes"/>
!    <policy label_prefix="test-part1" partition="6" writeable="yes"/>
!    <policy label_prefix="test-part2" partition="1" writeable="yes"/>
!  </config>
!</start>
!
!<!-- part_blk clients -->
!<start name="test-part1">
!  <binary name="test-part"/>
!  <resource name="RAM" quantum="10M" />
!  <route>
!    <any-service> <child name="part_blk" /> <parent/> <any-child/> </any-service>
!  </route>
!</start>
!
!<start name="test-part2">
!  <binary name="test-part"/>
!  <resource name="RAM" quantum="10M" />
!  <route>
!    <any-service> <child name="part_blk" /> <parent/> <any-child/> </any-service>
!  </route>
!</start>