RTEMS  5.1
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Block Device Partition Management

This module provides functions to manage partitions of a disk device. More...

Files

file  bdpart.h
 Block Device Partition Management.
 
file  bdpart-create.c
 Manage Partitions of a Disk Device.
 
file  bdpart-dump.c
 Prints the Partition Table Partitions with Count Partitions.
 
file  bdpart-mount.c
 Block Device Partition Management.
 
file  bdpart-read.c
 Block Device Partition Management.
 
file  bdpart-register.c
 Block Device Partition Management.
 
file  bdpart-sort.c
 Block Device Partition Management.
 
file  bdpart-write.c
 Block Device Partition Management.
 
file  show_bdbuf.c
 Enable the Monitor to Show bdbuf Information.
 

Data Structures

struct  rtems_bdpart_partition
 
union  rtems_bdpart_format
 

Macros

#define RTEMS_BDPART_PARTITION_NUMBER_HINT   16
 

Typedefs

typedef struct rtems_bdpart_partition rtems_bdpart_partition
 

Enumerations

enum  rtems_bdpart_format_type { RTEMS_BDPART_FORMAT_MBR, RTEMS_BDPART_FORMAT_GPT }
 

Functions

rtems_status_code rtems_bdpart_read (const char *disk_name, rtems_bdpart_format *format, rtems_bdpart_partition *partitions, size_t *count)
 Reads the partition information from the physical disk device with name disk_name. More...
 
void rtems_bdpart_sort (rtems_bdpart_partition *partitions, size_t count)
 Sorts the partition table partitions with count partitions to have ascending begin blocks.
 
rtems_status_code rtems_bdpart_write (const char *disk_name, const rtems_bdpart_format *format, const rtems_bdpart_partition *partitions, size_t count)
 Writes the partition table to the physical disk device with name disk_name. More...
 
rtems_status_code rtems_bdpart_create (const char *disk_name, const rtems_bdpart_format *format, rtems_bdpart_partition *partitions, const unsigned *distribution, size_t count)
 Creates a partition table in partitions with count partitions for the physical disk device with name disk_name. More...
 
rtems_status_code rtems_bdpart_register (const char *disk_name, const rtems_bdpart_partition *partitions, size_t count)
 Registers the partitions as logical disks for the physical disk device with name disk_name. More...
 
rtems_status_code rtems_bdpart_register_from_disk (const char *disk_name)
 
rtems_status_code rtems_bdpart_unregister (const char *disk_name, const rtems_bdpart_partition *partitions, size_t count)
 Deletes the logical disks associated with the partitions of the disk device with name disk_name. More...
 
rtems_status_code rtems_bdpart_mount (const char *disk_name, const rtems_bdpart_partition *partitions, size_t count, const char *mount_base)
 Mounts all supported file systems inside the logical disks derived from the partitions of the physical disk device with name disk_name. More...
 
rtems_status_code rtems_bdpart_unmount (const char *disk_name, const rtems_bdpart_partition *partitions, size_t count, const char *mount_base)
 Unmounts all file systems mounted with rtems_bdpart_mount().
 
void rtems_bdpart_dump (const rtems_bdpart_partition *partitions, size_t count)
 Prints the partition table partitions with count partitions to standard output.
 
void rtems_bdpart_to_partition_type (uint8_t mbr_type, uuid_t type)
 Returns the partition type for the MBR partition type value mbr_type in type.
 
bool rtems_bdpart_to_mbr_partition_type (const uuid_t type, uint8_t *mbr_type)
 Converts the partition type in type to the MBR partition type. More...
 

MBR Partition Types and Flags

#define RTEMS_BDPART_MBR_EMPTY   0x0U
 
#define RTEMS_BDPART_MBR_FAT_12   0x1U
 
#define RTEMS_BDPART_MBR_FAT_16   0x4U
 
#define RTEMS_BDPART_MBR_FAT_16_LBA   0xeU
 
#define RTEMS_BDPART_MBR_FAT_32   0xbU
 
#define RTEMS_BDPART_MBR_FAT_32_LBA   0xcU
 
#define RTEMS_BDPART_MBR_EXTENDED   0x5U
 
#define RTEMS_BDPART_MBR_DATA   0xdaU
 
#define RTEMS_BDPART_MBR_GPT   0xeeU
 
#define RTEMS_BDPART_MBR_FLAG_ACTIVE   0x80U
 

Detailed Description

This module provides functions to manage partitions of a disk device.

A disk is a set of blocks which are identified by a consecutive set of non-negative integers starting at zero. There are also logical disks which contain a subset of consecutive disk blocks. The logical disks are used to represent the partitions of a disk. The disk devices are accessed via the block device buffer module.

The partition format on the physical disk will be converted to an internal representation. It is possible to convert the internal representation into a specific output format and write it to the physical disk. One of the constrains for the internal representation was to support the GPT format easily.

