Overview   API Reference  

partition_driver Struct Reference

Class wrapping another block driver's sectors into a partition by "moving" all sectors up and inserting fake (read-only) MBR/GPT partition tables at the beginning and the end of the disk. More...

#include <partition_driver.hpp>

Inheritance diagram for partition_driver:

Inheritance graph
[legend]
Collaboration diagram for partition_driver:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 partition_driver (block_driver *driver, const uint16_t partition_type=DEFAULT_PARTITION_TYPE)
virtual int reset (void)
 Resets the driver's state back to defaults as when powering up the machine.
virtual const char * name (void) const
 Returns the driver's name.
virtual bool is (const state_flags flags) const
 Returns whether a specific feature/state (or all) is currently present/active.
virtual const state_flags state (void) const
 Returns all feature/state flags at once.
virtual l4_sector_t sectors (void) const
 Returns the number of disk sectors the underlying medium (e.g a file) provides.
virtual int read_sectors (uint8_t *buffer, l4_sector_t sector, l4_sector_t number)
 Reads (from disk) the specified number of sectors starting at the specified sector (inclusive) into the specified data buffer (which must be big enough).
virtual int write_sectors (uint8_t *buffer, l4_sector_t sector, l4_sector_t number)
 Writes (to disk) the specified number of sectors starting at the specified sector (inclusive) from the specified data buffer (which must be big enough).
virtual int flush_sectors (void)
 Flushes all currently pending operations.

Static Public Attributes

static const uint16_t DEFAULT_PARTITION_TYPE = 0x83
 Default partition type to pretend.
static const uint16_t START_SECTORS = 30
 Number of fake sectors at the beginning of the disk (should be >= 30).
static const uint16_t END_SECTORS = 30
 Number of fake sectors at the end of the disk (should be >= 29).

Protected Member Functions

virtual bool is_valid_partition (l4_sector_t start_lba, l4_sector_t end_lba)
 Returns whether the specified position is valid for an arbitrary data partition.
virtual int write_mbr (uint8_t type, l4_sector_t start_lba, l4_sector_t end_lba, uint8_t attributes=0)
 Writes an MBR partition table (and tag) containing 1 entry for the specified parameters and the EFI protective partitions.
virtual int write_gpt (uint8_t type, l4_sector_t start_lba, l4_sector_t end_lba, uint64_t attributes=0)
 Writes a GPT partition table containing 1 entry for the specified parameters.
virtual int build_fake_sectors (void)
 Builds the fake sectors by writing an MBR & GPT partition table into the buffers.
int read_write_sectors (uint8_t read_write, uint8_t *buffer, l4_sector_t sector, l4_sector_t number)
 Internal read/write sectors implementation.

Protected Attributes

const uint16_t partition_type
 Partition type to pretend.
block_driver *const driver
 Other driver to provide sectors in between.
const l4_sector_t driver_start_lba
 First sector the other driver provides.
const l4_sector_t driver_end_lba
 Last sector the other driver provides.
const l4_sector_t size
 The (virtual) disk's size including fake sectors.
uint8_t start_sectors [START_SECTORS *SECTOR_SIZE]
 Fake sectors at the beginning of the disk.
uint8_t end_sectors [END_SECTORS *SECTOR_SIZE]
 Fake sectors at the end of the disk.

Static Protected Attributes

static const efi::guid_t DUMMY_GUID
 Default dummy GUID used for disk and partition IDs (GPT).
static const uint32_t DUMMY_UID = 0x01020304
 Default dummy UID used as disk ID (MBR).


Detailed Description

Class wrapping another block driver's sectors into a partition by "moving" all sectors up and inserting fake (read-only) MBR/GPT partition tables at the beginning and the end of the disk.

Useful for plain files without a partition table or windhoek single partition pass-through.


Member Function Documentation

virtual int partition_driver::reset ( void   )  [inline, virtual]

Resets the driver's state back to defaults as when powering up the machine.

Returns 0 on success. Negative error codes otherwise.

Implements block_driver.

References driver, and block_driver::reset().

virtual int partition_driver::read_sectors ( uint8_t *  buffer,
l4_sector_t  sector,
l4_sector_t  number 
) [inline, virtual]

Reads (from disk) the specified number of sectors starting at the specified sector (inclusive) into the specified data buffer (which must be big enough).

Returns 0 on success. Negative error codes otherwise.

Implements block_driver.

References read_write_sectors().

virtual int partition_driver::write_sectors ( uint8_t *  buffer,
l4_sector_t  sector,
l4_sector_t  number 
) [inline, virtual]

Writes (to disk) the specified number of sectors starting at the specified sector (inclusive) from the specified data buffer (which must be big enough).

Returns 0 on success. Negative error codes otherwise.

Implements block_driver.

References read_write_sectors().

virtual int partition_driver::flush_sectors ( void   )  [inline, virtual]

Flushes all currently pending operations.

That is requests to write to the backend, if the driver provides some mechanism to cache blocks. Returns 0 on success. Negative error codes otherwise.

Implements block_driver.

References driver, and block_driver::flush_sectors().


Member Data Documentation

const efi::guid_t partition_driver::DUMMY_GUID [static, protected]

Initial value:

{
    0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
}
Default dummy GUID used for disk and partition IDs (GPT).

Referenced by write_gpt().


The documentation for this struct was generated from the following files:

L4vmm Reference Manual, written by Mario Schwalbe  © 2006-2008