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

Behavior
--------

At startup, the partition multiplexer 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'.

It also understands the GUID partition table (GPT) and will always try to read
the MBR as well as the GPT and will bail out if both are considered valid. It
is up to the user to choose the right table. To do so, the 'ignore_mbr' or
'ignore_gpt' config attribute may be specified. Using both at the same time is
a configuration error. Apart from that, the server will show a warning in case
a protective MBR is found but GPT is ignored and abort.  If a valid GPT was
encountered without a proper protective MBR it will use the GPT but show a
diagnostic warning.

The partition multiplexer forwards the augmented Block session request that
now includes the partition's offset and number of blocks covered by it to
the block-device driver component.

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

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

part_block supports partition reporting, which can be enabled via the
'report' node in its configuration. 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" ram="1M">
!  <provides><service name="Block"/></provides>
!  <config ata="yes" />
!</start>
!
!<start name="part_block" ram="10M">
!  <provides><service name="Block" /></provides>
!
!  <!-- route part_block to the ata_driver -->
!  <route>
!    <any-service><child name="ata_driver"/> <parent/><any-child/></any-service>
!  </route>
!
!  <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_block clients -->
!<start name="test-part1" ram="10M">
!  <binary name="test-part"/>
!  <route>
!    <any-service> <child name="part_block" /> <parent/> <any-child/> </any-service>
!  </route>
!</start>
!
!<start name="test-part2" ram="10M">
!  <binary name="test-part"/>
!  <route>
!    <any-service> <child name="part_block" /> <parent/> <any-child/> </any-service>
!  </route>
!</start>
