The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
partition.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
block_device.h
"
4
5
/**
6
* partition device structure representing a partition on a block device.
7
*/
8
typedef
struct
9
{
10
block_device_t
block
;
// partition block device wrapper.
11
block_device_t
*
parent
;
// parent block device backend.
12
uint32_t
start_lba
;
// starting LBA sector of partition.
13
}
partition_device_t
;
14
15
/**
16
* initialize a partition wrapper device around a parent block device.
17
* @param part partition device object to initialize.
18
* @param parent parent block device backend.
19
* @param start_lba starting LBA sector of partition.
20
* @return true on success, false on failure.
21
*/
22
bool
partition_initialize
(
partition_device_t
*part,
block_device_t
*parent,
uint32_t
start_lba);
23
24
/**
25
* detect an EXT2 partition on parent block device and initialize partition wrapper.
26
* checks MBR partition table and candidate LBAs (63, 2048, 0).
27
* @param part partition device object to initialize.
28
* @param parent parent block device backend.
29
* @return true if an EXT2 partition was found and initialized, false otherwise.
30
*/
31
bool
partition_detect_ext2
(
partition_device_t
*part,
block_device_t
*parent);
32
33
/* the volume label that tools/ext2/make_image.py gives a ginnOS root */
34
#define GINNOS_ROOT_LABEL "GINNOS_EXT2"
35
36
/**
37
* check that an ext2 filesystem on a block device has the ginnOS root label.
38
* the kernel uses this to not mount a disk of another operating system on
39
* real hardware.
40
* @param device the block device (a partition) with the filesystem.
41
* @return true if the superblock has the ext2 magic and GINNOS_ROOT_LABEL.
42
*/
43
bool
partition_is_ginnos_root
(
block_device_t
*
device
);
44
45
/**
46
* find the partition with the ginnOS root label on a disk: the primary MBR
47
* partitions, or the GPT partitions if the MBR is a protective one (type
48
* 0xEE). a disk without a partition table is checked as a whole.
49
* @param part the partition device to set up.
50
* @param parent the disk.
51
* @return true if a ginnOS root was found (part is set up).
52
*/
53
bool
partition_find_ginnos_root
(
partition_device_t
*part,
block_device_t
*parent);
block_device.h
block_device_t
struct block_device block_device_t
Definition
block_device.h:5
uint32_t
unsigned int uint32_t
Definition
fb.h:17
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.
Definition
partition.c:89
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,...
Definition
partition.c:272
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.
Definition
partition.c:181
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.
Definition
partition.c:133
device
a registered device.
Definition
device.h:114
partition_device_t
partition device structure representing a partition on a block device.
Definition
partition.h:9
partition_device_t::block
block_device_t block
Definition
partition.h:10
partition_device_t::parent
block_device_t * parent
Definition
partition.h:11
partition_device_t::start_lba
uint32_t start_lba
Definition
partition.h:12
src
drivers
disk
partition.h
Generated by
1.18.0