KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Fields
kos_blockdev Struct Reference

A simple block device. More...

#include <kos/blockdev.h>

Data Fields

void * dev_data
 Internal device data.
uint32_t l_block_size
 Log base 2 of the bytes per block.
int(* init )(struct kos_blockdev *d)
 Initialize the block device.
int(* shutdown )(struct kos_blockdev *d)
 Shut down the block device.
int(* read_blocks )(struct kos_blockdev *d, uint32_t block, size_t count, void *buf)
 Read a number of blocks from the device.
int(* write_blocks )(struct kos_blockdev *d, uint32_t block, size_t count, const void *buf)
 Write a number of blocks to the device.
uint32_t(* count_blocks )(struct kos_blockdev *d)
 Count the number of blocks on the device.

Detailed Description

A simple block device.

This structure represents a single block device. Each block device should be associated with exactly one filesystem and is used to actually read the data from the disk (or other device) where it is stored.

By using a block device with any new filesystems, we can abstract away a few things so that filesystems can be used with a variety of different "devices", such as the SD card reader for the Dreamcast or a disk image file of some sort.


Field Documentation

uint32_t(* kos_blockdev::count_blocks)(struct kos_blockdev *d)

Count the number of blocks on the device.

This function should return the total number of blocks on the device. There is no expectation of the device to keep track of which blocks are in use or anything else of the sort.

Parameters:
dThe device to read the block count from.
Returns:
The number of blocks that the device has.
void* kos_blockdev::dev_data

Internal device data.

int(* kos_blockdev::init)(struct kos_blockdev *d)

Initialize the block device.

This function should do any necessary initialization to use the block device passed in.

Parameters:
dThe device to initialize.
Return values:
0On success.
-1On failure. Set errno as appropriate.
uint32_t kos_blockdev::l_block_size

Log base 2 of the bytes per block.

int(* kos_blockdev::read_blocks)(struct kos_blockdev *d, uint32_t block, size_t count, void *buf)

Read a number of blocks from the device.

This function should read the specified number of device blocks into the given buffer. The buffer will already be allocated by the caller.

Parameters:
dThe device to read from.
blockThe first block to read.
countThe number of blocks to read.
bufThe buffer to read into.
Return values:
0On success.
-1On failure. Set errno as appropriate.
int(* kos_blockdev::shutdown)(struct kos_blockdev *d)

Shut down the block device.

This function should do any teardown work that is needed to clean up the block device.

Parameters:
dThe device to shut down.
Return values:
0On success.
-1On failure. Set errno as appropriate.
int(* kos_blockdev::write_blocks)(struct kos_blockdev *d, uint32_t block, size_t count, const void *buf)

Write a number of blocks to the device.

This function should write the specified number of device blocks onto the device from the given buffer.

Parameters:
dThe device to write to.
blockThe first block to write.
countThe number of blocks to write.
bufThe buffer to write from.
Return values:
0On success.
-1On failure. Set errno as appropriate.

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