#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ipc/bd.h>
#include <async.h>
#include <as.h>
#include <fibril_synch.h>
#include <devmap.h>
#include <sys/types.h>
#include <sys/typefmt.h>
#include <inttypes.h>
#include <libblock.h>
#include <errno.h>
#include <bool.h>
#include <byteorder.h>
#include <assert.h>
#include <macros.h>
#include <task.h>
Go to the source code of this file.
Data Structures | |
struct | br_block_t |
Structure of a boot-record block. More... | |
struct | part |
Partition. More... | |
struct | pt_entry_t |
Structure of a partition table entry. More... | |
Defines | |
#define | NAME "mbr_part" |
Typedefs | |
typedef part | part_t |
Partition. | |
Enumerations | |
enum | { N_PRIMARY = 4, BR_SIGNATURE = 0xAA55 } |
enum | ptype { PT_UNUSED = 0x00, PT_EXTENDED = 0x05 } |
Functions | |
int | main (int argc, char **argv) |
static int | mbr_bd_read (part_t *p, uint64_t ba, size_t cnt, void *buf) |
Read blocks from partition. | |
static int | mbr_bd_write (part_t *p, uint64_t ba, size_t cnt, const void *buf) |
Write blocks to partition. | |
static int | mbr_bsa_translate (part_t *p, uint64_t ba, size_t cnt, uint64_t *gba) |
Translate block segment address with range checking. | |
static void | mbr_connection (ipc_callid_t iid, ipc_call_t *icall) |
static int | mbr_init (const char *dev_name) |
static part_t * | mbr_part_new (void) |
Allocate a new part_t structure. | |
static int | mbr_part_read (void) |
Read in partition records. | |
static void | mbr_pte_to_part (uint32_t base, const pt_entry_t *pte, part_t *part) |
Parse partition table entry. | |
Variables | |
static size_t | block_size |
static devmap_handle_t | indev_handle |
Partitioned device (inbound device). | |
static part_t | plist_head |
List of partitions. |
Handles the PC MBR partitioning scheme. Uses a block device and provides one for each partition.
Limitations:
Only works with boot records using LBA. CHS-only records are not supported.
Referemces:
The source of MBR structures for this driver have been the following Wikipedia articles:
The fact that the extended partition has type 0x05 is pure observation. (TODO: can it have any other type number?)
Definition in file mbr_part.c.