Currently two physical partition formats are supported. These are the MBR and the GPT format. Please note that the GPT support is not implemented. With MBR format we mean the partition format of the wide spread IBM PC-compatible systems. The GPT format is defined in the Extensible Firmware Interface (EFI).

The most common task will be to read the partition information of a disk and register logical disks for each partition. This can be done with the rtems_bdpart_register_from_disk() function. Afterwards you can mount the file systems within the partitions.

You can read the partition information from a disk with rtems_bdpart_read() and write it to the disk with rtems_bdpart_write().

To create a partition table from scratch for a disk use rtems_bdpart_create().

You can access some disk functions with the shell command fdisk.

References used to create this module:

Macro Definition Documentation

◆ RTEMS_BDPART_PARTITION_NUMBER_HINT

#define RTEMS_BDPART_PARTITION_NUMBER_HINT   16

Recommended maximum partition table size.

Typedef Documentation

◆ rtems_bdpart_partition

Partition description.

Enumeration Type Documentation

◆ rtems_bdpart_format_type

Disk format for the partition tables.

Enumerator
RTEMS_BDPART_FORMAT_MBR 

Type value for MBR format.

RTEMS_BDPART_FORMAT_GPT 

Type value for GPT format.

Function Documentation

◆ rtems_bdpart_create()

rtems_status_code rtems_bdpart_create ( const char *  disk_name,
const rtems_bdpart_format format,
rtems_bdpart_partition partitions,
const unsigned *  distribution,
size_t  count 
)

Creates a partition table in partitions with count partitions for the physical disk device with name disk_name.

The array of positive integer weights in distribution must have exactly count elements. The weights in the distribution array are summed up. Each weight is then divided by the sum to obtain the disk fraction which forms the corresponding partition. The partition boundaries are generated with respect to the output format in format.

◆ rtems_bdpart_mount()

rtems_status_code rtems_bdpart_mount ( const char *  disk_name,
const rtems_bdpart_partition partitions,
size_t  count,
const char *  mount_base 
)

Mounts all supported file systems inside the logical disks derived from the partitions of the physical disk device with name disk_name.

For each partition in the partition table partitions with count partitions it will be checked if it contains a supported file system. In this case a mount point derived from the disk name will be created in the mount base path mount_base. The file system will be mounted there. The partition number equals the partition table index plus one. The mount point name for each partition will be the concatenation of the mount base path, the disk device file name and the parition number.

See also
rtems_bdpart_read().

◆ rtems_bdpart_read()

rtems_status_code rtems_bdpart_read ( const char *  disk_name,
rtems_bdpart_format format,
rtems_bdpart_partition partitions,
size_t *  count 
)

Reads the partition information from the physical disk device with name disk_name.

The partition information will be stored in the partition table partitions with a maximum of count partitions. The number of actual partitions will be stored in count. If there are more partitions than space for storage an error status will be returned. The partition table format recognized on the disk will be stored in format.

◆ rtems_bdpart_register()

rtems_status_code rtems_bdpart_register ( const char *  disk_name,
const rtems_bdpart_partition partitions,
size_t  count 
)

Registers the partitions as logical disks for the physical disk device with name disk_name.

For each partition of the partition table partitions with count partitions a logical disk is registered. The partition number equals the partition table index plus one. The name of the logical disk device is the concatenation of the physical disk device name and the partition number.

See also
rtems_blkdev_create_partition().

◆ rtems_bdpart_register_from_disk()

rtems_status_code rtems_bdpart_register_from_disk ( const char *  disk_name)

brief Reads the partition table from the disk device with name disk_name and registers the partitions as logical disks.

See also
rtems_bdpart_register() and rtems_fsmount().

◆ rtems_bdpart_to_mbr_partition_type()

bool rtems_bdpart_to_mbr_partition_type ( const uuid_t  type,
uint8_t *  mbr_type 
)

Converts the partition type in type to the MBR partition type.

The result will be stored in mbr_type. Returns true in case of a successful convertion and otherwise false. Both arguments must not be NULL.

◆ rtems_bdpart_unregister()

rtems_status_code rtems_bdpart_unregister ( const char *  disk_name,
const rtems_bdpart_partition partitions,
size_t  count 
)

Deletes the logical disks associated with the partitions of the disk device with name disk_name.

The partition table partitions with count partitions will be used to determine which disks need to be deleted. It may be obtained from rtems_bdpart_read().

◆ rtems_bdpart_write()

rtems_status_code rtems_bdpart_write ( const char *  disk_name,
const rtems_bdpart_format format,
const rtems_bdpart_partition partitions,
size_t  count 
)

Writes the partition table to the physical disk device with name disk_name.

The partition table partitions with count partitions will be written to the disk. The output format for the partition table on the disk is specified by format. There are some consistency checks applied to the partition table. The partition table must be sorted such that the begin blocks are in ascending order. This can be done with the rtems_bdpart_sort() function. The partitions must not overlap. The partitions must have a positive size. The partitions must be within the disk. Depending on the output format there are additional constrains.