The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
partition.h File Reference
#include "block_device.h"

Go to the source code of this file.

Data Structures

struct  partition_device_t
 partition device structure representing a partition on a block device. More...

Macros

#define GINNOS_ROOT_LABEL   "GINNOS_EXT2"

Functions

bool partition_initialize (partition_device_t *part, block_device_t *parent, uint32_t start_lba)
 initialize a partition wrapper device around a parent block device.
bool partition_detect_ext2 (partition_device_t *part, block_device_t *parent)
 detect an EXT2 partition on parent block device and initialize partition wrapper.
bool partition_is_ginnos_root (block_device_t *device)
 check that an ext2 filesystem on a block device has the ginnOS root label.
bool partition_find_ginnos_root (partition_device_t *part, block_device_t *parent)
 find the partition with the ginnOS root label on a disk: the primary MBR partitions, or the GPT partitions if the MBR is a protective one (type 0xEE).

Macro Definition Documentation

◆ GINNOS_ROOT_LABEL

#define GINNOS_ROOT_LABEL   "GINNOS_EXT2"

Function Documentation

◆ partition_initialize()

bool partition_initialize ( partition_device_t * part,
block_device_t * parent,
uint32_t start_lba )

initialize a partition wrapper device around a parent block device.

Parameters
partpartition device object to initialize.
parentparent block device backend.
start_lbastarting LBA sector of partition.
Returns
true on success, false on failure.

◆ partition_detect_ext2()

bool partition_detect_ext2 ( partition_device_t * part,
block_device_t * parent )

detect an EXT2 partition on parent block device and initialize partition wrapper.

checks MBR partition table and candidate LBAs (63, 2048, 0).

Parameters
partpartition device object to initialize.
parentparent block device backend.
Returns
true if an EXT2 partition was found and initialized, false otherwise.

◆ partition_is_ginnos_root()

bool partition_is_ginnos_root ( block_device_t * device)

check that an ext2 filesystem on a block device has the ginnOS root label.

the kernel uses this to not mount a disk of another operating system on real hardware.

Parameters
devicethe block device (a partition) with the filesystem.
Returns
true if the superblock has the ext2 magic and GINNOS_ROOT_LABEL.

◆ partition_find_ginnos_root()

bool partition_find_ginnos_root ( partition_device_t * part,
block_device_t * parent )

find the partition with the ginnOS root label on a disk: the primary MBR partitions, or the GPT partitions if the MBR is a protective one (type 0xEE).

a disk without a partition table is checked as a whole.

Parameters
partthe partition device to set up.
parentthe disk.
Returns
true if a ginnOS root was found (part is set up).